From 3977fe956c1a759075b7f64d374d1d857c58c30b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michal=20Strehovsk=C3=BD?= Date: Thu, 30 Mar 2017 19:00:24 -0700 Subject: [PATCH] Add test coverage for ldtoken of open generic methods (dotnet/coreclr#10592) Commit migrated from https://github.com/dotnet/coreclr/commit/216d972cd87e1dab8e45862e64cc1b53abac3f1b --- .../tests/src/reflection/ldtoken/ldtokenmember.il | 126 ++++++++++++++++++++- 1 file changed, 125 insertions(+), 1 deletion(-) diff --git a/src/coreclr/tests/src/reflection/ldtoken/ldtokenmember.il b/src/coreclr/tests/src/reflection/ldtoken/ldtokenmember.il index cc098ae..f67d73c 100644 --- a/src/coreclr/tests/src/reflection/ldtoken/ldtokenmember.il +++ b/src/coreclr/tests/src/reflection/ldtoken/ldtokenmember.il @@ -19,7 +19,9 @@ class [mscorlib]System.Reflection.MethodBase staticInt32Method, class [mscorlib]System.Reflection.MethodBase staticMethodT, class [mscorlib]System.Reflection.MethodBase staticMethodU, - class [mscorlib]System.Reflection.FieldInfo staticFieldT) + class [mscorlib]System.Reflection.FieldInfo staticFieldT, + class [mscorlib]System.Reflection.MethodBase weirdoGenericMethod, + class [mscorlib]System.Reflection.MethodBase otherWeirdoGenericMethod) // // Type nonGenericHolderType = typeof(NonGenericHolder) @@ -175,6 +177,118 @@ MethodGenericOwningTypeOK: ret FieldGenericOwningTypeOK: + // + // if (!infoof(NonGenericHolder.GenericMethod<>).IsGenericMethodDefinition) + // return 8; + // + ldtoken method void NonGenericHolder::GenericMethod<[1]>() + call class [mscorlib]System.Reflection.MethodBase + [mscorlib]System.Reflection.MethodBase::GetMethodFromHandle( + valuetype [mscorlib]System.RuntimeMethodHandle) + callvirt instance bool [mscorlib]System.Reflection.MethodBase::get_IsGenericMethodDefinition() + brtrue StaticGenericMethodIsDefinition + ldc.i4 8 + ret +StaticGenericMethodIsDefinition: + + // + // if (infoof(NonGenericHolder.GenericMethod).IsGenericMethodDefinition) + // return 9; + // + ldtoken method void NonGenericHolder::GenericMethod() + call class [mscorlib]System.Reflection.MethodBase + [mscorlib]System.Reflection.MethodBase::GetMethodFromHandle( + valuetype [mscorlib]System.RuntimeMethodHandle) + callvirt instance bool [mscorlib]System.Reflection.MethodBase::get_IsGenericMethodDefinition() + brfalse StaticGenericMethodIsInstantiated + ldc.i4 9 + ret +StaticGenericMethodIsInstantiated: + + // + // if (!infoof(GenericHolder<,>.GenericMethod<>).IsGenericMethodDefinition) + // return 10; + // + ldtoken method void GenericHolder`2::GenericMethod<[1]>(!1, !!0) + ldtoken GenericHolder`2 + call class [mscorlib]System.Reflection.MethodBase + [mscorlib]System.Reflection.MethodBase::GetMethodFromHandle( + valuetype [mscorlib]System.RuntimeMethodHandle, + valuetype [mscorlib]System.RuntimeTypeHandle) + callvirt instance bool [mscorlib]System.Reflection.MethodBase::get_IsGenericMethodDefinition() + brtrue StaticGenericMethodOnGenericTypeIsDefinition + ldc.i4 10 + ret +StaticGenericMethodOnGenericTypeIsDefinition: + + // + // MethodBase weirdoGenericMethod = infoof(GenericHolder<,>.GenericMethod); + // if (weirdoGenericMethod.IsGenericMethodDefinition) + // return 11; + // + ldtoken method void GenericHolder`2::GenericMethod(!1, !!0) + ldtoken GenericHolder`2 + call class [mscorlib]System.Reflection.MethodBase + [mscorlib]System.Reflection.MethodBase::GetMethodFromHandle( + valuetype [mscorlib]System.RuntimeMethodHandle, + valuetype [mscorlib]System.RuntimeTypeHandle) + stloc weirdoGenericMethod + ldloc weirdoGenericMethod + callvirt instance bool [mscorlib]System.Reflection.MethodBase::get_IsGenericMethodDefinition() + brfalse WeirdoGenericMethodIsNotDefinition + ldc.i4 11 + ret +WeirdoGenericMethodIsNotDefinition: + + // + // if (weirdoGenericMethod.DeclaringType != typeof(GenericHolder<,>)) + // return 12; + // + ldloc weirdoGenericMethod + callvirt instance class [mscorlib]System.Type [mscorlib]System.Reflection.MethodBase::get_DeclaringType() + ldtoken GenericHolder`2 + call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle( + valuetype [mscorlib]System.RuntimeTypeHandle) + ceq + brtrue WeirdoGenericMethodOwningTypeOK + ldc.i4 12 + ret +WeirdoGenericMethodOwningTypeOK: + + // + // MethodBase otherWeirdoGenericMethod = infoof(GenericHolder.GenericMethod<>); + // if (!otherWeirdoGenericMethod.IsGenericMethodDefinition) + // return 13; + // + ldtoken method void class GenericHolder`2::GenericMethod<[1]>(!1, !!0) + ldtoken class GenericHolder`2 + call class [mscorlib]System.Reflection.MethodBase + [mscorlib]System.Reflection.MethodBase::GetMethodFromHandle( + valuetype [mscorlib]System.RuntimeMethodHandle, + valuetype [mscorlib]System.RuntimeTypeHandle) + stloc otherWeirdoGenericMethod + ldloc otherWeirdoGenericMethod + callvirt instance bool [mscorlib]System.Reflection.MethodBase::get_IsGenericMethodDefinition() + brtrue OtherWeirdoGenericMethodIsDefinition + ldc.i4 13 + ret +OtherWeirdoGenericMethodIsDefinition: + + // + // if (otherWeirdoGenericMethod.DeclaringType != typeof(GenericHolder)) + // return 14; + // + ldloc otherWeirdoGenericMethod + callvirt instance class [mscorlib]System.Type [mscorlib]System.Reflection.MethodBase::get_DeclaringType() + ldtoken class GenericHolder`2 + call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle( + valuetype [mscorlib]System.RuntimeTypeHandle) + ceq + brtrue OtherWeirdoGenericMethodOwningTypeOK + ldc.i4 14 + ret +OtherWeirdoGenericMethodOwningTypeOK: + ldc.i4 100 ret } @@ -195,6 +309,11 @@ FieldGenericOwningTypeOK: ldc.i4.0 ret } + + .method public hidebysig static void GenericMethod() + { + ret + } } .class private auto ansi beforefieldinit GenericHolder`2 @@ -212,6 +331,11 @@ FieldGenericOwningTypeOK: ret } + .method public hidebysig static void GenericMethod(!1 x, !!0 y) + { + ret + } + .method public hidebysig static class [mscorlib]System.Reflection.FieldInfo GetInfoOfFieldT() { ldtoken field !0 class GenericHolder`2::StaticFieldT -- 2.7.4