Hi there, 
        
The issue DYNPROXY-ISSUE-87 was just created by Krzysztof Ko?mic (xtoff).
        
        Key: DYNPROXY-ISSUE-87
        Summary: Mixin takes precedence over target object
        Type: Bug
        Importance: High
        
        Description:
        Say we have the following classes:
        public interface IMixins
        {
            void Foo();
        }
        internal class MixinsTwo : IMixins
        {
            public void Foo()
            {
                MixinsTwoCallCount++;
                Console.WriteLine(GetType());
            }
            public int MixinsTwoCallCount { get; private set; }
        }
        [Serializable]
        internal class MixinsOne : IMixins
        {
            public void Foo()
            {
                this.MixinsOneCallCount++;
                Console.WriteLine(GetType());
            }
            public int MixinsOneCallCount { get; private set; }
        }
Suppose we want to proxy one type, and use another type as mixin. If we call 
common interface's member on the proxy, the call will be invoked on mixin, not 
on target, which I consider a bug.
See the following failing test:
            [Test]
            public void InvalidMixinBehavior()
            {
            var proxyGenerationOptions = new ProxyGenerationOptions();
                var mixin = new MixinsOne();
                proxyGenerationOptions.AddMixinInstance(mixin);
            object proxy = generator.CreateClassProxy(
                typeof(MixinsTwo), proxyGenerationOptions, new 
AssertInvocationInterceptor());
                var proxyAsMixin = proxy as IMixins;
            Assert.IsNotNull(proxyAsMixin);
                mixin.Foo();
            Assert.AreEqual(0, mixin.MixinsOneCallCount);
            Assert.AreEqual(1, (proxy as MixinsTwo).MixinsTwoCallCount);
            }
Now, I'm not really sure that this should be the default behavior either, that 
is, I'm not sure we should simply forward the call to the target.
If we have such situation, we may rather want to throw an exception explaining 
that mixin and target type both implement the same interface, and that it's not 
a right thing to do.
On the other hand, this may be a valid choice, so we might prefer to allow it.
Things get even more complicated if we have multiple mixin instances that may 
implement the same interfaces. Currently this results in an exception. I think 
we probably should disallow it and throw an exception (but not IndexOutOfRange 
as it is now, but something more descriptive).
I don't really know since I use mixins rarely myself. Any opinions?
        
For more, see 
http://support.castleproject.org/projects/DYNPROXY/issues/view/DYNPROXY-ISSUE-87
 
        
--
donjon
by Castle Stronghold
http://www.castle-donjon.com



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Development List" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/castle-project-devel?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to