Hey,

On Thu, Nov 25, 2010 at 8:43 AM, Fabian Schmied
<[email protected]> wrote:
>>> 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.)

Actually, I'd use the
GetMethodFromHandle(RuntimeMethodHandle,Type[],Type[]) overload which
would close the method in the specified generic context. It can deal
with methodspecs tokens as well as memberref and method.

Jb

-- 
--
mono-cecil

Reply via email to