I've created the project, ran the tests, made some changes and came to
the conclusion that Unity is working for the most part, EXCEPT for 2
issues:
1) Some bits are not marked as Serializeable
2) Unity Interception does not like protected constructors. But as
soon as I mark the constructors as public, the tests pass...

I can't seem to find a Unity issue in JIRA?

Regards,
Dawid

On Jul 10, 7:21 pm, Dawid <[email protected]> wrote:
> Thx will do that...
>
> JIRA still down??
>
> On Jul 10, 2:10 pm, Fabio Maulo <[email protected]> wrote:
>
> > Very interesting.
> > Change the conf of NHibernate Tests project and run all tests with your
> > UnityBytecode and you will see the result.
> > btw, please check our JIRA about this issue and then add a zip with all
> > files needed (in this case could be better than a patch file).
>
> > On Fri, Jul 9, 2010 at 5:11 PM, Dawid <[email protected]> wrote:
> > > Hi,
>
> > > Without understanding most of the inner technical details of
> > > nHibernate, it would seem as if I've gotten Unity Interception to work
> > > as the LazyInitializer.
>
> > > Code for the LazyInitializer:
> > >  class LazyInitializer:  BasicLazyInitializer, IInterceptionBehavior
> > >  {
> > >    public bool _constructed;
>
> > >    public LazyInitializer(string entityName, Type persistentClass,
> > > object id, MethodInfo getIdentifierMethod, MethodInfo
> > > setIdentifierMethod, IAbstractComponentType componentIdType,
> > > ISessionImplementor session)
> > >      : base(entityName, persistentClass, id, getIdentifierMethod,
> > > setIdentifierMethod, componentIdType, session)
> > >    {
> > >    }
>
> > >    public IMethodReturn Invoke(IMethodInvocation input,
> > > GetNextInterceptionBehaviorDelegate getNext)
> > >    {
> > >      var result = input.CreateMethodReturn(null);
> > >      if (_constructed)
> > >      {
>
> > >        var args = new object[input.Arguments.Count];
> > >        input.Arguments.CopyTo(args, 0);
> > >        result.ReturnValue = base.Invoke((MethodInfo)input.MethodBase,
> > > args, input.Target);
> > >        if (result.ReturnValue == InvokeImplementation)
> > >        {
> > >          //var input2 = new
> > > VirtualMethodInvocation(GetImplementation(), input.MethodBase,
> > > input.Arguments);
> > >          result =
> > > input.CreateMethodReturn(input.MethodBase.Invoke(GetImplementation(),
> > > args));
> > >        }
> > >      }
> > >      return result;
> > >    }
>
> > >    public IEnumerable<Type> GetRequiredInterfaces()
> > >    {
> > >      return new[] {typeof (INHibernateProxy)};
> > >    }
>
> > >    public bool WillExecute
> > >    {
> > >      get { return true; }
> > >    }
>
> > > Code for the Proxy Factory:
> > >  class UnityProxyFactory: AbstractProxyFactory
> > >  {
> > >    public override INHibernateProxy GetProxy(object id,
> > > ISessionImplementor session)
> > >    {
> > >      INHibernateProxy proxy;
> > >      try
> > >      {
> > >        LazyInitializer initializer = new LazyInitializer(EntityName,
> > > PersistentClass, id, GetIdentifierMethod, SetIdentifierMethod,
> > > ComponentIdType, session);
> > >        object obj2 = IsClassProxy
> > >                        ?
> > > Intercept.NewInstanceWithAdditionalInterfaces(PersistentClass, new
> > > VirtualMethodInterceptor(),
>
> > > new[] {initializer}, Interfaces)
> > >                        :
> > > Intercept.NewInstanceWithAdditionalInterfaces(Interfaces[0], new
> > > VirtualMethodInterceptor(),
>
> > > new[] {initializer}, Interfaces);
> > >        initializer._constructed = true;
> > >        proxy = (INHibernateProxy)obj2;
> > >      }
> > >      catch (Exception exception)
> > >      {
> > >        //log.Error("Creating a proxy instance failed", exception);
> > >        throw new HibernateException("Creating a proxy instance
> > > failed", exception);
> > >      }
> > >      return proxy;
>
> > >    }
> > >  }
>
> > > Any comments / ideas? What sort of unit tests is required to make sure
> > > that Unity Interception is actually working correctly?
>
> > > Regards,
> > > Dawid Mostert
>
> > --
> > Fabio Maulo

Reply via email to