Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release/6.0] Add explicit APIs to Double/Single/Half/TimeOnly #58845

Merged
merged 3 commits into from
Sep 9, 2021
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
24 changes: 24 additions & 0 deletions src/libraries/System.Private.CoreLib/src/System/Double.cs
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,30 @@ static double IFloatingPoint<double>.Tanh(double x)
static double IFloatingPoint<double>.Truncate(double x)
=> Math.Truncate(x);

[RequiresPreviewFeatures]
static bool IFloatingPoint<double>.IsFinite(double d) => IsFinite(d);

[RequiresPreviewFeatures]
static bool IFloatingPoint<double>.IsInfinity(double d) => IsInfinity(d);

[RequiresPreviewFeatures]
static bool IFloatingPoint<double>.IsNaN(double d) => IsNaN(d);

[RequiresPreviewFeatures]
static bool IFloatingPoint<double>.IsNegative(double d) => IsNegative(d);

[RequiresPreviewFeatures]
static bool IFloatingPoint<double>.IsNegativeInfinity(double d) => IsNegativeInfinity(d);

[RequiresPreviewFeatures]
static bool IFloatingPoint<double>.IsNormal(double d) => IsNormal(d);

[RequiresPreviewFeatures]
static bool IFloatingPoint<double>.IsPositiveInfinity(double d) => IsPositiveInfinity(d);

[RequiresPreviewFeatures]
static bool IFloatingPoint<double>.IsSubnormal(double d) => IsSubnormal(d);

// static double IFloatingPoint<double>.AcosPi(double x)
// => Math.AcosPi(x);
//
Expand Down
25 changes: 25 additions & 0 deletions src/libraries/System.Private.CoreLib/src/System/Half.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1059,6 +1059,31 @@ static Half IFloatingPoint<Half>.Tanh(Half x)
static Half IFloatingPoint<Half>.Truncate(Half x)
=> (Half)MathF.Truncate((float)x);

[RequiresPreviewFeatures]
static bool IFloatingPoint<Half>.IsFinite(Half x) => IsFinite(x);

[RequiresPreviewFeatures]
static bool IFloatingPoint<Half>.IsInfinity(Half x) => IsInfinity(x);

[RequiresPreviewFeatures]
static bool IFloatingPoint<Half>.IsNaN(Half x) => IsNaN(x);

[RequiresPreviewFeatures]
static bool IFloatingPoint<Half>.IsNegative(Half x) => IsNegative(x);

[RequiresPreviewFeatures]
static bool IFloatingPoint<Half>.IsNegativeInfinity(Half x) => IsNegativeInfinity(x);

[RequiresPreviewFeatures]
static bool IFloatingPoint<Half>.IsNormal(Half x) => IsNormal(x);

[RequiresPreviewFeatures]
static bool IFloatingPoint<Half>.IsPositiveInfinity(Half x) => IsPositiveInfinity(x);

[RequiresPreviewFeatures]
static bool IFloatingPoint<Half>.IsSubnormal(Half x) => IsSubnormal(x);


// static Half IFloatingPoint<Half>.AcosPi(Half x)
// => (Half)MathF.AcosPi((float)x);
//
Expand Down
24 changes: 24 additions & 0 deletions src/libraries/System.Private.CoreLib/src/System/Single.cs
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,30 @@ static float IFloatingPoint<float>.Tanh(float x)
static float IFloatingPoint<float>.Truncate(float x)
=> MathF.Truncate(x);

[RequiresPreviewFeatures]
static bool IFloatingPoint<float>.IsFinite(float x) => IsFinite(x);

[RequiresPreviewFeatures]
static bool IFloatingPoint<float>.IsInfinity(float x) => IsInfinity(x);

[RequiresPreviewFeatures]
static bool IFloatingPoint<float>.IsNaN(float x) => IsNaN(x);

[RequiresPreviewFeatures]
static bool IFloatingPoint<float>.IsNegative(float x) => IsNegative(x);

[RequiresPreviewFeatures]
static bool IFloatingPoint<float>.IsNegativeInfinity(float x) => IsNegativeInfinity(x);

[RequiresPreviewFeatures]
static bool IFloatingPoint<float>.IsNormal(float x) => IsNormal(x);

[RequiresPreviewFeatures]
static bool IFloatingPoint<float>.IsPositiveInfinity(float x) => IsPositiveInfinity(x);

[RequiresPreviewFeatures]
static bool IFloatingPoint<float>.IsSubnormal(float x) => IsSubnormal(x);

