>> 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.

Yes, you're right, this works. I was under the impression that this
was still buggy
(<https://connect.microsoft.com/VisualStudio/feedback/details/269853/loading-methodbase-for-closed-generic-method-in-il>),
but it has been fixed since .NET 2.0 SP 2 (I think). (Before that
service pack, that method did not work correctly.)

Fabian

-- 
--
mono-cecil

Reply via email to