Unable to proxy class with generic method
Melchy opened this issue · comments
Following example doesn't work:
public class SexyProxyTest
{
public void GenericMethod<TModel>(TModel model)
{
}
}
public class SexyProxyTests
{
[Test]
public void Test()
{
var proxy = Proxy.CreateProxy<SexyProxyTest>(new SexyProxyTest(), x => new object());
}
}
Sexy proxy throws folowing exception:
System.TypeInitializationException : The type initializer for 'RidgeTests.SexyProxyTest$Proxy' threw an exception.
----> System.BadImageFormatException : An attempt was made to load a program with an incorrect format. (0x8007000B)
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture)
at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(Type type, Object[] args)
at SexyProxy.Proxy`1.CreateProxy(T target, InvocationHandler invocationHandler)
at SexyProxy.Proxy`1.CreateProxy(T target, Func`2 invocationHandler, ProxyPredicate`1 predicate)
at SexyProxy.Proxy.CreateProxy[T](T target, Func`2 invocationHandler, ProxyPredicate`1 predicate)
at RidgeTests.SexyProxyTests.Test() in C:\Users\michal.motycka\Desktop\Personal\Ridge\Tests\RidgeTests\SexyProxyTests.cs:line 39
--BadImageFormatException
at RidgeTests.SexyProxyTest$Proxy..cctor()
``