@@ -13,29 +13,6 @@ namespace Microsoft.VisualBasic.Tests
13
13
{
14
14
public class ConversionsTests
15
15
{
16
- private static bool ? s_reflectionEmitSupported = null ;
17
-
18
- public static bool ReflectionEmitSupported
19
- {
20
- get
21
- {
22
- if ( s_reflectionEmitSupported == null )
23
- {
24
- try
25
- {
26
- object o = FloatEnum ;
27
- s_reflectionEmitSupported = true ;
28
- }
29
- catch ( PlatformNotSupportedException )
30
- {
31
- s_reflectionEmitSupported = false ;
32
- }
33
- }
34
-
35
- return s_reflectionEmitSupported . Value ;
36
- }
37
- }
38
-
39
16
public static IEnumerable < object [ ] > InvalidString_TestData ( )
40
17
{
41
18
yield return new object [ ] { "" } ;
@@ -49,7 +26,7 @@ public static IEnumerable<object[]> InvalidString_TestData()
49
26
50
27
public static IEnumerable < object [ ] > InvalidBool_TestData ( )
51
28
{
52
- if ( ReflectionEmitSupported )
29
+ if ( PlatformDetection . IsReflectionEmitSupported && PlatformDetection . IsRareEnumsSupported )
53
30
{
54
31
yield return new object [ ] { FloatEnum } ;
55
32
yield return new object [ ] { DoubleEnum } ;
@@ -65,7 +42,7 @@ public static IEnumerable<object[]> InvalidNumberObject_TestData()
65
42
yield return new object [ ] { char . MaxValue } ;
66
43
yield return new object [ ] { new DateTime ( 10 ) } ;
67
44
yield return new object [ ] { new object ( ) } ;
68
- if ( ReflectionEmitSupported )
45
+ if ( PlatformDetection . IsReflectionEmitSupported && PlatformDetection . IsRareEnumsSupported )
69
46
{
70
47
yield return new object [ ] { CharEnum } ;
71
48
}
@@ -182,7 +159,7 @@ public static IEnumerable<object[]> ToByte_Object_TestData()
182
159
// bool.
183
160
yield return new object [ ] { true , byte . MaxValue } ;
184
161
yield return new object [ ] { false , byte . MinValue } ;
185
- if ( ReflectionEmitSupported )
162
+ if ( PlatformDetection . IsReflectionEmitSupported && PlatformDetection . IsRareEnumsSupported )
186
163
{
187
164
yield return new object [ ] { BoolEnum , byte . MinValue } ;
188
165
}
@@ -363,7 +340,7 @@ public static IEnumerable<object[]> ToSByte_Object_TestData()
363
340
// bool.
364
341
yield return new object [ ] { true , ( sbyte ) ( - 1 ) } ;
365
342
yield return new object [ ] { false , ( sbyte ) 0 } ;
366
- if ( ReflectionEmitSupported )
343
+ if ( PlatformDetection . IsReflectionEmitSupported && PlatformDetection . IsRareEnumsSupported )
367
344
{
368
345
yield return new object [ ] { BoolEnum , ( sbyte ) 0 } ;
369
346
}
@@ -537,7 +514,7 @@ public static IEnumerable<object[]> ToUShort_Object_TestData()
537
514
// bool.
538
515
yield return new object [ ] { true , ushort . MaxValue } ;
539
516
yield return new object [ ] { false , ushort . MinValue } ;
540
- if ( ReflectionEmitSupported )
517
+ if ( PlatformDetection . IsReflectionEmitSupported && PlatformDetection . IsRareEnumsSupported )
541
518
{
542
519
yield return new object [ ] { BoolEnum , ushort . MinValue } ;
543
520
}
@@ -721,7 +698,7 @@ public static IEnumerable<object[]> ToShort_Object_TestData()
721
698
// bool.
722
699
yield return new object [ ] { true , ( short ) ( - 1 ) } ;
723
700
yield return new object [ ] { false , ( short ) 0 } ;
724
- if ( ReflectionEmitSupported )
701
+ if ( PlatformDetection . IsReflectionEmitSupported && PlatformDetection . IsRareEnumsSupported )
725
702
{
726
703
yield return new object [ ] { BoolEnum , ( short ) 0 } ;
727
704
}
@@ -899,7 +876,7 @@ public static IEnumerable<object[]> ToUInteger_Object_TestData()
899
876
// bool.
900
877
yield return new object [ ] { true , uint . MaxValue } ;
901
878
yield return new object [ ] { false , uint . MinValue } ;
902
- if ( ReflectionEmitSupported )
879
+ if ( PlatformDetection . IsReflectionEmitSupported && PlatformDetection . IsRareEnumsSupported )
903
880
{
904
881
yield return new object [ ] { BoolEnum , uint . MinValue } ;
905
882
}
@@ -1089,7 +1066,7 @@ public static IEnumerable<object[]> ToInteger_Object_TestData()
1089
1066
// bool.
1090
1067
yield return new object [ ] { true , - 1 } ;
1091
1068
yield return new object [ ] { false , 0 } ;
1092
- if ( ReflectionEmitSupported )
1069
+ if ( PlatformDetection . IsReflectionEmitSupported && PlatformDetection . IsRareEnumsSupported )
1093
1070
{
1094
1071
yield return new object [ ] { BoolEnum , 0 } ;
1095
1072
}
@@ -1275,7 +1252,7 @@ public static IEnumerable<object[]> ToULong_Object_TestData()
1275
1252
// bool.
1276
1253
yield return new object [ ] { true , ulong . MaxValue } ;
1277
1254
yield return new object [ ] { false , ulong . MinValue } ;
1278
- if ( ReflectionEmitSupported )
1255
+ if ( PlatformDetection . IsReflectionEmitSupported && PlatformDetection . IsRareEnumsSupported )
1279
1256
{
1280
1257
yield return new object [ ] { BoolEnum , ulong . MinValue } ;
1281
1258
}
@@ -1503,7 +1480,7 @@ public static IEnumerable<object[]> ToLong_Object_TestData()
1503
1480
// bool.
1504
1481
yield return new object [ ] { true , ( long ) ( - 1 ) } ;
1505
1482
yield return new object [ ] { false , ( long ) 0 } ;
1506
- if ( ReflectionEmitSupported )
1483
+ if ( PlatformDetection . IsReflectionEmitSupported && PlatformDetection . IsRareEnumsSupported )
1507
1484
{
1508
1485
yield return new object [ ] { BoolEnum , ( long ) 0 } ;
1509
1486
}
@@ -1729,7 +1706,7 @@ public static IEnumerable<object[]> ToSingle_Object_TestData()
1729
1706
// bool.
1730
1707
yield return new object [ ] { true , ( float ) ( - 1 ) } ;
1731
1708
yield return new object [ ] { false , ( float ) 0 } ;
1732
- if ( ReflectionEmitSupported )
1709
+ if ( PlatformDetection . IsReflectionEmitSupported && PlatformDetection . IsRareEnumsSupported )
1733
1710
{
1734
1711
yield return new object [ ] { BoolEnum , ( float ) 0 } ;
1735
1712
}
@@ -1922,7 +1899,7 @@ public static IEnumerable<object[]> ToDouble_Object_TestData()
1922
1899
// bool.
1923
1900
yield return new object [ ] { true , ( double ) ( - 1 ) } ;
1924
1901
yield return new object [ ] { false , ( double ) 0 } ;
1925
- if ( ReflectionEmitSupported )
1902
+ if ( PlatformDetection . IsReflectionEmitSupported && PlatformDetection . IsRareEnumsSupported )
1926
1903
{
1927
1904
yield return new object [ ] { BoolEnum , ( double ) 0 } ;
1928
1905
}
@@ -2118,7 +2095,7 @@ public static IEnumerable<object[]> ToDecimal_Object_TestData()
2118
2095
// bool.
2119
2096
yield return new object [ ] { true , ( decimal ) ( - 1 ) } ;
2120
2097
yield return new object [ ] { false , ( decimal ) 0 } ;
2121
- if ( ReflectionEmitSupported )
2098
+ if ( PlatformDetection . IsReflectionEmitSupported && PlatformDetection . IsRareEnumsSupported )
2122
2099
{
2123
2100
yield return new object [ ] { BoolEnum , ( decimal ) 0 } ;
2124
2101
}
@@ -2344,7 +2321,7 @@ public static IEnumerable<object[]> ToBoolean_Object_TestData()
2344
2321
// bool.
2345
2322
yield return new object [ ] { true , true } ;
2346
2323
yield return new object [ ] { false , false } ;
2347
- if ( ReflectionEmitSupported )
2324
+ if ( PlatformDetection . IsReflectionEmitSupported && PlatformDetection . IsRareEnumsSupported )
2348
2325
{
2349
2326
yield return new object [ ] { BoolEnum , false } ;
2350
2327
}
@@ -2659,7 +2636,7 @@ public static IEnumerable<object[]> ToString_IConvertible_TestData()
2659
2636
// bool.
2660
2637
yield return new object [ ] { true , "True" } ;
2661
2638
yield return new object [ ] { false , "False" } ;
2662
- if ( ReflectionEmitSupported )
2639
+ if ( PlatformDetection . IsReflectionEmitSupported && PlatformDetection . IsRareEnumsSupported )
2663
2640
{
2664
2641
yield return new object [ ] { BoolEnum , "False" } ;
2665
2642
}
0 commit comments