Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ private static bool GetLinqExpressionsBuiltWithIsInterpretingOnly()

public static bool IsPreciseGcSupported => !IsMonoRuntime;

public static bool IsRareEnumsSupported => !IsNativeAot;

public static bool IsNotIntMaxValueArrayIndexSupported => s_largeArrayIsNotSupported.Value;

public static bool IsAssemblyLoadingSupported => !IsNativeAot;
Expand Down
53 changes: 15 additions & 38 deletions src/libraries/Microsoft.VisualBasic.Core/tests/ConversionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,6 @@ namespace Microsoft.VisualBasic.Tests
{
public class ConversionsTests
{
private static bool? s_reflectionEmitSupported = null;

public static bool ReflectionEmitSupported
{
get
{
if (s_reflectionEmitSupported == null)
{
try
{
object o = FloatEnum;
s_reflectionEmitSupported = true;
}
catch (PlatformNotSupportedException)
{
s_reflectionEmitSupported = false;
}
}

return s_reflectionEmitSupported.Value;
}
}

public static IEnumerable<object[]> InvalidString_TestData()
{
yield return new object[] { "" };
Expand All @@ -49,7 +26,7 @@ public static IEnumerable<object[]> InvalidString_TestData()

public static IEnumerable<object[]> InvalidBool_TestData()
{
if (ReflectionEmitSupported)
if (PlatformDetection.IsReflectionEmitSupported && PlatformDetection.IsRareEnumsSupported)
{
yield return new object[] { FloatEnum };
yield return new object[] { DoubleEnum };
Expand All @@ -65,7 +42,7 @@ public static IEnumerable<object[]> InvalidNumberObject_TestData()
yield return new object[] { char.MaxValue };
yield return new object[] { new DateTime(10) };
yield return new object[] { new object() };
if (ReflectionEmitSupported)
if (PlatformDetection.IsReflectionEmitSupported && PlatformDetection.IsRareEnumsSupported)
{
yield return new object[] { CharEnum };
}
Expand Down Expand Up @@ -182,7 +159,7 @@ public static IEnumerable<object[]> ToByte_Object_TestData()
// bool.
yield return new object[] { true, byte.MaxValue };
yield return new object[] { false, byte.MinValue };
if (ReflectionEmitSupported)
if (PlatformDetection.IsReflectionEmitSupported && PlatformDetection.IsRareEnumsSupported)
{
yield return new object[] { BoolEnum, byte.MinValue };
}
Expand Down Expand Up @@ -363,7 +340,7 @@ public static IEnumerable<object[]> ToSByte_Object_TestData()
// bool.
yield return new object[] { true, (sbyte)(-1) };
yield return new object[] { false, (sbyte)0 };
if (ReflectionEmitSupported)
if (PlatformDetection.IsReflectionEmitSupported && PlatformDetection.IsRareEnumsSupported)
{
yield return new object[] { BoolEnum, (sbyte)0 };
}
Expand Down Expand Up @@ -537,7 +514,7 @@ public static IEnumerable<object[]> ToUShort_Object_TestData()
// bool.
yield return new object[] { true, ushort.MaxValue };
yield return new object[] { false, ushort.MinValue };
if (ReflectionEmitSupported)
if (PlatformDetection.IsReflectionEmitSupported && PlatformDetection.IsRareEnumsSupported)
{
yield return new object[] { BoolEnum, ushort.MinValue };
}
Expand Down Expand Up @@ -721,7 +698,7 @@ public static IEnumerable<object[]> ToShort_Object_TestData()
// bool.
yield return new object[] { true, (short)(-1) };
yield return new object[] { false, (short)0 };
if (ReflectionEmitSupported)
if (PlatformDetection.IsReflectionEmitSupported && PlatformDetection.IsRareEnumsSupported)
{
yield return new object[] { BoolEnum, (short)0 };
}
Expand Down Expand Up @@ -899,7 +876,7 @@ public static IEnumerable<object[]> ToUInteger_Object_TestData()
// bool.
yield return new object[] { true, uint.MaxValue };
yield return new object[] { false, uint.MinValue };
if (ReflectionEmitSupported)
if (PlatformDetection.IsReflectionEmitSupported && PlatformDetection.IsRareEnumsSupported)
{
yield return new object[] { BoolEnum, uint.MinValue };
}
Expand Down Expand Up @@ -1089,7 +1066,7 @@ public static IEnumerable<object[]> ToInteger_Object_TestData()
// bool.
yield return new object[] { true, -1 };
yield return new object[] { false, 0 };
if (ReflectionEmitSupported)
if (PlatformDetection.IsReflectionEmitSupported && PlatformDetection.IsRareEnumsSupported)
{
yield return new object[] { BoolEnum, 0 };
}
Expand Down Expand Up @@ -1275,7 +1252,7 @@ public static IEnumerable<object[]> ToULong_Object_TestData()
// bool.
yield return new object[] { true, ulong.MaxValue };
yield return new object[] { false, ulong.MinValue };
if (ReflectionEmitSupported)
if (PlatformDetection.IsReflectionEmitSupported && PlatformDetection.IsRareEnumsSupported)
{
yield return new object[] { BoolEnum, ulong.MinValue };
}
Expand Down Expand Up @@ -1503,7 +1480,7 @@ public static IEnumerable<object[]> ToLong_Object_TestData()
// bool.
yield return new object[] { true, (long)(-1) };
yield return new object[] { false, (long)0 };
if (ReflectionEmitSupported)
if (PlatformDetection.IsReflectionEmitSupported && PlatformDetection.IsRareEnumsSupported)
{
yield return new object[] { BoolEnum, (long)0 };
}
Expand Down Expand Up @@ -1729,7 +1706,7 @@ public static IEnumerable<object[]> ToSingle_Object_TestData()
// bool.
yield return new object[] { true, (float)(-1) };
yield return new object[] { false, (float)0 };
if (ReflectionEmitSupported)
if (PlatformDetection.IsReflectionEmitSupported && PlatformDetection.IsRareEnumsSupported)
{
yield return new object[] { BoolEnum, (float)0 };
}
Expand Down Expand Up @@ -1922,7 +1899,7 @@ public static IEnumerable<object[]> ToDouble_Object_TestData()
// bool.
yield return new object[] { true, (double)(-1) };
yield return new object[] { false, (double)0 };
if (ReflectionEmitSupported)
if (PlatformDetection.IsReflectionEmitSupported && PlatformDetection.IsRareEnumsSupported)
{
yield return new object[] { BoolEnum, (double)0 };
}
Expand Down Expand Up @@ -2118,7 +2095,7 @@ public static IEnumerable<object[]> ToDecimal_Object_TestData()
// bool.
yield return new object[] { true, (decimal)(-1) };
yield return new object[] { false, (decimal)0 };
if (ReflectionEmitSupported)
if (PlatformDetection.IsReflectionEmitSupported && PlatformDetection.IsRareEnumsSupported)
{
yield return new object[] { BoolEnum, (decimal)0 };
}
Expand Down Expand Up @@ -2344,7 +2321,7 @@ public static IEnumerable<object[]> ToBoolean_Object_TestData()
// bool.
yield return new object[] { true, true };
yield return new object[] { false, false };
if (ReflectionEmitSupported)
if (PlatformDetection.IsReflectionEmitSupported && PlatformDetection.IsRareEnumsSupported)
{
yield return new object[] { BoolEnum, false };
}
Expand Down Expand Up @@ -2659,7 +2636,7 @@ public static IEnumerable<object[]> ToString_IConvertible_TestData()
// bool.
yield return new object[] { true, "True" };
yield return new object[] { false, "False" };
if (ReflectionEmitSupported)
if (PlatformDetection.IsReflectionEmitSupported && PlatformDetection.IsRareEnumsSupported)
{
yield return new object[] { BoolEnum, "False" };
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2373,7 +2373,7 @@ public static IEnumerable<Type> EnumerableTypes()
yield return typeof(Int64Enum);
yield return typeof(UInt64Enum);

if (PlatformDetection.IsReflectionEmitSupported)
if (PlatformDetection.IsReflectionEmitSupported && PlatformDetection.IsRareEnumsSupported)
{
yield return NonCSharpTypes.CharEnumType;
yield return NonCSharpTypes.BoolEnumType;
Expand Down
Loading