philiplaureano/LinFu — Issue #20: Proxy creation fails for objects having explicitly implemented interfaces
Author: GhoSe
Created: 2011-12-13 15:44:48+00:00
State: open

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(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