From 62e231656a8fc6aa347d52e8812c4eb9e558b469 Mon Sep 17 00:00:00 2001 From: Steven He Date: Mon, 3 Feb 2025 01:06:36 +0900 Subject: [PATCH 1/9] More conv opcodes --- .../Compiler/TypePreinit.cs | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs index a5851aba72f2fe..a1d426484b198e 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs @@ -835,6 +835,8 @@ private Status TryScanMethod(MethodIL methodIL, Value[] parameters, Stack Date: Thu, 6 Feb 2025 07:02:53 +0900 Subject: [PATCH 2/9] Adding tests, fixing float and nint conversions --- .../Compiler/TypePreinit.cs | 10 +- .../Preinitialization/Preinitialization.cs | 231 ++++++++++++++++++ 2 files changed, 238 insertions(+), 3 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs index a1d426484b198e..fd05a5efc2be0f 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs @@ -877,7 +877,7 @@ private Status TryScanMethod(MethodIL methodIL, Value[] parameters, Stack -42; + private static long GetLong() => -42; + private static float GetFloat() => -42; + private static double GetDouble() => -42; + private static nint GetNativeInt() => -42; + + class IntConversions + { + internal static byte s_byte; + internal static sbyte s_sbyte; + internal static short s_short; + internal static ushort s_ushort; + internal static uint s_uint; + internal static long s_long; + internal static ulong s_ulong; + internal static float s_float; + internal static double s_double; + internal static nint s_nint; + internal static nuint s_nuint; + + static IntConversions() + { + s_byte = unchecked((byte)GetInt()); + s_sbyte = unchecked((sbyte)GetInt()); + s_short = unchecked((short)GetInt()); + s_ushort = unchecked((ushort)GetInt()); + s_uint = unchecked((uint)GetInt()); + s_long = GetInt(); + s_ulong = unchecked((ulong)GetInt()); + s_float = unchecked((float)GetInt()); + s_double = unchecked(GetInt()); + s_nint = GetInt(); + s_nuint = unchecked((nuint)GetInt()); + } + } + + class LongConversions + { + internal static byte s_byte; + internal static sbyte s_sbyte; + internal static short s_short; + internal static ushort s_ushort; + internal static int s_int; + internal static uint s_uint; + internal static ulong s_ulong; + internal static float s_float; + internal static double s_double; + internal static nint s_nint; + internal static nuint s_nuint; + + static LongConversions() + { + s_byte = unchecked((byte)GetLong()); + s_sbyte = unchecked((sbyte)GetLong()); + s_short = unchecked((short)GetLong()); + s_ushort = unchecked((ushort)GetLong()); + s_int = unchecked((int)GetLong()); + s_uint = unchecked((uint)GetLong()); + s_ulong = unchecked((ulong)GetLong()); + s_float = unchecked((float)GetLong()); + s_double = unchecked(GetLong()); + s_nint = unchecked((nint)GetLong()); + s_nuint = unchecked((nuint)GetLong()); + } + } + + class FloatConversions + { + internal static byte s_byte; + internal static sbyte s_sbyte; + internal static short s_short; + internal static ushort s_ushort; + internal static int s_int; + internal static uint s_uint; + internal static long s_long; + internal static ulong s_ulong; + internal static double s_double; + internal static nint s_nint; + internal static nuint s_nuint; + + static FloatConversions() + { + s_byte = (byte)GetFloat(); + s_sbyte = (sbyte)GetFloat(); + s_short = (short)GetFloat(); + s_ushort = (ushort)GetFloat(); + s_int = (int)GetFloat(); + s_uint = (uint)GetFloat(); + s_long = (long)GetFloat(); + s_ulong = (ulong)GetFloat(); + s_double = GetFloat(); + s_nint = (nint)GetFloat(); + s_nuint = (nuint)GetFloat(); + } + } + + class DoubleConversions + { + internal static byte s_byte; + internal static sbyte s_sbyte; + internal static short s_short; + internal static ushort s_ushort; + internal static int s_int; + internal static uint s_uint; + internal static long s_long; + internal static ulong s_ulong; + internal static float s_float; + internal static nint s_nint; + internal static nuint s_nuint; + + static DoubleConversions() + { + s_byte = unchecked((byte)GetDouble()); + s_sbyte = unchecked((sbyte)GetDouble()); + s_short = unchecked((short)GetDouble()); + s_ushort = unchecked((ushort)GetDouble()); + s_int = unchecked((int)GetDouble()); + s_uint = unchecked((uint)GetDouble()); + s_long = unchecked((long)GetDouble()); + s_ulong = unchecked((ulong)GetDouble()); + s_float = unchecked((float)GetDouble()); + s_nint = unchecked((nint)GetDouble()); + s_nuint = unchecked((nuint)GetDouble()); + } + } + + class NativeIntConversions + { + internal static byte s_byte; + internal static sbyte s_sbyte; + internal static short s_short; + internal static ushort s_ushort; + internal static int s_int; + internal static uint s_uint; + internal static long s_long; + internal static ulong s_ulong; + internal static float s_float; + internal static double s_double; + internal static decimal s_decimal; + internal static nuint s_nuint; + + static NativeIntConversions() + { + s_byte = unchecked((byte)GetNativeInt()); + s_sbyte = unchecked((sbyte)GetNativeInt()); + s_short = unchecked((short)GetNativeInt()); + s_ushort = unchecked((ushort)GetNativeInt()); + s_int = unchecked((int)GetNativeInt()); + s_uint = unchecked((uint)GetNativeInt()); + s_long = unchecked((long)GetNativeInt()); + s_ulong = unchecked((ulong)GetNativeInt()); + s_float = unchecked((float)GetNativeInt()); + s_double = unchecked((double)GetNativeInt()); + s_decimal = unchecked((decimal)GetNativeInt()); + s_nuint = unchecked((nuint)GetNativeInt()); + } + } + + public static void Run() + { + Assert.IsPreinitialized(typeof(IntConversions)); + Assert.AreEqual(unchecked((byte)GetInt()), IntConversions.s_byte); + Assert.AreEqual(unchecked((sbyte)GetInt()), IntConversions.s_sbyte); + Assert.AreEqual(unchecked((short)GetInt()), IntConversions.s_short); + Assert.AreEqual(unchecked((ushort)GetInt()), IntConversions.s_ushort); + Assert.AreEqual(unchecked((uint)GetInt()), IntConversions.s_uint); + Assert.AreEqual(unchecked((long)GetInt()), IntConversions.s_long); + Assert.AreEqual(unchecked((ulong)GetInt()), IntConversions.s_ulong); + Assert.AreEqual(unchecked((float)GetInt()), IntConversions.s_float); + Assert.AreEqual(unchecked((double)GetInt()), IntConversions.s_double); + Assert.AreEqual(unchecked((nint)GetInt()), IntConversions.s_nint); + Assert.AreEqual(unchecked((nuint)GetInt()), IntConversions.s_nuint); + + Assert.IsPreinitialized(typeof(LongConversions)); + Assert.AreEqual(unchecked((byte)GetLong()), LongConversions.s_byte); + Assert.AreEqual(unchecked((sbyte)GetLong()), LongConversions.s_sbyte); + Assert.AreEqual(unchecked((short)GetLong()), LongConversions.s_short); + Assert.AreEqual(unchecked((ushort)GetLong()), LongConversions.s_ushort); + Assert.AreEqual(unchecked((int)GetLong()), LongConversions.s_int); + Assert.AreEqual(unchecked((uint)GetLong()), LongConversions.s_uint); + Assert.AreEqual(unchecked((ulong)GetLong()), LongConversions.s_ulong); + Assert.AreEqual(unchecked((float)GetLong()), LongConversions.s_float); + Assert.AreEqual(unchecked((double)GetLong()), LongConversions.s_double); + Assert.AreEqual(unchecked((nint)GetLong()), LongConversions.s_nint); + Assert.AreEqual(unchecked((nuint)GetLong()), LongConversions.s_nuint); + + Assert.IsPreinitialized(typeof(FloatConversions)); + Assert.AreEqual(unchecked((byte)GetFloat()), FloatConversions.s_byte); + Assert.AreEqual(unchecked((sbyte)GetFloat()), FloatConversions.s_sbyte); + Assert.AreEqual(unchecked((short)GetFloat()), FloatConversions.s_short); + Assert.AreEqual(unchecked((ushort)GetFloat()), FloatConversions.s_ushort); + Assert.AreEqual(unchecked((int)GetFloat()), FloatConversions.s_int); + Assert.AreEqual(unchecked((uint)GetFloat()), FloatConversions.s_uint); + Assert.AreEqual(unchecked((long)GetFloat()), FloatConversions.s_long); + Assert.AreEqual(unchecked((ulong)GetFloat()), FloatConversions.s_ulong); + Assert.AreEqual(unchecked((double)GetFloat()), FloatConversions.s_double); + Assert.AreEqual(unchecked((nint)GetFloat()), FloatConversions.s_nint); + Assert.AreEqual(unchecked((nuint)GetFloat()), FloatConversions.s_nuint); + + Assert.IsPreinitialized(typeof(DoubleConversions)); + Assert.AreEqual(unchecked((byte)GetDouble()), DoubleConversions.s_byte); + Assert.AreEqual(unchecked((sbyte)GetDouble()), DoubleConversions.s_sbyte); + Assert.AreEqual(unchecked((short)GetDouble()), DoubleConversions.s_short); + Assert.AreEqual(unchecked((ushort)GetDouble()), DoubleConversions.s_ushort); + Assert.AreEqual(unchecked((int)GetDouble()), DoubleConversions.s_int); + Assert.AreEqual(unchecked((uint)GetDouble()), DoubleConversions.s_uint); + Assert.AreEqual(unchecked((long)GetDouble()), DoubleConversions.s_long); + Assert.AreEqual(unchecked((ulong)GetDouble()), DoubleConversions.s_ulong); + Assert.AreEqual(unchecked((float)GetDouble()), DoubleConversions.s_float); + Assert.AreEqual(unchecked((nint)GetDouble()), DoubleConversions.s_nint); + Assert.AreEqual(unchecked((nuint)GetDouble()), DoubleConversions.s_nuint); + + Assert.IsPreinitialized(typeof(NativeIntConversions)); + Assert.AreEqual(unchecked((byte)GetNativeInt()), NativeIntConversions.s_byte); + Assert.AreEqual(unchecked((sbyte)GetNativeInt()), NativeIntConversions.s_sbyte); + Assert.AreEqual(unchecked((short)GetNativeInt()), NativeIntConversions.s_short); + Assert.AreEqual(unchecked((ushort)GetNativeInt()), NativeIntConversions.s_ushort); + Assert.AreEqual(unchecked((int)GetNativeInt()), NativeIntConversions.s_int); + Assert.AreEqual(unchecked((uint)GetNativeInt()), NativeIntConversions.s_uint); + Assert.AreEqual(unchecked((long)GetNativeInt()), NativeIntConversions.s_long); + Assert.AreEqual(unchecked((ulong)GetNativeInt()), NativeIntConversions.s_ulong); + Assert.AreEqual(unchecked((float)GetNativeInt()), NativeIntConversions.s_float); + Assert.AreEqual(unchecked((double)GetNativeInt()), NativeIntConversions.s_double); + Assert.AreEqual(unchecked((nuint)GetNativeInt()), NativeIntConversions.s_nuint); + } +} + + static class Assert { [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2070:UnrecognizedReflectionPattern", From 5c2f4ac343bfe86c92b71bc3455faed3f2d0a883 Mon Sep 17 00:00:00 2001 From: Steven He Date: Thu, 6 Feb 2025 08:24:53 +0900 Subject: [PATCH 3/9] Fix tests --- .../Preinitialization/Preinitialization.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/tests/nativeaot/SmokeTests/Preinitialization/Preinitialization.cs b/src/tests/nativeaot/SmokeTests/Preinitialization/Preinitialization.cs index a52cac3d3c3268..52bc2aeb80df3f 100644 --- a/src/tests/nativeaot/SmokeTests/Preinitialization/Preinitialization.cs +++ b/src/tests/nativeaot/SmokeTests/Preinitialization/Preinitialization.cs @@ -1711,6 +1711,12 @@ public static unsafe void AreEqual(long v1, long v2) throw new Exception(); } + public static unsafe void AreEqual(ulong v1, ulong v2) + { + if (v1 != v2) + throw new Exception(); + } + public static unsafe void AreEqual(float v1, float v2) { if (v1 != v2) @@ -1723,6 +1729,18 @@ public static unsafe void AreEqual(double v1, double v2) throw new Exception(); } + public static unsafe void AreEqual(nint v1, nint v2) + { + if (v1 != v2) + throw new Exception(); + } + + public static unsafe void AreEqual(nuint v1, nuint v2) + { + if (v1 != v2) + throw new Exception(); + } + public static void True(bool v) { if (!v) From d3b2b0f66b84598a6aec049543f8a00f43a3afd7 Mon Sep 17 00:00:00 2001 From: Steven He Date: Thu, 6 Feb 2025 08:45:43 +0900 Subject: [PATCH 4/9] Conformance --- .../aot/ILCompiler.Compiler/Compiler/TypePreinit.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs index fd05a5efc2be0f..e1e33c9fef57ef 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs @@ -936,10 +936,13 @@ private Status TryScanMethod(MethodIL methodIL, Value[] parameters, Stack Date: Sun, 9 Feb 2025 21:28:42 +0900 Subject: [PATCH 5/9] Add diag messages --- .../Preinitialization/Preinitialization.cs | 56 +++++++++---------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/src/tests/nativeaot/SmokeTests/Preinitialization/Preinitialization.cs b/src/tests/nativeaot/SmokeTests/Preinitialization/Preinitialization.cs index 52bc2aeb80df3f..5928c8e3e89c62 100644 --- a/src/tests/nativeaot/SmokeTests/Preinitialization/Preinitialization.cs +++ b/src/tests/nativeaot/SmokeTests/Preinitialization/Preinitialization.cs @@ -1669,87 +1669,87 @@ private static bool HasCctor(Type type) return type.GetConstructor(BindingFlags.NonPublic | BindingFlags.Static, null, Type.EmptyTypes, null) != null; } - public static void IsPreinitialized(Type type) + public static void IsPreinitialized(Type type, [CallerLineNumber] int line = 0) { if (HasCctor(type)) - throw new Exception(); + throw new Exception($"{type} is not preinitialized. At line {line}."); } - public static void IsLazyInitialized(Type type) + public static void IsLazyInitialized(Type type, [CallerLineNumber] int line = 0) { if (!HasCctor(type)) - throw new Exception(); + throw new Exception($"{type} is not lazy initialized. At line {line}."); } - public static unsafe void AreEqual(void* v1, void* v2) + public static unsafe void AreEqual(void* v1, void* v2, [CallerLineNumber] int line = 0) { if (v1 != v2) - throw new Exception(); + throw new Exception($"Expect {(nint)v1}, but get {(nint)v2}. At line {line}."); } - public static unsafe void AreEqual(bool v1, bool v2) + public static unsafe void AreEqual(bool v1, bool v2, [CallerLineNumber] int line = 0) { if (v1 != v2) - throw new Exception(); + throw new Exception($"Expect {v1}, but get {v2}. At line {line}."); } - public static unsafe void AreEqual(int v1, int v2) + public static unsafe void AreEqual(int v1, int v2, [CallerLineNumber] int line = 0) { if (v1 != v2) - throw new Exception(); + throw new Exception($"Expect {v1}, but get {v2}. At line {line}."); } - public static void AreEqual(string v1, string v2) + public static void AreEqual(string v1, string v2, [CallerLineNumber] int line = 0) { if (v1 != v2) - throw new Exception(); + throw new Exception($"Expect {v1}, but get {v2}. At line {line}."); } - public static unsafe void AreEqual(long v1, long v2) + public static unsafe void AreEqual(long v1, long v2, [CallerLineNumber] int line = 0) { if (v1 != v2) - throw new Exception(); + throw new Exception($"Expect {v1}, but get {v2}. At line {line}."); } - public static unsafe void AreEqual(ulong v1, ulong v2) + public static unsafe void AreEqual(ulong v1, ulong v2, [CallerLineNumber] int line = 0) { if (v1 != v2) - throw new Exception(); + throw new Exception($"Expect {v1}, but get {v2}. At line {line}."); } - public static unsafe void AreEqual(float v1, float v2) + public static unsafe void AreEqual(float v1, float v2, [CallerLineNumber] int line = 0) { if (v1 != v2) - throw new Exception(); + throw new Exception($"Expect {v1}, but get {v2}. At line {line}."); } - public static unsafe void AreEqual(double v1, double v2) + public static unsafe void AreEqual(double v1, double v2, [CallerLineNumber] int line = 0) { if (v1 != v2) - throw new Exception(); + throw new Exception($"Expect {v1}, but get {v2}. At line {line}."); } - public static unsafe void AreEqual(nint v1, nint v2) + public static unsafe void AreEqual(nint v1, nint v2, [CallerLineNumber] int line = 0) { if (v1 != v2) - throw new Exception(); + throw new Exception($"Expect True, but get {v}. At line {line}."); } - public static unsafe void AreEqual(nuint v1, nuint v2) + public static unsafe void AreEqual(nuint v1, nuint v2, [CallerLineNumber] int line = 0) { if (v1 != v2) - throw new Exception(); + throw new Exception($"Expect True, but get {v}. At line {line}."); } - public static void True(bool v) + public static void True(bool v, [CallerLineNumber] int line = 0) { if (!v) - throw new Exception(); + throw new Exception($"Expect True, but get {v}. At line {line}."); } - public static void AreSame(T v1, T v2) where T : class + public static void AreSame(T v1, T v2, [CallerLineNumber] int line = 0) where T : class { if (v1 != v2) - throw new Exception(); + throw new Exception($"{v1} and {v2} is not the same. At line {line}."); } } From ce7b634fb85bf8e5d8c5fe2dbc135a06b181acf6 Mon Sep 17 00:00:00 2001 From: Steven He Date: Sun, 9 Feb 2025 21:31:07 +0900 Subject: [PATCH 6/9] Oops --- .../SmokeTests/Preinitialization/Preinitialization.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tests/nativeaot/SmokeTests/Preinitialization/Preinitialization.cs b/src/tests/nativeaot/SmokeTests/Preinitialization/Preinitialization.cs index 5928c8e3e89c62..137c2d634f0b10 100644 --- a/src/tests/nativeaot/SmokeTests/Preinitialization/Preinitialization.cs +++ b/src/tests/nativeaot/SmokeTests/Preinitialization/Preinitialization.cs @@ -1732,13 +1732,13 @@ public static unsafe void AreEqual(double v1, double v2, [CallerLineNumber] int public static unsafe void AreEqual(nint v1, nint v2, [CallerLineNumber] int line = 0) { if (v1 != v2) - throw new Exception($"Expect True, but get {v}. At line {line}."); + throw new Exception($"Expect {v1}, but get {v2}. At line {line}."); } public static unsafe void AreEqual(nuint v1, nuint v2, [CallerLineNumber] int line = 0) { if (v1 != v2) - throw new Exception($"Expect True, but get {v}. At line {line}."); + throw new Exception($"Expect {v1}, but get {v2}. At line {line}."); } public static void True(bool v, [CallerLineNumber] int line = 0) From 674daff61ff0654ebedc332393b039d9390d1757 Mon Sep 17 00:00:00 2001 From: Steven He Date: Mon, 10 Feb 2025 03:50:25 +0900 Subject: [PATCH 7/9] Also account for nint in neg --- .../tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs index e1e33c9fef57ef..e62bed88b34f42 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs @@ -1437,10 +1437,10 @@ private Status TryScanMethod(MethodIL methodIL, Value[] parameters, Stack Date: Mon, 10 Feb 2025 03:51:31 +0900 Subject: [PATCH 8/9] Cleanup --- .../tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs index e62bed88b34f42..8a437f66bce9c7 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs @@ -1438,11 +1438,11 @@ private Status TryScanMethod(MethodIL methodIL, Value[] parameters, Stack Date: Tue, 11 Feb 2025 00:06:53 +0900 Subject: [PATCH 9/9] Fix invalid test --- .../Preinitialization/Preinitialization.cs | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/tests/nativeaot/SmokeTests/Preinitialization/Preinitialization.cs b/src/tests/nativeaot/SmokeTests/Preinitialization/Preinitialization.cs index 137c2d634f0b10..b645995549b22d 100644 --- a/src/tests/nativeaot/SmokeTests/Preinitialization/Preinitialization.cs +++ b/src/tests/nativeaot/SmokeTests/Preinitialization/Preinitialization.cs @@ -1459,11 +1459,11 @@ static IntConversions() s_short = unchecked((short)GetInt()); s_ushort = unchecked((ushort)GetInt()); s_uint = unchecked((uint)GetInt()); - s_long = GetInt(); + s_long = unchecked((long)GetInt()); s_ulong = unchecked((ulong)GetInt()); s_float = unchecked((float)GetInt()); s_double = unchecked(GetInt()); - s_nint = GetInt(); + s_nint = unchecked((nint)GetInt()); s_nuint = unchecked((nuint)GetInt()); } } @@ -1492,7 +1492,7 @@ static LongConversions() s_uint = unchecked((uint)GetLong()); s_ulong = unchecked((ulong)GetLong()); s_float = unchecked((float)GetLong()); - s_double = unchecked(GetLong()); + s_double = unchecked((double)GetLong()); s_nint = unchecked((nint)GetLong()); s_nuint = unchecked((nuint)GetLong()); } @@ -1514,17 +1514,17 @@ class FloatConversions static FloatConversions() { - s_byte = (byte)GetFloat(); - s_sbyte = (sbyte)GetFloat(); - s_short = (short)GetFloat(); - s_ushort = (ushort)GetFloat(); - s_int = (int)GetFloat(); - s_uint = (uint)GetFloat(); - s_long = (long)GetFloat(); - s_ulong = (ulong)GetFloat(); - s_double = GetFloat(); - s_nint = (nint)GetFloat(); - s_nuint = (nuint)GetFloat(); + s_byte = unchecked((byte)GetFloat()); + s_sbyte = unchecked((sbyte)GetFloat()); + s_short = unchecked((short)GetFloat()); + s_ushort = unchecked((ushort)GetFloat()); + s_int = unchecked((int)GetFloat()); + s_uint = unchecked((uint)GetFloat()); + s_long = unchecked((long)GetFloat()); + s_ulong = unchecked((ulong)GetFloat()); + s_double = unchecked((double)GetFloat()); + s_nint = unchecked((nint)GetFloat()); + s_nuint = unchecked((nuint)GetFloat()); } } @@ -1570,7 +1570,6 @@ class NativeIntConversions internal static ulong s_ulong; internal static float s_float; internal static double s_double; - internal static decimal s_decimal; internal static nuint s_nuint; static NativeIntConversions() @@ -1585,7 +1584,6 @@ static NativeIntConversions() s_ulong = unchecked((ulong)GetNativeInt()); s_float = unchecked((float)GetNativeInt()); s_double = unchecked((double)GetNativeInt()); - s_decimal = unchecked((decimal)GetNativeInt()); s_nuint = unchecked((nuint)GetNativeInt()); } }