@@ -27,7 +27,7 @@ public event EventHandler Event { add { } remove { } }
2727 new object [ ] { typeof ( Test < > ) . GetGenericArguments ( ) [ 0 ] . GetTypeInfo ( ) , 0x2A }
2828 } ;
2929
30- [ Theory ]
30+ [ ConditionalTheory ( nameof ( GetMetadataTokenSupported ) ) ]
3131 [ MemberData ( nameof ( MembersWithExpectedTableIndex ) ) ]
3232 public void SuccessImpliesNonNilWithCorrectTable ( MemberInfo member , int expectedTableIndex )
3333 {
@@ -37,7 +37,7 @@ public void SuccessImpliesNonNilWithCorrectTable(MemberInfo member, int expected
3737 Assert . NotEqual ( 0 , TableIndex ( token ) ) ;
3838 }
3939
40- [ Fact ]
40+ [ ConditionalFact ( nameof ( GetMetadataTokenSupported ) , nameof ( IsReflectionEmitSupported ) ) ]
4141 public static void UnbakedReflectionEmitType_HasNoMetadataToken ( )
4242 {
4343 AssemblyBuilder assembly = AssemblyBuilder . DefineDynamicAssembly ( new AssemblyName ( "dynamic" ) , AssemblyBuilderAccess . Run ) ;
@@ -48,6 +48,20 @@ public static void UnbakedReflectionEmitType_HasNoMetadataToken()
4848 Assert . Throws < InvalidOperationException > ( ( ) => method . GetMetadataToken ( ) ) ;
4949 }
5050
51+ public static bool GetMetadataTokenSupported
52+ {
53+ get
54+ {
55+ if ( ! PlatformDetection . IsNetNative )
56+ return true ;
57+
58+ // Expected false but in case .Net Native ever changes its mind...
59+ return typeof ( MetadataTokenTests ) . HasMetadataToken ( ) ;
60+ }
61+ }
62+
63+ public static bool IsReflectionEmitSupported => PlatformDetection . IsReflectionEmitSupported ;
64+
5165 private static int TableIndex ( int token ) => token >> 24 ;
5266 private static int RowIndex ( int token ) => token & 0x00FFFFFF ;
5367 }
0 commit comments