SelectCallMethods, targeting generic methods issue...

Jan 18, 2013 at 3:12 AM

Hi,

First of all, thanks for your awesome library.

I have encountered this issue, and it took me a few hours to figure out that it is SheepAspect enhanced dll that was causing me trouble.  I hope you can have a look...

Issue:

I was trying to intercept and log everything when a dll calls RestSharp.Execute<T>(RestRequest).

I have the SelectCallMethods as follow:

[SelectCallMethods( "Method:(Name:'Execute*'& InType:Name:'*RestClient') & FromMethod:(Public & InType:Name:'Api')" )]

 

Exceptions:

After I compiled the Api class, the other project which referenced this dll throw:

8007000B BadImageFormatException

I inspected the dll with ILSpy, it showed this exception when analyzing it:

A method contains RestClient.Execute<T>(RestResponse)
System.InvalidCastException: Unable to cast object of type 'Mono.Cecil.MethodReference' to type 'Mono.Cecil.GenericInstanceMethod'.

 

Tried this:

I tried to use the non-generic version, RestClient.Execute(RestRequest), then the weaved dll was fine...

 

Hope you can help.  Thanks!

Coordinator
Jan 24, 2013 at 9:30 PM

Hi awyl,

Thanks for reporting the error. I will look into this and get back to you.

Cheers

Hendry

Feb 18, 2013 at 6:07 AM
Hi hendryluk,

Would you able to replicate the problem?

Thanks!

awyl
Feb 27, 2013 at 4:05 PM
Hi,

I would like to help debugging. However, when I try to run the unit tests, all of them failed with this kind of mysterious error... The tests do not even reach the test code...

e.g.,

Test Name: AlwaysUseDifferentInstances
Test FullName: [0-1024]SheepAspect.UnitTest.LifecycleTests.TransientTest.AlwaysUseDifferentInstances
Test Source: c:\Downloads\sheepaspect-82877\SheepAspect.UnitTest\LifecycleTests\TransientTest.cs : line 20
Test Outcome: Failed
Test Duration: 0:00:00.009

Result Message: System.NullReferenceException : Object reference not set to an instance of an object.
Result StackTrace:
at NUnit.Core.TestAction..ctor(Object action)
at NUnit.Core.ActionsHelper.GetActionsFromAttributeProvider(ICustomAttributeProvider attributeProvider)
at NUnit.Core.TestMethod.RunTestInContext()


Any idea how to setup the project properly to run correctly?

I am on VS2012.

Thanks.