// static float IFloatingPoint<float>.AcosPi(float x)
// => MathF.AcosPi(x);
//
Expand Down
7 changes: 7 additions & 0 deletions src/libraries/System.Private.CoreLib/src/System/TimeOnly.cs
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,13 @@ static bool ISpanParseable<TimeOnly>.TryParse(ReadOnlySpan<char> s, IFormatProvi
// [RequiresPreviewFeatures]
// static checked TimeSpan ISubtractionOperators<TimeOnly, TimeOnly, TimeSpan>.operator -(TimeOnly left, TimeOnly right)
// => checked(left - right);

[RequiresPreviewFeatures]
static TimeOnly IMinMaxValue<TimeOnly>.MinValue => MinValue;

[RequiresPreviewFeatures]
static TimeOnly IMinMaxValue<TimeOnly>.MaxValue => MaxValue;

#endif // FEATURE_GENERIC_MATH
}
}
56 changes: 56 additions & 0 deletions src/libraries/System.Runtime/ref/System.Runtime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2552,6 +2552,23 @@ public DivideByZeroException(string? message, System.Exception? innerException)
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
static double IFloatingPoint<double>.Truncate(double x) { throw null; }

[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pgovind I see a blank line here so perhaps you hand edited? If you generate mechanically then it avoids diffs later: https://github.com/dotnet/runtime/blob/main/docs/coding-guidelines/updating-ref-source.md#L16

No need to change here though.

static bool IFloatingPoint<double>.IsFinite(double d) { throw null; }
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
static bool IFloatingPoint<double>.IsInfinity(double d) { throw null; }
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
static bool IFloatingPoint<double>.IsNaN(double d) { throw null; }
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
static bool IFloatingPoint<double>.IsNegative(double d) { throw null; }
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
static bool IFloatingPoint<double>.IsNegativeInfinity(double d) { throw null; }
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
static bool IFloatingPoint<double>.IsNormal(double d) { throw null; }
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
static bool IFloatingPoint<double>.IsPositiveInfinity(double d) { throw null; }
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
static bool IFloatingPoint<double>.IsSubnormal(double d) { throw null; }

[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
static double IIncrementOperators<double>.operator ++(double value) { throw null; }

Expand Down Expand Up @@ -3269,6 +3286,23 @@ public GopherStyleUriParser() { }
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
static System.Half IFloatingPoint<System.Half>.Truncate(System.Half x) { throw null; }

[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
static bool IFloatingPoint<System.Half>.IsFinite(System.Half x) { throw null; }
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
static bool IFloatingPoint<System.Half>.IsInfinity(System.Half x) { throw null; }
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
static bool IFloatingPoint<System.Half>.IsNaN(System.Half x) { throw null; }
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
static bool IFloatingPoint<System.Half>.IsNegative(System.Half x) { throw null; }
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
static bool IFloatingPoint<System.Half>.IsNegativeInfinity(System.Half x) { throw null; }
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
static bool IFloatingPoint<System.Half>.IsNormal(System.Half x) { throw null; }
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
static bool IFloatingPoint<System.Half>.IsPositiveInfinity(System.Half x) { throw null; }
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
static bool IFloatingPoint<System.Half>.IsSubnormal(System.Half x) { throw null; }

[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
static System.Half IIncrementOperators<System.Half>.operator ++(System.Half value) { throw null; }

Expand Down Expand Up @@ -5594,6 +5628,23 @@ public SerializableAttribute() { }
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
static float IFloatingPoint<float>.Truncate(float x) { throw null; }

[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
static bool IFloatingPoint<float>.IsFinite(float x) { throw null; }
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
static bool IFloatingPoint<float>.IsInfinity(float x) { throw null; }
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
static bool IFloatingPoint<float>.IsNaN(float x) { throw null; }
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
static bool IFloatingPoint<float>.IsNegative(float x) { throw null; }
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
static bool IFloatingPoint<float>.IsNegativeInfinity(float x) { throw null; }
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
static bool IFloatingPoint<float>.IsNormal(float x) { throw null; }
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
static bool IFloatingPoint<float>.IsPositiveInfinity(float x) { throw null; }
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
static bool IFloatingPoint<float>.IsSubnormal(float x) { throw null; }

[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
static float IIncrementOperators<float>.operator ++(float value) { throw null; }

Expand Down Expand Up @@ -6062,6 +6113,11 @@ public ThreadStaticAttribute() { }

[System.Runtime.Versioning.RequiresPreviewFeatures]
static System.TimeSpan ISubtractionOperators<System.TimeOnly, System.TimeOnly, System.TimeSpan>.operator -(System.TimeOnly left, System.TimeOnly right) { throw null; }

[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
static System.TimeOnly IMinMaxValue<System.TimeOnly>.MinValue { get { throw null; } }
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
static System.TimeOnly IMinMaxValue<System.TimeOnly>.MaxValue { get { throw null; } }
#endif // FEATURE_GENERIC_MATH
}
public partial class TimeoutException : System.SystemException
Expand Down