Looks like a CLR issue to me, because the same thing happens if you write the IL by hand and use ilasm. That is, given a generic class G
and a nongeneric class N
, each with a generic method M
, then trying to get the generic method definition from the non-generic class works:
ldtoken method void class N::M<[1]>()
ldtoken class N<!T>
call class [mscorlib]System.Reflection.MethodBase [mscorlib]
System.Reflection.MethodBase::GetMethodFromHandle(
valuetype [mscorlib]System.RuntimeMethodHandle,
valuetype [mscorlib]System.RuntimeTypeHandle)
castclass [mscorlib]System.Reflection.MethodInfo
ret
but the MethodInfo
returned from the generic class is not a generic method definition (but it almost is; it's D.MakeGenericMethod(D.GetGenericArguments())
where D
is the method definition you want):
ldtoken method void class G`1<!T>::M<[1]>()
ldtoken class G`1<!T>
call class [mscorlib]System.Reflection.MethodBase [mscorlib]
System.Reflection.MethodBase::GetMethodFromHandle(
valuetype [mscorlib]System.RuntimeMethodHandle,
valuetype [mscorlib]System.RuntimeTypeHandle)
castclass [mscorlib]System.Reflection.MethodInfo
ret