-
Notifications
You must be signed in to change notification settings - Fork 477
Description
When I update CastleCore from 4.2.1 to 4.3.0 I get an ArgumentException in the MethodEmitter. With the older version there was no exception and the code was working.
I am using Moq with CastleCore. Stacktrace of the error:
System.ArgumentException: Constant does not match the defined type..
at System.Reflection.Emit.TypeBuilder.SetConstantValue(ModuleBuilder module, Int32 tk, Type destType, Object value)
at System.Reflection.Emit.ParameterBuilder.SetConstant(Object defaultValue)
at Castle.DynamicProxy.Generators.Emitters.MethodEmitter.CopyDefaultValueConstant(ParameterInfo from, ParameterBuilder to)
at Castle.DynamicProxy.Generators.Emitters.MethodEmitter.DefineParameters(ParameterInfo[] parameters)
at Castle.DynamicProxy.Generators.Emitters.MethodEmitter..ctor(AbstractTypeEmitter owner, String name, MethodAttributes attributes, MethodInfo methodToUseAsATemplate)
at Castle.DynamicProxy.Generators.Emitters.AbstractTypeEmitter.CreateMethod(String name, MethodAttributes attributes, MethodInfo methodToUseAsATemplate)
at Castle.DynamicProxy.Generators.MethodGenerator.Generate(ClassEmitter class, ProxyGenerationOptions options, INamingScope namingScope)
at Castle.DynamicProxy.Contributors.CompositeTypeContributor.ImplementMethod(MetaMethod method, ClassEmitter class, ProxyGenerationOptions options, OverrideMethodDelegate overrideMethod)
at Castle.DynamicProxy.Contributors.CompositeTypeContributor.Generate(ClassEmitter class, ProxyGenerationOptions options)
at Castle.DynamicProxy.Generators.InterfaceProxyWithoutTargetGenerator.GenerateType(String typeName, Type proxyTargetType, Type[] interfaces, INamingScope namingScope)
at Castle.DynamicProxy.Generators.InterfaceProxyWithTargetGenerator.<>c__DisplayClass6_0.b__0(String n, INamingScope s)
at Castle.DynamicProxy.Generators.BaseProxyGenerator.ObtainProxyType(CacheKey cacheKey, Func3 factory) at Castle.DynamicProxy.Generators.InterfaceProxyWithTargetGenerator.GenerateCode(Type proxyTargetType, Type[] interfaces, ProxyGenerationOptions options) at Castle.DynamicProxy.DefaultProxyBuilder.CreateInterfaceProxyTypeWithoutTarget(Type interfaceToProxy, Type[] additionalInterfacesToProxy, ProxyGenerationOptions options) at Castle.DynamicProxy.ProxyGenerator.CreateInterfaceProxyWithoutTarget(Type interfaceToProxy, Type[] additionalInterfacesToProxy, ProxyGenerationOptions options, IInterceptor[] interceptors) at Moq.CastleProxyFactory.CreateProxy(Type mockType, IInterceptor interceptor, Type[] interfaces, Object[] arguments) in C:\projects\moq4\Source\ProxyFactories\CastleProxyFactory.cs:line 103 at Moq.Mock
1.InitializeInstancePexProtected() in C:\projects\moq4\Source\Mock.Generic.cs:line 295
at Moq.PexProtector.Invoke(Action action) in C:\projects\moq4\Source\PexProtector.cs:line 57
at Moq.Mock1.InitializeInstance() in C:\projects\moq4\Source\Mock.Generic.cs:line 258 at Moq.Mock
1.OnGetObject() in C:\projects\moq4\Source\Mock.Generic.cs:line 320
at Moq.Mock`1.get_Object() in C:\projects\moq4\Source\Mock.Generic.cs:line 234
--> It looks like there was a change in the MethodEmitter.cs of castle core which leads now to this issue:
d75e5b3#diff-d8c107b19efb77444c39c422ff125610