Hi Ohad,
Still no go :(
When I try it with the test case that passes of course, but in my real program I'm now getting a different exception. Even before I tried to add back the DefaultBehavior.CheckArguements() I decided to run the test again and found that it's now failing. It was passing before.
Here's the exception:
Test method xxxx.ReadTest threw exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: GenericArguments[0], 'xxxx.ClassA', on 'xxxx.ClassB`1[T]' violates the constraint of type 'T'. ---> System.TypeLoadException: GenericArguments[0], 'xxxx.ClassA', on 'xxxx.ClassB`1[T]' violates the constraint of type parameter 'T'..
and this is the stack trace:
at System.RuntimeTypeHandle._Instantiate(RuntimeTypeHandle[] inst)
at System.RuntimeTypeHandle.Instantiate(RuntimeTypeHandle[] inst)
at System.RuntimeType.MakeGenericType(Type[] instantiation)
--- End of inner exception stack trace ---
at System.RuntimeType.ValidateGenericArguments(MemberInfo definition, Type[] genericArguments, Exception e)
at System.RuntimeType.MakeGenericType(Type[] instantiation)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at p.a(Type A_0, Type[] A_1)
at TypeMock.RecorderManager.a(Object A_0, Object A_1, MethodInfo A_2)
at TypeMock.RecorderManager.a(String A_0, MethodBase A_1, MethodInfo A_2, Boolean A_3, Object A_4, Object A_5)
at TypeMock.RecorderManager.a(String A_0, String A_1, Object A_2, Object[] A_3, MethodBase A_4, Object A_5, StackTrace A_6)
at TypeMock.MockManager.a(String A_0, String A_1, Object A_2, Object A_3, Object[] A_4)
at TypeMock.InternalMockManager.getReturn(Object that, String typeName, String methodName, Object methodParameters, Object p1)
at xxxx.ClassC`2.Selection(IEnumerable elements)
at xxxx.ReadTest()
In the above, ClassC.Selection() returns the ClassB<T> that the exception is complaining about. However, the T in ClassB<T> is not the ClassA that the exception mentions. Also, T has a constraint that it inherits from a base class and a constraint that it be new-able like this:
where T : BaseClass, new()
Unfortunately I don't have time now to narrow this down to a test case, but if you'd like me to send you some other log files I'd be happy to do that.
Thanks,
Tibor