>> You can make it much more simple. Instead of calling
>> MethodBase.GetCurrentMethod, use Cecil to inject a:
>>
>> ldtoken methodDef
>> call MethodBase::GetMethodFromHandle

But be careful with generics: On the Microsoft CLR, generic methods
closed with reference types share the same method handle; I think
you'll always get back the generic method definition for those via
GetMethodFromHandle. You need to call MakeGenericMethod on the result
to close the generic method if you need that. The behavior with
generic methods closed with value types might differ, as they have
their own handles. This is also an implementation detail that might
vary over time (or with Mono), I think, so you shouldn't rely on it,
but cope with it. (If required.)

(If generic instantiations are important to you, also test your code
using methods on generic types instantiated with reference types and
value types.)

Fabian

-- 
--
mono-cecil

Reply via email to