From 94f8121ead4204ef335c20bc660d1ad1595f49d2 Mon Sep 17 00:00:00 2001 From: Steven He Date: Sat, 1 Feb 2025 19:36:25 +0900 Subject: [PATCH 1/2] Mark TryConvertFrom as AggressiveInlining --- src/libraries/System.Private.CoreLib/src/System/Decimal.cs | 1 + src/libraries/System.Private.CoreLib/src/System/Double.cs | 1 + src/libraries/System.Private.CoreLib/src/System/Half.cs | 1 + .../src/System/Runtime/InteropServices/NFloat.cs | 1 + src/libraries/System.Private.CoreLib/src/System/Single.cs | 1 + 5 files changed, 5 insertions(+) diff --git a/src/libraries/System.Private.CoreLib/src/System/Decimal.cs b/src/libraries/System.Private.CoreLib/src/System/Decimal.cs index 351597114398c8..53dc3538cf4345 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Decimal.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Decimal.cs @@ -1573,6 +1573,7 @@ static bool INumberBase.TryConvertFromTruncating(TOther value, return TryConvertFrom(value, out result); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] private static bool TryConvertFrom(TOther value, out decimal result) where TOther : INumberBase { diff --git a/src/libraries/System.Private.CoreLib/src/System/Double.cs b/src/libraries/System.Private.CoreLib/src/System/Double.cs index c4ed8ed65587ad..31d2f96f94e2b7 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Double.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Double.cs @@ -1229,6 +1229,7 @@ static bool INumberBase.TryConvertFromTruncating(TOther value, o return TryConvertFrom(value, out result); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] private static bool TryConvertFrom(TOther value, out double result) where TOther : INumberBase { diff --git a/src/libraries/System.Private.CoreLib/src/System/Half.cs b/src/libraries/System.Private.CoreLib/src/System/Half.cs index fab95058ccd261..ddf563f51b3dfa 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Half.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Half.cs @@ -1928,6 +1928,7 @@ static bool INumberBase.TryConvertFromTruncating(TOther value, out return TryConvertFrom(value, out result); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] private static bool TryConvertFrom(TOther value, out Half result) where TOther : INumberBase { diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/NFloat.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/NFloat.cs index 5939bc9e159450..27ed9bff4bb0d0 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/NFloat.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/NFloat.cs @@ -1410,6 +1410,7 @@ static bool INumberBase.TryConvertFromTruncating(TOther value, o return TryConvertFrom(value, out result); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] private static bool TryConvertFrom(TOther value, out NFloat result) where TOther : INumberBase { diff --git a/src/libraries/System.Private.CoreLib/src/System/Single.cs b/src/libraries/System.Private.CoreLib/src/System/Single.cs index 38b9b389f7d9c3..b6c6bc86c87095 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Single.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Single.cs @@ -1248,6 +1248,7 @@ static bool INumberBase.TryConvertFromTruncating(TOther value, ou return TryConvertFrom(value, out result); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] private static bool TryConvertFrom(TOther value, out float result) where TOther : INumberBase { From 4ba7228c9376783a77ec32015d62cf81a975322b Mon Sep 17 00:00:00 2001 From: Steven He Date: Sat, 1 Feb 2025 20:15:10 +0900 Subject: [PATCH 2/2] Cover TryConvertTo --- src/libraries/System.Private.CoreLib/src/System/Decimal.cs | 1 + src/libraries/System.Private.CoreLib/src/System/Double.cs | 1 + src/libraries/System.Private.CoreLib/src/System/Half.cs | 1 + .../src/System/Runtime/InteropServices/NFloat.cs | 1 + src/libraries/System.Private.CoreLib/src/System/Single.cs | 1 + 5 files changed, 5 insertions(+) diff --git a/src/libraries/System.Private.CoreLib/src/System/Decimal.cs b/src/libraries/System.Private.CoreLib/src/System/Decimal.cs index 53dc3538cf4345..c9e03939b8ae82 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Decimal.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Decimal.cs @@ -1723,6 +1723,7 @@ static bool INumberBase.TryConvertToTruncating(decimal value, [ return TryConvertTo(value, out result); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] private static bool TryConvertTo(decimal value, [MaybeNullWhen(false)] out TOther result) where TOther : INumberBase { diff --git a/src/libraries/System.Private.CoreLib/src/System/Double.cs b/src/libraries/System.Private.CoreLib/src/System/Double.cs index 31d2f96f94e2b7..a5adb8057f6a5e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Double.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Double.cs @@ -1379,6 +1379,7 @@ static bool INumberBase.TryConvertToTruncating(double value, [Ma return TryConvertTo(value, out result); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] private static bool TryConvertTo(double value, [MaybeNullWhen(false)] out TOther result) where TOther : INumberBase { diff --git a/src/libraries/System.Private.CoreLib/src/System/Half.cs b/src/libraries/System.Private.CoreLib/src/System/Half.cs index ddf563f51b3dfa..3ef63767f242d8 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Half.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Half.cs @@ -2078,6 +2078,7 @@ static bool INumberBase.TryConvertToTruncating(Half value, [MaybeN return TryConvertTo(value, out result); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] private static bool TryConvertTo(Half value, [MaybeNullWhen(false)] out TOther result) where TOther : INumberBase { diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/NFloat.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/NFloat.cs index 27ed9bff4bb0d0..5e2fb905df195c 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/NFloat.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/NFloat.cs @@ -1650,6 +1650,7 @@ static bool INumberBase.TryConvertToTruncating(NFloat value, [Ma return TryConvertTo(value, out result); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] private static bool TryConvertTo(NFloat value, [MaybeNullWhen(false)] out TOther result) where TOther : INumberBase { diff --git a/src/libraries/System.Private.CoreLib/src/System/Single.cs b/src/libraries/System.Private.CoreLib/src/System/Single.cs index b6c6bc86c87095..ef991d4aea3ea0 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Single.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Single.cs @@ -1398,6 +1398,7 @@ static bool INumberBase.TryConvertToTruncating(float value, [Mayb return TryConvertTo(value, out result); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] private static bool TryConvertTo(float value, [MaybeNullWhen(false)] out TOther result) where TOther : INumberBase {