diff options
Diffstat (limited to 'tests/src/reflection/ldtoken/byrefs.il')
-rw-r--r-- | tests/src/reflection/ldtoken/byrefs.il | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/tests/src/reflection/ldtoken/byrefs.il b/tests/src/reflection/ldtoken/byrefs.il new file mode 100644 index 0000000000..d0009b3624 --- /dev/null +++ b/tests/src/reflection/ldtoken/byrefs.il @@ -0,0 +1,88 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +// +// This test makes sure that ByRef types are properly unified by the reflection stack +// and that a type constructed by reflection is equivalent to a type constructed through +// the LDTOKEN instruction. +// + +.assembly extern mscorlib { } +.assembly extern System.Console +{ + .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) + .ver 4:0:0:0 +} +.assembly byrefs +{ + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 ) +} + +.class private auto ansi beforefieldinit Test + extends [mscorlib]System.Object +{ + .method private hidebysig static int32 Main() cil managed + { + .entrypoint + .maxstack 2 + + call bool Test::LdTokenEqualsMakeByRef() + brfalse Failed + + call bool Test::MakeByRefEqualsLdToken() + brfalse Failed + + ldc.i4 100 + ldstr "ByRefs look good" + br.s Done + Failed: + ldc.i4 666 + ldstr "ByRefs are broken" + Done: + call void class [System.Console]System.Console::WriteLine(string) + ret + } + + .method private hidebysig static bool LdTokenEqualsMakeByRef() cil managed + { + .maxstack 2 + + ldtoken valuetype MyType1& + call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) + + ldtoken valuetype MyType1 + call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) + callvirt instance class [mscorlib]System.Type [mscorlib]System.Type::MakeByRefType() + + ceq + + ret + } + + .method private hidebysig static bool MakeByRefEqualsLdToken() cil managed + { + .maxstack 2 + + ldtoken valuetype MyType2 + call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) + callvirt instance class [mscorlib]System.Type [mscorlib]System.Type::MakeByRefType() + + ldtoken valuetype MyType2& + call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) + + ceq + + ret + } +} + +.class private auto ansi beforefieldinit MyType1 + extends [mscorlib]System.ValueType +{ +} + +.class private auto ansi beforefieldinit MyType2 + extends [mscorlib]System.ValueType +{ +} |