Skip to content
This repository has been archived by the owner on Aug 3, 2021. It is now read-only.

Proxy creation fails for classes having explicitly implemented interfaces #20

Open
GhoSe opened this issue Dec 13, 2011 · 0 comments
Open

Comments

@GhoSe
Copy link

GhoSe commented Dec 13, 2011

The title says more or less all.
A little sample:

    [TestClass]
    public class LinFuProxyTests
    {
        [TestMethod]
        public void CreateProxyTest()
        {
            var target = new SampleClass();
            var factory = new ProxyFactory();
            var interceptor = new SampleInterceptor(target);

            var proxy = factory.CreateProxy<SampleClass>(interceptor);
        }
    }

    public class SampleClass : ICloneable
    {
        object ICloneable.Clone()
        {
            return new SampleClass();
        }
    }

    public class SampleInterceptor : IInvokeWrapper
    {
        public SampleInterceptor(object target)
        {
            this.Target = target;
        }

        public object Target { get; private set; }

        object IInvokeWrapper.DoInvoke(IInvocationInfo info)
        {
            return null;
        }

        void IBeforeInvoke.BeforeInvoke(IInvocationInfo info)
        {
        }

        void IAfterInvoke.AfterInvoke(IInvocationInfo info, object returnValue)
        {
        }
    }

Result of the unit test is:

Test method LinFuProxyTests.CreateProxyTest threw exception:
System.ArgumentNullException: Value cannot be null.
Parameter name: type
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
at LinFu.Proxy.Interfaces.ProxyFactoryExtensions.CreateProxy(IProxyFactory factory, Type instanceType, IInterceptor interceptor, Type[] baseInterfaces)
at LinFu.Proxy.Interfaces.ProxyFactoryExtensions.CreateProxy(IProxyFactory factory, Type instanceType, IInvokeWrapper wrapper, Type[] baseInterfaces)
at LinFu.Proxy.Interfaces.ProxyFactoryExtensions.CreateProxy(IProxyFactory factory, IInvokeWrapper wrapper, Type[] baseInterfaces)
at LinFuProxyTests.CreateProxyTest() in LinFuProxyTests.cs: line 28

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant