From fa3b6515e362b059dc2d6dd7fcb675f70be95d5b Mon Sep 17 00:00:00 2001 From: Prashanth Govindarajan Date: Tue, 7 Sep 2021 16:02:19 -0700 Subject: [PATCH 1/3] Add explicit APIs to Double/Single/Half/TimeOnly --- .../src/System/Double.cs | 24 ++++++++ .../System.Private.CoreLib/src/System/Half.cs | 25 +++++++++ .../src/System/Single.cs | 24 ++++++++ .../src/System/TimeOnly.cs | 7 +++ .../System.Runtime/ref/System.Runtime.cs | 56 +++++++++++++++++++ 5 files changed, 136 insertions(+) diff --git a/src/libraries/System.Private.CoreLib/src/System/Double.cs b/src/libraries/System.Private.CoreLib/src/System/Double.cs index 3165535dd15b4..6fde5409e2add 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Double.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Double.cs @@ -755,6 +755,30 @@ static double IFloatingPoint.Tanh(double x) static double IFloatingPoint.Truncate(double x) => Math.Truncate(x); + [RequiresPreviewFeatures] + static bool IFloatingPoint.IsFinite(double d) => IsFinite(d); + + [RequiresPreviewFeatures] + static bool IFloatingPoint.IsInfinity(double d) => IsInfinity(d); + + [RequiresPreviewFeatures] + static bool IFloatingPoint.IsNaN(double d) => IsNaN(d); + + [RequiresPreviewFeatures] + static bool IFloatingPoint.IsNegative(double d) => IsNegative(d); + + [RequiresPreviewFeatures] + static bool IFloatingPoint.IsNegativeInfinity(double d) => IsNegativeInfinity(d); + + [RequiresPreviewFeatures] + static bool IFloatingPoint.IsNormal(double d) => IsNormal(d); + + [RequiresPreviewFeatures] + static bool IFloatingPoint.IsPositiveInfinity(double d) => IsPositiveInfinity(d); + + [RequiresPreviewFeatures] + static bool IFloatingPoint.IsSubnormal(double d) => IsSubnormal(d); + // static double IFloatingPoint.AcosPi(double x) // => Math.AcosPi(x); // diff --git a/src/libraries/System.Private.CoreLib/src/System/Half.cs b/src/libraries/System.Private.CoreLib/src/System/Half.cs index c42d7a4374e52..c8791e1b8d9ac 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Half.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Half.cs @@ -1059,6 +1059,31 @@ static Half IFloatingPoint.Tanh(Half x) static Half IFloatingPoint.Truncate(Half x) => (Half)MathF.Truncate((float)x); + [RequiresPreviewFeatures] + static bool IFloatingPoint.IsFinite(Half x) => IsFinite(x); + + [RequiresPreviewFeatures] + static bool IFloatingPoint.IsInfinity(Half x) => IsInfinity(x); + + [RequiresPreviewFeatures] + static bool IFloatingPoint.IsNaN(Half x) => IsNaN(x); + + [RequiresPreviewFeatures] + static bool IFloatingPoint.IsNegative(Half x) => IsNegative(x); + + [RequiresPreviewFeatures] + static bool IFloatingPoint.IsNegativeInfinity(Half x) => IsNegativeInfinity(x); + + [RequiresPreviewFeatures] + static bool IFloatingPoint.IsNormal(Half x) => IsNormal(x); + + [RequiresPreviewFeatures] + static bool IFloatingPoint.IsPositiveInfinity(Half x) => IsPositiveInfinity(x); + + [RequiresPreviewFeatures] + static bool IFloatingPoint.IsSubnormal(Half x) => IsSubnormal(x); + + // static Half IFloatingPoint.AcosPi(Half x) // => (Half)MathF.AcosPi((float)x); // diff --git a/src/libraries/System.Private.CoreLib/src/System/Single.cs b/src/libraries/System.Private.CoreLib/src/System/Single.cs index 24150edb87230..26ea34a6d70fb 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Single.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Single.cs @@ -747,6 +747,30 @@ static float IFloatingPoint.Tanh(float x) static float IFloatingPoint.Truncate(float x) => MathF.Truncate(x); + [RequiresPreviewFeatures] + static bool IFloatingPoint.IsFinite(float x) => IsFinite(x); + + [RequiresPreviewFeatures] + static bool IFloatingPoint.IsInfinity(float x) => IsInfinity(x); + + [RequiresPreviewFeatures] + static bool IFloatingPoint.IsNaN(float x) => IsNaN(x); + + [RequiresPreviewFeatures] + static bool IFloatingPoint.IsNegative(float x) => IsNegative(x); + + [RequiresPreviewFeatures] + static bool IFloatingPoint.IsNegativeInfinity(float x) => IsNegativeInfinity(x); + + [RequiresPreviewFeatures] + static bool IFloatingPoint.IsNormal(float x) => IsNormal(x); + + [RequiresPreviewFeatures] + static bool IFloatingPoint.IsPositiveInfinity(float x) => IsPositiveInfinity(x); + + [RequiresPreviewFeatures] + static bool IFloatingPoint.IsSubnormal(float x) => IsSubnormal(x); + // static float IFloatingPoint.AcosPi(float x) // => MathF.AcosPi(x); // diff --git a/src/libraries/System.Private.CoreLib/src/System/TimeOnly.cs b/src/libraries/System.Private.CoreLib/src/System/TimeOnly.cs index d89c04fb67560..d842806a0bc9e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/TimeOnly.cs +++ b/src/libraries/System.Private.CoreLib/src/System/TimeOnly.cs @@ -974,6 +974,13 @@ static bool ISpanParseable.TryParse(ReadOnlySpan s, IFormatProvi // [RequiresPreviewFeatures] // static checked TimeSpan ISubtractionOperators.operator -(TimeOnly left, TimeOnly right) // => checked(left - right); + + [RequiresPreviewFeatures] + static TimeOnly IMinMaxValue.MinValue => MinValue; + + [RequiresPreviewFeatures] + static TimeOnly IMinMaxValue.MaxValue => MaxValue; + #endif // FEATURE_GENERIC_MATH } } diff --git a/src/libraries/System.Runtime/ref/System.Runtime.cs b/src/libraries/System.Runtime/ref/System.Runtime.cs index 5de2f8d1c1605..f7a342041955a 100644 --- a/src/libraries/System.Runtime/ref/System.Runtime.cs +++ b/src/libraries/System.Runtime/ref/System.Runtime.cs @@ -2552,6 +2552,23 @@ public DivideByZeroException(string? message, System.Exception? innerException) [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute] static double IFloatingPoint.Truncate(double x) { throw null; } + [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute] + static bool IFloatingPoint.IsFinite(double d) { throw null; } + [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute] + static bool IFloatingPoint.IsInfinity(double d) { throw null; } + [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute] + static bool IFloatingPoint.IsNaN(double d) { throw null; } + [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute] + static bool IFloatingPoint.IsNegative(double d) { throw null; } + [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute] + static bool IFloatingPoint.IsNegativeInfinity(double d) { throw null; } + [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute] + static bool IFloatingPoint.IsNormal(double d) { throw null; } + [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute] + static bool IFloatingPoint.IsPositiveInfinity(double d) { throw null; } + [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute] + static bool IFloatingPoint.IsSubnormal(double d) { throw null; } + [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute] static double IIncrementOperators.operator ++(double value) { throw null; } @@ -3269,6 +3286,23 @@ public GopherStyleUriParser() { } [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute] static System.Half IFloatingPoint.Truncate(System.Half x) { throw null; } + [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute] + static bool IFloatingPoint.IsFinite(Half x) { throw null; } + [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute] + static bool IFloatingPoint.IsInfinity(Half x) { throw null; } + [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute] + static bool IFloatingPoint.IsNaN(Half x) { throw null; } + [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute] + static bool IFloatingPoint.IsNegative(Half x) { throw null; } + [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute] + static bool IFloatingPoint.IsNegativeInfinity(Half x) { throw null; } + [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute] + static bool IFloatingPoint.IsNormal(Half x) { throw null; } + [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute] + static bool IFloatingPoint.IsPositiveInfinity(Half x) { throw null; } + [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute] + static bool IFloatingPoint.IsSubnormal(Half x) { throw null; } + [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute] static System.Half IIncrementOperators.operator ++(System.Half value) { throw null; } @@ -5594,6 +5628,23 @@ public SerializableAttribute() { } [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute] static float IFloatingPoint.Truncate(float x) { throw null; } + [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute] + static bool IFloatingPoint.IsFinite(float x) { throw null; } + [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute] + static bool IFloatingPoint.IsInfinity(float x) { throw null; } + [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute] + static bool IFloatingPoint.IsNaN(float x) { throw null; } + [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute] + static bool IFloatingPoint.IsNegative(float x) { throw null; } + [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute] + static bool IFloatingPoint.IsNegativeInfinity(float x) { throw null; } + [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute] + static bool IFloatingPoint.IsNormal(float x) { throw null; } + [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute] + static bool IFloatingPoint.IsPositiveInfinity(float x) { throw null; } + [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute] + static bool IFloatingPoint.IsSubnormal(float x) { throw null; } + [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute] static float IIncrementOperators.operator ++(float value) { throw null; } @@ -6062,6 +6113,11 @@ public ThreadStaticAttribute() { } [System.Runtime.Versioning.RequiresPreviewFeatures] static System.TimeSpan ISubtractionOperators.operator -(System.TimeOnly left, System.TimeOnly right) { throw null; } + + [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute] + static System.TimeOnly IMinMaxValue.MinValue { throw null; } + [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute] + static System.TimeOnly IMinMaxValue.MaxValue { throw null; } #endif // FEATURE_GENERIC_MATH } public partial class TimeoutException : System.SystemException From 31d90677a26d2f778b7b631aadcf5db2749ebe30 Mon Sep 17 00:00:00 2001 From: Prashanth Govindarajan Date: Tue, 7 Sep 2021 16:15:26 -0700 Subject: [PATCH 2/3] sq --- .../System.Runtime/ref/System.Runtime.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/libraries/System.Runtime/ref/System.Runtime.cs b/src/libraries/System.Runtime/ref/System.Runtime.cs index f7a342041955a..b4203df34bf90 100644 --- a/src/libraries/System.Runtime/ref/System.Runtime.cs +++ b/src/libraries/System.Runtime/ref/System.Runtime.cs @@ -3287,21 +3287,21 @@ public GopherStyleUriParser() { } static System.Half IFloatingPoint.Truncate(System.Half x) { throw null; } [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute] - static bool IFloatingPoint.IsFinite(Half x) { throw null; } + static bool IFloatingPoint.IsFinite(System.Half x) { throw null; } [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute] - static bool IFloatingPoint.IsInfinity(Half x) { throw null; } + static bool IFloatingPoint.IsInfinity(System.Half x) { throw null; } [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute] - static bool IFloatingPoint.IsNaN(Half x) { throw null; } + static bool IFloatingPoint.IsNaN(System.Half x) { throw null; } [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute] - static bool IFloatingPoint.IsNegative(Half x) { throw null; } + static bool IFloatingPoint.IsNegative(System.Half x) { throw null; } [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute] - static bool IFloatingPoint.IsNegativeInfinity(Half x) { throw null; } + static bool IFloatingPoint.IsNegativeInfinity(System.Half x) { throw null; } [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute] - static bool IFloatingPoint.IsNormal(Half x) { throw null; } + static bool IFloatingPoint.IsNormal(System.Half x) { throw null; } [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute] - static bool IFloatingPoint.IsPositiveInfinity(Half x) { throw null; } + static bool IFloatingPoint.IsPositiveInfinity(System.Half x) { throw null; } [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute] - static bool IFloatingPoint.IsSubnormal(Half x) { throw null; } + static bool IFloatingPoint.IsSubnormal(System.Half x) { throw null; } [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute] static System.Half IIncrementOperators.operator ++(System.Half value) { throw null; } From b46b1ba295eba1e19a8ba07583a8c5880a641d3c Mon Sep 17 00:00:00 2001 From: Prashanth Govindarajan Date: Tue, 7 Sep 2021 16:40:48 -0700 Subject: [PATCH 3/3] Fix get accessor in ref --- src/libraries/System.Runtime/ref/System.Runtime.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Runtime/ref/System.Runtime.cs b/src/libraries/System.Runtime/ref/System.Runtime.cs index b4203df34bf90..b617e4dd85c84 100644 --- a/src/libraries/System.Runtime/ref/System.Runtime.cs +++ b/src/libraries/System.Runtime/ref/System.Runtime.cs @@ -6115,9 +6115,9 @@ public ThreadStaticAttribute() { } static System.TimeSpan ISubtractionOperators.operator -(System.TimeOnly left, System.TimeOnly right) { throw null; } [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute] - static System.TimeOnly IMinMaxValue.MinValue { throw null; } + static System.TimeOnly IMinMaxValue.MinValue { get { throw null; } } [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute] - static System.TimeOnly IMinMaxValue.MaxValue { throw null; } + static System.TimeOnly IMinMaxValue.MaxValue { get { throw null; } } #endif // FEATURE_GENERIC_MATH } public partial class TimeoutException : System.SystemException