Done: http://216.121.112.228/browse/NH-2726
On May 23, 4:02 pm, "Richard Brown \(gmail\)" <[email protected]> wrote: > I would expect NH to run in .Net 4.0, so I think there should be a JIRA for > this. > > If you could reference this thread in the JIRA that would be great. > > Thanks, > Richard > > > > > > > > -----Original Message----- > From: cremor > Sent: Monday, May 23, 2011 2:23 PM > To: nhibernate-development > Subject: [nhibernate-development] Re: Test "GenericMethodShouldBeProxied" > > failing for x86 but not x64? > > After some hours of debugging I just found out why generic methods > still don't work in my project but work perfectly in the NHibernate > unit tests: It's the .NET runtime version. > > NUnit is using the 2.0 runtime, everything works fine there. But my > project is using the 4.0 runtime and there the call to the generic > method fails. > Luckily this can be reproduced without changing any code. If you > change the app.config files of NUnit (in my case nunit-x86.exe.config > and nunit-agent-x86.exe.config) the way it's shown > herehttp://mint.litemedia.se/2010/11/04/nunit-for-net-framework-4/both > tests of GenericMethodsTests.GenericMethodShouldBeProxied fail. > The exception is "InvalidOperationException : Late bound operations > cannot be performed on types or methods for which > ContainsGenericParameters is true." > > The problem here is that with the assembly generated in the 4.0 > runtime the MethodInfo parameter of the InvocationInfo constructor is > an open generic method (As<T>) instead of a closed one (As<MyClass>) > and therefore the info.TargetMethod.Invoke() call of the Interceptor > fails with the exception I mentioned above. > > While debugging this I compared the generated dynamic assemblies and > there I found a little difference between the assembly generated in > 2.0 and 4.0: > 2.0 code line: > L_0014: ldtoken instance !!0 > [NHibernate.Test]NHibernate.Test.DynamicProxyTests.GenericMethodsTests.GenericMethodShouldBeProxied/ > MyClass::As<!!T0>() > 4.0 code line: > L_0014: ldtoken instance !!0 > [NHibernate.Test]NHibernate.Test.DynamicProxyTests.GenericMethodsTests.GenericMethodShouldBeProxied/ > MyClass::As() > (note the missing generic type parameter at the end) > > So it seems like a fix should be made in > DefaultMethodEmitter.EmitMethodBody(), but sadly all that IL is way to > complex for me, so I stopped the debugging there. > > Should I submit a Jira issue about this although I can't provide a > unit test that fails with the 2.0 runtime? > And any chance someone will look into this? :-) > > On May 16, 5:07 pm, "Richard Brown \(gmail\)" > <[email protected]> wrote: > > Done. > > > Sorry I hadn't realised the correlation between the JIRA ticket and the > > fix. > > I should really pay more attention. > > > Thanks for letting us know. > > > Cheers. > > > -----Original Message----- > > From: cremor > > Sent: Monday, May 16, 2011 4:02 PM > > To: nhibernate-development > > Subject: [nhibernate-development] Re: Test "GenericMethodShouldBeProxied" > > > failing for x86 but not x64? > > > Seems like this was fixed with r5816, thanks! > > I think the issue should be changed to "fixed in 3.2.0.Beta1" so it > > appears in the changelog. > > > On May 11, 8:26 am, cremor <[email protected]> wrote: > > > This message is about that issue:http://216.121.112.228/browse/NH-2698 > > > > I think I just found out why the test didn't fail for Fabio. It > > > succeeds if I start it with nunit.exe, but it fails if I start it with > > > nunit-x86.exe (using the latest trunk right now). The exception is > > > "System.Security.VerificationException : Method > > > NHibernate.Test.DynamicProxyTests.GenericMethodsTests.GenericMethodShouldBeProxied > > > +MyClass.As: type argument 'T0' violates the constraint of type > > > parameter 'TRequestedType'." > > > > Can someone reproduce this? If yes, please reopen the issue :-) > > > > And if someone has an explanation for this different behaviour of > > > the .NET runtimes it would be great if he could explain it for me.
