From 68aebc1b56bee1d433cd8faf2790209e9da6c11e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 18 Aug 2022 08:00:14 -0400 Subject: [PATCH] [release/7.0-rc1] Fix nullable annotations on generic math interfaces (#74116) * Fix nullable annotations on generic math interfaces - All `where TSelf : ...` constraints become `where TSelf : ...?`. Without this, trying to define a type like `Matrix where T : INumber?` in order to support nullable T types warns because `INumber` constrains its `T` (`TSelf`) to be non-nullable. - All `where TOther : ...` constraints are changed to be oblivious. They can't be correctly annotated as there's no way to express the nullability relationship with the nullability of TSelf. - Use `[MaybeNullWhen(false)] out T` instead of `[NotNullWhen(true)] out T?`, as we do with other generics, since if the instantiation of `T` is nullable, we can't guarantee `NotNullWhen(true)`. - Make `IEqualityOperators` `==` and `!=` accept `TSelf?`. This keeps it consistent with `IEquatable.Equals(T?)`, `IEqualityComparer.Equals(T?, T?)`, `IEqualityComparer.Equals(object?, object?)`, `IStructuralEquatable.Equals(object?, IEqualityComparer)`, and `object.Equals(object?)` which all allow null even if generic and the generic is non-null. It in turn enables checks like `T.Zero == default` without nullability warnings. * Address PR feedback Co-authored-by: Stephen Toub --- .../System.Private.CoreLib/src/System/Byte.cs | 12 +- .../System.Private.CoreLib/src/System/Char.cs | 12 +- .../Collections/Concurrent/ConcurrentQueue.cs | 2 +- .../src/System/Collections/Generic/Queue.cs | 4 +- .../src/System/Decimal.cs | 12 +- .../src/System/Double.cs | 12 +- .../System.Private.CoreLib/src/System/Half.cs | 12 +- .../src/System/IParsable.cs | 2 +- .../src/System/ISpanParsable.cs | 2 +- .../src/System/Int128.cs | 12 +- .../src/System/Int16.cs | 12 +- .../src/System/Int32.cs | 12 +- .../src/System/Int64.cs | 12 +- .../src/System/IntPtr.cs | 12 +- .../src/System/Numerics/IAdditionOperators.cs | 2 +- .../src/System/Numerics/IAdditiveIdentity.cs | 2 +- .../Numerics/IBinaryFloatingPointIeee754.cs | 2 +- .../src/System/Numerics/IBinaryInteger.cs | 23 +- .../src/System/Numerics/IBinaryNumber.cs | 2 +- .../src/System/Numerics/IBitwiseOperators.cs | 2 +- .../System/Numerics/IComparisonOperators.cs | 2 +- .../System/Numerics/IDecrementOperators.cs | 2 +- .../src/System/Numerics/IDivisionOperators.cs | 2 +- .../src/System/Numerics/IEqualityOperators.cs | 6 +- .../System/Numerics/IExponentialFunctions.cs | 2 +- .../src/System/Numerics/IFloatingPoint.cs | 2 +- .../Numerics/IFloatingPointConstants.cs | 2 +- .../System/Numerics/IFloatingPointIeee754.cs | 2 +- .../System/Numerics/IHyperbolicFunctions.cs | 2 +- .../System/Numerics/IIncrementOperators.cs | 2 +- .../System/Numerics/ILogarithmicFunctions.cs | 2 +- .../src/System/Numerics/IMinMaxValue.cs | 2 +- .../src/System/Numerics/IModulusOperators.cs | 2 +- .../Numerics/IMultiplicativeIdentity.cs | 2 +- .../src/System/Numerics/IMultiplyOperators.cs | 2 +- .../src/System/Numerics/INumber.cs | 2 +- .../src/System/Numerics/INumberBase.cs | 38 ++- .../src/System/Numerics/IPowerFunctions.cs | 2 +- .../src/System/Numerics/IRootFunctions.cs | 2 +- .../src/System/Numerics/IShiftOperators.cs | 2 +- .../src/System/Numerics/ISignedNumber.cs | 2 +- .../System/Numerics/ISubtractionOperators.cs | 2 +- .../Numerics/ITrigonometricFunctions.cs | 2 +- .../Numerics/IUnaryNegationOperators.cs | 2 +- .../System/Numerics/IUnaryPlusOperators.cs | 2 +- .../src/System/Numerics/IUnsignedNumber.cs | 2 +- .../System/Runtime/InteropServices/NFloat.cs | 14 +- .../src/System/SByte.cs | 12 +- .../src/System/Single.cs | 12 +- .../src/System/UInt128.cs | 12 +- .../src/System/UInt16.cs | 12 +- .../src/System/UInt32.cs | 12 +- .../src/System/UInt64.cs | 12 +- .../src/System/UIntPtr.cs | 12 +- .../ref/System.Runtime.InteropServices.cs | 6 +- .../ref/System.Runtime.Numerics.cs | 12 +- .../src/System/Numerics/BigInteger.cs | 12 +- .../src/System/Numerics/Complex.cs | 12 +- .../System.Runtime/ref/System.Runtime.cs | 219 ++++++++++-------- .../System/Numerics/GenericMathDimHelpers.cs | 6 +- 60 files changed, 340 insertions(+), 280 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Byte.cs b/src/libraries/System.Private.CoreLib/src/System/Byte.cs index 6541d1a1f8cf0..2a45415301196 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Byte.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Byte.cs @@ -920,7 +920,7 @@ private static bool TryConvertFromTruncating(TOther value, out byte resu /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToChecked(byte value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToChecked(byte value, [MaybeNullWhen(false)] out TOther result) { // In order to reduce overall code duplication and improve the inlinabilty of these // methods for the corelib types we have `ConvertFrom` handle the same sign and @@ -987,14 +987,14 @@ static bool INumberBase.TryConvertToChecked(byte value, [NotNullWh } else { - result = default!; + result = default; return false; } } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToSaturating(byte value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToSaturating(byte value, [MaybeNullWhen(false)] out TOther result) { // In order to reduce overall code duplication and improve the inlinabilty of these // methods for the corelib types we have `ConvertFrom` handle the same sign and @@ -1061,14 +1061,14 @@ static bool INumberBase.TryConvertToSaturating(byte value, [NotNul } else { - result = default!; + result = default; return false; } } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToTruncating(byte value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToTruncating(byte value, [MaybeNullWhen(false)] out TOther result) { // In order to reduce overall code duplication and improve the inlinabilty of these // methods for the corelib types we have `ConvertFrom` handle the same sign and @@ -1135,7 +1135,7 @@ static bool INumberBase.TryConvertToTruncating(byte value, [NotNul } else { - result = default!; + result = default; return false; } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Char.cs b/src/libraries/System.Private.CoreLib/src/System/Char.cs index b93226bb9778e..d506f503d48be 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Char.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Char.cs @@ -1715,7 +1715,7 @@ static bool INumberBase.TryConvertFromTruncating(TOther value, out /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToChecked(char value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToChecked(char value, [MaybeNullWhen(false)] out TOther result) { // In order to reduce overall code duplication and improve the inlinabilty of these // methods for the corelib types we have `ConvertFrom` handle the same sign and @@ -1782,14 +1782,14 @@ static bool INumberBase.TryConvertToChecked(char value, [NotNullWh } else { - result = default!; + result = default; return false; } } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToSaturating(char value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToSaturating(char value, [MaybeNullWhen(false)] out TOther result) { // In order to reduce overall code duplication and improve the inlinabilty of these // methods for the corelib types we have `ConvertFrom` handle the same sign and @@ -1856,14 +1856,14 @@ static bool INumberBase.TryConvertToSaturating(char value, [NotNul } else { - result = default!; + result = default; return false; } } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToTruncating(char value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToTruncating(char value, [MaybeNullWhen(false)] out TOther result) { // In order to reduce overall code duplication and improve the inlinabilty of these // methods for the corelib types we have `ConvertFrom` handle the same sign and @@ -1930,7 +1930,7 @@ static bool INumberBase.TryConvertToTruncating(char value, [NotNul } else { - result = default!; + result = default; return false; } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Collections/Concurrent/ConcurrentQueue.cs b/src/libraries/System.Private.CoreLib/src/System/Collections/Concurrent/ConcurrentQueue.cs index 7a49887d17c28..3fa2f71ade78f 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Collections/Concurrent/ConcurrentQueue.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Collections/Concurrent/ConcurrentQueue.cs @@ -683,7 +683,7 @@ public bool TryDequeue([MaybeNullWhen(false)] out T result) // check and this check, another item could have arrived). if (head._nextSegment == null) { - result = default!; + result = default; return false; } diff --git a/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/Queue.cs b/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/Queue.cs index e9f9f6c307f98..7a793902166a0 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/Queue.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/Queue.cs @@ -231,7 +231,7 @@ public bool TryDequeue([MaybeNullWhen(false)] out T result) if (_size == 0) { - result = default!; + result = default; return false; } @@ -263,7 +263,7 @@ public bool TryPeek([MaybeNullWhen(false)] out T result) { if (_size == 0) { - result = default!; + result = default; return false; } diff --git a/src/libraries/System.Private.CoreLib/src/System/Decimal.cs b/src/libraries/System.Private.CoreLib/src/System/Decimal.cs index 5436baebfdc57..8b469e385b13d 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Decimal.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Decimal.cs @@ -1645,7 +1645,7 @@ private static bool TryConvertFrom(TOther value, out decimal result) /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToChecked(decimal value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToChecked(decimal value, [MaybeNullWhen(false)] out TOther result) { // In order to reduce overall code duplication and improve the inlinabilty of these // methods for the corelib types we have `ConvertFrom` handle the same sign and @@ -1712,26 +1712,26 @@ static bool INumberBase.TryConvertToChecked(decimal value, [Not } else { - result = default!; + result = default; return false; } } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToSaturating(decimal value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToSaturating(decimal value, [MaybeNullWhen(false)] out TOther result) { return TryConvertTo(value, out result); } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToTruncating(decimal value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToTruncating(decimal value, [MaybeNullWhen(false)] out TOther result) { return TryConvertTo(value, out result); } - private static bool TryConvertTo(decimal value, [NotNullWhen(true)] out TOther result) + private static bool TryConvertTo(decimal value, [MaybeNullWhen(false)] out TOther result) where TOther : INumberBase { // In order to reduce overall code duplication and improve the inlinabilty of these @@ -1804,7 +1804,7 @@ private static bool TryConvertTo(decimal value, [NotNullWhen(true)] out } else { - result = default!; + result = default; return false; } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Double.cs b/src/libraries/System.Private.CoreLib/src/System/Double.cs index 177eb912575ed..75580d6a88c8b 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Double.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Double.cs @@ -1243,7 +1243,7 @@ private static bool TryConvertFrom(TOther value, out double result) /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToChecked(double value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToChecked(double value, [MaybeNullWhen(false)] out TOther result) { // In order to reduce overall code duplication and improve the inlinabilty of these // methods for the corelib types we have `ConvertFrom` handle the same sign and @@ -1304,26 +1304,26 @@ static bool INumberBase.TryConvertToChecked(double value, [NotNu } else { - result = default!; + result = default; return false; } } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToSaturating(double value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToSaturating(double value, [MaybeNullWhen(false)] out TOther result) { return TryConvertTo(value, out result); } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToTruncating(double value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToTruncating(double value, [MaybeNullWhen(false)] out TOther result) { return TryConvertTo(value, out result); } - private static bool TryConvertTo(double value, [NotNullWhen(true)] out TOther result) + private static bool TryConvertTo(double value, [MaybeNullWhen(false)] out TOther result) where TOther : INumberBase { // In order to reduce overall code duplication and improve the inlinabilty of these @@ -1402,7 +1402,7 @@ private static bool TryConvertTo(double value, [NotNullWhen(true)] out T } else { - result = default!; + result = default; return false; } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Half.cs b/src/libraries/System.Private.CoreLib/src/System/Half.cs index ba931c1f93cec..ecab10dbc00d6 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Half.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Half.cs @@ -1727,7 +1727,7 @@ private static bool TryConvertFrom(TOther value, out Half result) /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToChecked(Half value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToChecked(Half value, [MaybeNullWhen(false)] out TOther result) { // In order to reduce overall code duplication and improve the inlinabilty of these // methods for the corelib types we have `ConvertFrom` handle the same sign and @@ -1788,26 +1788,26 @@ static bool INumberBase.TryConvertToChecked(Half value, [NotNullWh } else { - result = default!; + result = default; return false; } } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToSaturating(Half value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToSaturating(Half value, [MaybeNullWhen(false)] out TOther result) { return TryConvertTo(value, out result); } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToTruncating(Half value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToTruncating(Half value, [MaybeNullWhen(false)] out TOther result) { return TryConvertTo(value, out result); } - private static bool TryConvertTo(Half value, [NotNullWhen(true)] out TOther result) + private static bool TryConvertTo(Half value, [MaybeNullWhen(false)] out TOther result) where TOther : INumberBase { // In order to reduce overall code duplication and improve the inlinabilty of these @@ -1879,7 +1879,7 @@ private static bool TryConvertTo(Half value, [NotNullWhen(true)] out TOt } else { - result = default!; + result = default; return false; } } diff --git a/src/libraries/System.Private.CoreLib/src/System/IParsable.cs b/src/libraries/System.Private.CoreLib/src/System/IParsable.cs index af220483d640e..e2891fbd68947 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IParsable.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IParsable.cs @@ -8,7 +8,7 @@ namespace System /// Defines a mechanism for parsing a string to a value. /// The type that implements this interface. public interface IParsable - where TSelf : IParsable + where TSelf : IParsable? { /// Parses a string into a value. /// The string to parse. diff --git a/src/libraries/System.Private.CoreLib/src/System/ISpanParsable.cs b/src/libraries/System.Private.CoreLib/src/System/ISpanParsable.cs index 8ad117cfa4c6e..2e24d5173e2fb 100644 --- a/src/libraries/System.Private.CoreLib/src/System/ISpanParsable.cs +++ b/src/libraries/System.Private.CoreLib/src/System/ISpanParsable.cs @@ -8,7 +8,7 @@ namespace System /// Defines a mechanism for parsing a span of characters to a value. /// The type that implements this interface. public interface ISpanParsable : IParsable - where TSelf : ISpanParsable + where TSelf : ISpanParsable? { /// Parses a span of characters into a value. /// The span of characters to parse. diff --git a/src/libraries/System.Private.CoreLib/src/System/Int128.cs b/src/libraries/System.Private.CoreLib/src/System/Int128.cs index b67d6e89a7006..d66655060f3e1 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Int128.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Int128.cs @@ -1865,7 +1865,7 @@ private static bool TryConvertFromTruncating(TOther value, out Int128 re /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToChecked(Int128 value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToChecked(Int128 value, [MaybeNullWhen(false)] out TOther result) { // In order to reduce overall code duplication and improve the inlinabilty of these // methods for the corelib types we have `ConvertFrom` handle the same sign and @@ -1926,14 +1926,14 @@ static bool INumberBase.TryConvertToChecked(Int128 value, [NotNu } else { - result = default!; + result = default; return false; } } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToSaturating(Int128 value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToSaturating(Int128 value, [MaybeNullWhen(false)] out TOther result) { // In order to reduce overall code duplication and improve the inlinabilty of these // methods for the corelib types we have `ConvertFrom` handle the same sign and @@ -2000,14 +2000,14 @@ static bool INumberBase.TryConvertToSaturating(Int128 value, [No } else { - result = default!; + result = default; return false; } } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToTruncating(Int128 value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToTruncating(Int128 value, [MaybeNullWhen(false)] out TOther result) { // In order to reduce overall code duplication and improve the inlinabilty of these // methods for the corelib types we have `ConvertFrom` handle the same sign and @@ -2069,7 +2069,7 @@ static bool INumberBase.TryConvertToTruncating(Int128 value, [No } else { - result = default!; + result = default; return false; } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Int16.cs b/src/libraries/System.Private.CoreLib/src/System/Int16.cs index a357d272360fa..94fe0e4844f08 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Int16.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Int16.cs @@ -1148,7 +1148,7 @@ private static bool TryConvertFromTruncating(TOther value, out short res /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToChecked(short value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToChecked(short value, [MaybeNullWhen(false)] out TOther result) { // In order to reduce overall code duplication and improve the inlinabilty of these // methods for the corelib types we have `ConvertFrom` handle the same sign and @@ -1209,14 +1209,14 @@ static bool INumberBase.TryConvertToChecked(short value, [NotNull } else { - result = default!; + result = default; return false; } } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToSaturating(short value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToSaturating(short value, [MaybeNullWhen(false)] out TOther result) { // In order to reduce overall code duplication and improve the inlinabilty of these // methods for the corelib types we have `ConvertFrom` handle the same sign and @@ -1278,14 +1278,14 @@ static bool INumberBase.TryConvertToSaturating(short value, [NotN } else { - result = default!; + result = default; return false; } } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToTruncating(short value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToTruncating(short value, [MaybeNullWhen(false)] out TOther result) { // In order to reduce overall code duplication and improve the inlinabilty of these // methods for the corelib types we have `ConvertFrom` handle the same sign and @@ -1346,7 +1346,7 @@ static bool INumberBase.TryConvertToTruncating(short value, [NotN } else { - result = default!; + result = default; return false; } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Int32.cs b/src/libraries/System.Private.CoreLib/src/System/Int32.cs index 317c789c7d676..7b7c3f2765fb1 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Int32.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Int32.cs @@ -1158,7 +1158,7 @@ private static bool TryConvertFromTruncating(TOther value, out int resul /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToChecked(int value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToChecked(int value, [MaybeNullWhen(false)] out TOther result) { // In order to reduce overall code duplication and improve the inlinabilty of these // methods for the corelib types we have `ConvertFrom` handle the same sign and @@ -1219,14 +1219,14 @@ static bool INumberBase.TryConvertToChecked(int value, [NotNullWhen } else { - result = default!; + result = default; return false; } } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToSaturating(int value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToSaturating(int value, [MaybeNullWhen(false)] out TOther result) { // In order to reduce overall code duplication and improve the inlinabilty of these // methods for the corelib types we have `ConvertFrom` handle the same sign and @@ -1290,14 +1290,14 @@ static bool INumberBase.TryConvertToSaturating(int value, [NotNullW } else { - result = default!; + result = default; return false; } } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToTruncating(int value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToTruncating(int value, [MaybeNullWhen(false)] out TOther result) { // In order to reduce overall code duplication and improve the inlinabilty of these // methods for the corelib types we have `ConvertFrom` handle the same sign and @@ -1358,7 +1358,7 @@ static bool INumberBase.TryConvertToTruncating(int value, [NotNullW } else { - result = default!; + result = default; return false; } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Int64.cs b/src/libraries/System.Private.CoreLib/src/System/Int64.cs index 569240329da35..8752d93c2f837 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Int64.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Int64.cs @@ -1143,7 +1143,7 @@ private static bool TryConvertFromTruncating(TOther value, out long resu /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToChecked(long value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToChecked(long value, [MaybeNullWhen(false)] out TOther result) { // In order to reduce overall code duplication and improve the inlinabilty of these // methods for the corelib types we have `ConvertFrom` handle the same sign and @@ -1204,14 +1204,14 @@ static bool INumberBase.TryConvertToChecked(long value, [NotNullWh } else { - result = default!; + result = default; return false; } } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToSaturating(long value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToSaturating(long value, [MaybeNullWhen(false)] out TOther result) { // In order to reduce overall code duplication and improve the inlinabilty of these // methods for the corelib types we have `ConvertFrom` handle the same sign and @@ -1283,14 +1283,14 @@ static bool INumberBase.TryConvertToSaturating(long value, [NotNul } else { - result = default!; + result = default; return false; } } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToTruncating(long value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToTruncating(long value, [MaybeNullWhen(false)] out TOther result) { // In order to reduce overall code duplication and improve the inlinabilty of these // methods for the corelib types we have `ConvertFrom` handle the same sign and @@ -1351,7 +1351,7 @@ static bool INumberBase.TryConvertToTruncating(long value, [NotNul } else { - result = default!; + result = default; return false; } } diff --git a/src/libraries/System.Private.CoreLib/src/System/IntPtr.cs b/src/libraries/System.Private.CoreLib/src/System/IntPtr.cs index 9f6b414343b15..3fbed0cea3520 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IntPtr.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IntPtr.cs @@ -1117,7 +1117,7 @@ private static bool TryConvertFromTruncating(TOther value, out nint resu /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToChecked(nint value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToChecked(nint value, [MaybeNullWhen(false)] out TOther result) { // In order to reduce overall code duplication and improve the inlinabilty of these // methods for the corelib types we have `ConvertFrom` handle the same sign and @@ -1178,14 +1178,14 @@ static bool INumberBase.TryConvertToChecked(nint value, [NotNullWh } else { - result = default!; + result = default; return false; } } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToSaturating(nint value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToSaturating(nint value, [MaybeNullWhen(false)] out TOther result) { // In order to reduce overall code duplication and improve the inlinabilty of these // methods for the corelib types we have `ConvertFrom` handle the same sign and @@ -1250,14 +1250,14 @@ static bool INumberBase.TryConvertToSaturating(nint value, [NotNul } else { - result = default!; + result = default; return false; } } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToTruncating(nint value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToTruncating(nint value, [MaybeNullWhen(false)] out TOther result) { // In order to reduce overall code duplication and improve the inlinabilty of these // methods for the corelib types we have `ConvertFrom` handle the same sign and @@ -1318,7 +1318,7 @@ static bool INumberBase.TryConvertToTruncating(nint value, [NotNul } else { - result = default!; + result = default; return false; } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Numerics/IAdditionOperators.cs b/src/libraries/System.Private.CoreLib/src/System/Numerics/IAdditionOperators.cs index ca11868381a29..ecdfe953a0c8c 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Numerics/IAdditionOperators.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Numerics/IAdditionOperators.cs @@ -8,7 +8,7 @@ namespace System.Numerics /// The type that will be added to . /// The type that contains the sum of and . public interface IAdditionOperators - where TSelf : IAdditionOperators + where TSelf : IAdditionOperators? { /// Adds two values together to compute their sum. /// The value to which is added. diff --git a/src/libraries/System.Private.CoreLib/src/System/Numerics/IAdditiveIdentity.cs b/src/libraries/System.Private.CoreLib/src/System/Numerics/IAdditiveIdentity.cs index 1e95b5fb35cc8..be11ca7e2fbf7 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Numerics/IAdditiveIdentity.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Numerics/IAdditiveIdentity.cs @@ -7,7 +7,7 @@ namespace System.Numerics /// The type that implements this interface. /// The type that contains the additive identify of . public interface IAdditiveIdentity - where TSelf : IAdditiveIdentity + where TSelf : IAdditiveIdentity? { /// Gets the additive identity of the current type. static abstract TResult AdditiveIdentity { get; } diff --git a/src/libraries/System.Private.CoreLib/src/System/Numerics/IBinaryFloatingPointIeee754.cs b/src/libraries/System.Private.CoreLib/src/System/Numerics/IBinaryFloatingPointIeee754.cs index 7e6565579d4ff..151ae4c11d082 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Numerics/IBinaryFloatingPointIeee754.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Numerics/IBinaryFloatingPointIeee754.cs @@ -8,7 +8,7 @@ namespace System.Numerics public interface IBinaryFloatingPointIeee754 : IBinaryNumber, IFloatingPointIeee754 - where TSelf : IBinaryFloatingPointIeee754 + where TSelf : IBinaryFloatingPointIeee754? { } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Numerics/IBinaryInteger.cs b/src/libraries/System.Private.CoreLib/src/System/Numerics/IBinaryInteger.cs index e182d35b04246..067d6c338384e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Numerics/IBinaryInteger.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Numerics/IBinaryInteger.cs @@ -8,7 +8,7 @@ namespace System.Numerics public interface IBinaryInteger : IBinaryNumber, IShiftOperators - where TSelf : IBinaryInteger + where TSelf : IBinaryInteger? { /// Computes the quotient and remainder of two values. /// The value which divides. @@ -25,7 +25,12 @@ static virtual (TSelf Quotient, TSelf Remainder) DivRem(TSelf left, TSelf right) /// The number of leading zeros in . static virtual TSelf LeadingZeroCount(TSelf value) { - TSelf bitCount = TSelf.CreateChecked(value.GetByteCount() * 8L); + if (!typeof(TSelf).IsValueType) + { + ArgumentNullException.ThrowIfNull(value); + } + + TSelf bitCount = TSelf.CreateChecked(value!.GetByteCount() * 8L); if (value == TSelf.Zero) { @@ -132,7 +137,12 @@ static virtual TSelf ReadLittleEndian(ReadOnlySpan source, bool isUnsigned /// The result of rotating left by . static virtual TSelf RotateLeft(TSelf value, int rotateAmount) { - int bitCount = checked(value.GetByteCount() * 8); + if (!typeof(TSelf).IsValueType) + { + ArgumentNullException.ThrowIfNull(value); + } + + int bitCount = checked(value!.GetByteCount() * 8); return (value << rotateAmount) | (value >> (bitCount - rotateAmount)); } @@ -142,7 +152,12 @@ static virtual TSelf RotateLeft(TSelf value, int rotateAmount) /// The result of rotating right by . static virtual TSelf RotateRight(TSelf value, int rotateAmount) { - int bitCount = checked(value.GetByteCount() * 8); + if (!typeof(TSelf).IsValueType) + { + ArgumentNullException.ThrowIfNull(value); + } + + int bitCount = checked(value!.GetByteCount() * 8); return (value >> rotateAmount) | (value << (bitCount - rotateAmount)); } diff --git a/src/libraries/System.Private.CoreLib/src/System/Numerics/IBinaryNumber.cs b/src/libraries/System.Private.CoreLib/src/System/Numerics/IBinaryNumber.cs index 9b45fb59cc73b..5dbe5bc957609 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Numerics/IBinaryNumber.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Numerics/IBinaryNumber.cs @@ -8,7 +8,7 @@ namespace System.Numerics public interface IBinaryNumber : IBitwiseOperators, INumber - where TSelf : IBinaryNumber + where TSelf : IBinaryNumber? { /// Gets an instance of the binary type in which all bits are set. static virtual TSelf AllBitsSet => ~TSelf.Zero; diff --git a/src/libraries/System.Private.CoreLib/src/System/Numerics/IBitwiseOperators.cs b/src/libraries/System.Private.CoreLib/src/System/Numerics/IBitwiseOperators.cs index 15a7aa311f642..36399a1b6d96c 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Numerics/IBitwiseOperators.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Numerics/IBitwiseOperators.cs @@ -8,7 +8,7 @@ namespace System.Numerics /// The type that will is used in the operation with . /// The type that contains the result of op . public interface IBitwiseOperators - where TSelf : IBitwiseOperators + where TSelf : IBitwiseOperators? { /// Computes the bitwise-and of two values. /// The value to and with . diff --git a/src/libraries/System.Private.CoreLib/src/System/Numerics/IComparisonOperators.cs b/src/libraries/System.Private.CoreLib/src/System/Numerics/IComparisonOperators.cs index d6b8883aa718c..474ea46e7f656 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Numerics/IComparisonOperators.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Numerics/IComparisonOperators.cs @@ -9,7 +9,7 @@ namespace System.Numerics /// The type that is returned as a result of the comparison. public interface IComparisonOperators : IEqualityOperators - where TSelf : IComparisonOperators + where TSelf : IComparisonOperators? { /// Compares two values to determine which is less. /// The value to compare with . diff --git a/src/libraries/System.Private.CoreLib/src/System/Numerics/IDecrementOperators.cs b/src/libraries/System.Private.CoreLib/src/System/Numerics/IDecrementOperators.cs index 159ad6bc44e2d..edc0022c58447 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Numerics/IDecrementOperators.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Numerics/IDecrementOperators.cs @@ -6,7 +6,7 @@ namespace System.Numerics /// Defines a mechanism for decrementing a given value. /// The type that implements this interface. public interface IDecrementOperators - where TSelf : IDecrementOperators + where TSelf : IDecrementOperators? { /// Decrements a value. /// The value to decrement. diff --git a/src/libraries/System.Private.CoreLib/src/System/Numerics/IDivisionOperators.cs b/src/libraries/System.Private.CoreLib/src/System/Numerics/IDivisionOperators.cs index a8ed07a633591..20535020efcd7 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Numerics/IDivisionOperators.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Numerics/IDivisionOperators.cs @@ -8,7 +8,7 @@ namespace System.Numerics /// The type that will divide . /// The type that contains the quotient of and . public interface IDivisionOperators - where TSelf : IDivisionOperators + where TSelf : IDivisionOperators? { /// Divides two values together to compute their quotient. /// The value which divides. diff --git a/src/libraries/System.Private.CoreLib/src/System/Numerics/IEqualityOperators.cs b/src/libraries/System.Private.CoreLib/src/System/Numerics/IEqualityOperators.cs index 397e4489aefbe..ebf11d8576e4e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Numerics/IEqualityOperators.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Numerics/IEqualityOperators.cs @@ -8,18 +8,18 @@ namespace System.Numerics /// The type that will be compared with . /// The type that is returned as a result of the comparison. public interface IEqualityOperators - where TSelf : IEqualityOperators + where TSelf : IEqualityOperators? { /// Compares two values to determine equality. /// The value to compare with . /// The value to compare with . /// true if is equal to ; otherwise, false. - static abstract TResult operator ==(TSelf left, TOther right); + static abstract TResult operator ==(TSelf? left, TOther? right); /// Compares two values to determine inequality. /// The value to compare with . /// The value to compare with . /// true if is not equal to ; otherwise, false. - static abstract TResult operator !=(TSelf left, TOther right); + static abstract TResult operator !=(TSelf? left, TOther? right); } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Numerics/IExponentialFunctions.cs b/src/libraries/System.Private.CoreLib/src/System/Numerics/IExponentialFunctions.cs index 85660ab3ba3c8..f7370ff4708fb 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Numerics/IExponentialFunctions.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Numerics/IExponentialFunctions.cs @@ -7,7 +7,7 @@ namespace System.Numerics /// The type that implements this interface. public interface IExponentialFunctions : IFloatingPointConstants - where TSelf : IExponentialFunctions + where TSelf : IExponentialFunctions? { /// Computes E raised to a given power. /// The power to which E is raised. diff --git a/src/libraries/System.Private.CoreLib/src/System/Numerics/IFloatingPoint.cs b/src/libraries/System.Private.CoreLib/src/System/Numerics/IFloatingPoint.cs index 9b5f975754361..0abcc40ebbbd3 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Numerics/IFloatingPoint.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Numerics/IFloatingPoint.cs @@ -9,7 +9,7 @@ public interface IFloatingPoint : IFloatingPointConstants, INumber, ISignedNumber - where TSelf : IFloatingPoint + where TSelf : IFloatingPoint? { /// Computes the ceiling of a value. /// The value whose ceiling is to be computed. diff --git a/src/libraries/System.Private.CoreLib/src/System/Numerics/IFloatingPointConstants.cs b/src/libraries/System.Private.CoreLib/src/System/Numerics/IFloatingPointConstants.cs index 7bb8bbd229bd1..1ab2d6a4ed55f 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Numerics/IFloatingPointConstants.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Numerics/IFloatingPointConstants.cs @@ -7,7 +7,7 @@ namespace System.Numerics /// The type that implements the interface. public interface IFloatingPointConstants : INumberBase - where TSelf : IFloatingPointConstants + where TSelf : IFloatingPointConstants? { /// Gets the mathematical constant e. static abstract TSelf E { get; } diff --git a/src/libraries/System.Private.CoreLib/src/System/Numerics/IFloatingPointIeee754.cs b/src/libraries/System.Private.CoreLib/src/System/Numerics/IFloatingPointIeee754.cs index 7d9e33c994957..35d7b42cd7931 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Numerics/IFloatingPointIeee754.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Numerics/IFloatingPointIeee754.cs @@ -13,7 +13,7 @@ public interface IFloatingPointIeee754 IPowerFunctions, IRootFunctions, ITrigonometricFunctions - where TSelf : IFloatingPointIeee754 + where TSelf : IFloatingPointIeee754? { /// Gets the smallest value such that can be added to 0 that does not result in 0. static abstract TSelf Epsilon { get; } diff --git a/src/libraries/System.Private.CoreLib/src/System/Numerics/IHyperbolicFunctions.cs b/src/libraries/System.Private.CoreLib/src/System/Numerics/IHyperbolicFunctions.cs index 3fe24e7ef6eba..8929a539145d6 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Numerics/IHyperbolicFunctions.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Numerics/IHyperbolicFunctions.cs @@ -7,7 +7,7 @@ namespace System.Numerics /// The type that implements this interface. public interface IHyperbolicFunctions : IFloatingPointConstants - where TSelf : IHyperbolicFunctions + where TSelf : IHyperbolicFunctions? { /// Computes the hyperbolic arc-cosine of a value. /// The value, in radians, whose hyperbolic arc-cosine is to be computed. diff --git a/src/libraries/System.Private.CoreLib/src/System/Numerics/IIncrementOperators.cs b/src/libraries/System.Private.CoreLib/src/System/Numerics/IIncrementOperators.cs index 9024a4a6615ac..9dc434e4c4252 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Numerics/IIncrementOperators.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Numerics/IIncrementOperators.cs @@ -6,7 +6,7 @@ namespace System.Numerics /// Defines a mechanism for incrementing a given value. /// The type that implements this interface. public interface IIncrementOperators - where TSelf : IIncrementOperators + where TSelf : IIncrementOperators? { /// Increments a value. /// The value to increment. diff --git a/src/libraries/System.Private.CoreLib/src/System/Numerics/ILogarithmicFunctions.cs b/src/libraries/System.Private.CoreLib/src/System/Numerics/ILogarithmicFunctions.cs index 668a8b42d1d1f..343327946e423 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Numerics/ILogarithmicFunctions.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Numerics/ILogarithmicFunctions.cs @@ -7,7 +7,7 @@ namespace System.Numerics /// The type that implements this interface. public interface ILogarithmicFunctions : IFloatingPointConstants - where TSelf : ILogarithmicFunctions + where TSelf : ILogarithmicFunctions? { /// Computes the natural (base-E) logarithm of a value. /// The value whose natural logarithm is to be computed. diff --git a/src/libraries/System.Private.CoreLib/src/System/Numerics/IMinMaxValue.cs b/src/libraries/System.Private.CoreLib/src/System/Numerics/IMinMaxValue.cs index fe424d1aa6733..aabfdd10a9fba 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Numerics/IMinMaxValue.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Numerics/IMinMaxValue.cs @@ -6,7 +6,7 @@ namespace System.Numerics /// Defines a mechanism for getting the minimum and maximum value of a type. /// The type that implements this interface. public interface IMinMaxValue - where TSelf : IMinMaxValue + where TSelf : IMinMaxValue? { /// Gets the minimum value of the current type. static abstract TSelf MinValue { get; } diff --git a/src/libraries/System.Private.CoreLib/src/System/Numerics/IModulusOperators.cs b/src/libraries/System.Private.CoreLib/src/System/Numerics/IModulusOperators.cs index fae966ef0be18..772241f9f1686 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Numerics/IModulusOperators.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Numerics/IModulusOperators.cs @@ -9,7 +9,7 @@ namespace System.Numerics /// The type that contains the modulus or remainder of and . /// This type represents the % in C# which is often used to compute the remainder and may differ from an actual modulo operation depending on the type that implements the interface. public interface IModulusOperators - where TSelf : IModulusOperators + where TSelf : IModulusOperators? { /// Divides two values together to compute their modulus or remainder. /// The value which divides. diff --git a/src/libraries/System.Private.CoreLib/src/System/Numerics/IMultiplicativeIdentity.cs b/src/libraries/System.Private.CoreLib/src/System/Numerics/IMultiplicativeIdentity.cs index fa087d0d8a967..32c7c40db8c91 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Numerics/IMultiplicativeIdentity.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Numerics/IMultiplicativeIdentity.cs @@ -7,7 +7,7 @@ namespace System.Numerics /// The type that implements this interface. /// The type that contains the multiplicative identify of . public interface IMultiplicativeIdentity - where TSelf : IMultiplicativeIdentity + where TSelf : IMultiplicativeIdentity? { /// Gets the multiplicative identity of the current type. static abstract TResult MultiplicativeIdentity { get; } diff --git a/src/libraries/System.Private.CoreLib/src/System/Numerics/IMultiplyOperators.cs b/src/libraries/System.Private.CoreLib/src/System/Numerics/IMultiplyOperators.cs index a3e4d52ec42b8..e93e3d466823c 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Numerics/IMultiplyOperators.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Numerics/IMultiplyOperators.cs @@ -8,7 +8,7 @@ namespace System.Numerics /// The type that will multiply . /// The type that contains the product of and . public interface IMultiplyOperators - where TSelf : IMultiplyOperators + where TSelf : IMultiplyOperators? { /// Multiplies two values together to compute their product. /// The value which multiplies. diff --git a/src/libraries/System.Private.CoreLib/src/System/Numerics/INumber.cs b/src/libraries/System.Private.CoreLib/src/System/Numerics/INumber.cs index a3413ee78641e..e41d0b999850b 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Numerics/INumber.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Numerics/INumber.cs @@ -14,7 +14,7 @@ public interface INumber IComparisonOperators, IModulusOperators, INumberBase - where TSelf : INumber + where TSelf : INumber? { /// Clamps a value to an inclusive minimum and maximum value. /// The value to clamp. diff --git a/src/libraries/System.Private.CoreLib/src/System/Numerics/INumberBase.cs b/src/libraries/System.Private.CoreLib/src/System/Numerics/INumberBase.cs index ed159927d5d33..7bc025bf806ce 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Numerics/INumberBase.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Numerics/INumberBase.cs @@ -24,7 +24,7 @@ public interface INumberBase ISubtractionOperators, IUnaryPlusOperators, IUnaryNegationOperators - where TSelf : INumberBase + where TSelf : INumberBase? { /// Gets the value 1 for the type. static abstract TSelf One { get; } @@ -49,7 +49,9 @@ public interface INumberBase /// is not representable by . [MethodImpl(MethodImplOptions.AggressiveInlining)] static virtual TSelf CreateChecked(TOther value) +#nullable disable where TOther : INumberBase +#nullable restore { TSelf? result; @@ -57,7 +59,7 @@ static virtual TSelf CreateChecked(TOther value) { result = (TSelf)(object)value; } - else if (!TSelf.TryConvertFromChecked(value, out result) && !TOther.TryConvertToChecked(value, out result)) + else if (!TSelf.TryConvertFromChecked(value, out result) && !TOther.TryConvertToChecked(value, out result)) { ThrowHelper.ThrowNotSupportedException(); } @@ -72,7 +74,9 @@ static virtual TSelf CreateChecked(TOther value) /// is not supported. [MethodImpl(MethodImplOptions.AggressiveInlining)] static virtual TSelf CreateSaturating(TOther value) +#nullable disable where TOther : INumberBase +#nullable restore { TSelf? result; @@ -80,7 +84,7 @@ static virtual TSelf CreateSaturating(TOther value) { result = (TSelf)(object)value; } - else if (!TSelf.TryConvertFromSaturating(value, out result) && !TOther.TryConvertToSaturating(value, out result)) + else if (!TSelf.TryConvertFromSaturating(value, out result) && !TOther.TryConvertToSaturating(value, out result)) { ThrowHelper.ThrowNotSupportedException(); } @@ -95,7 +99,9 @@ static virtual TSelf CreateSaturating(TOther value) /// is not supported. [MethodImpl(MethodImplOptions.AggressiveInlining)] static virtual TSelf CreateTruncating(TOther value) +#nullable disable where TOther : INumberBase +#nullable restore { TSelf? result; @@ -103,7 +109,7 @@ static virtual TSelf CreateTruncating(TOther value) { result = (TSelf)(object)value; } - else if (!TSelf.TryConvertFromTruncating(value, out result) && !TOther.TryConvertToTruncating(value, out result)) + else if (!TSelf.TryConvertFromTruncating(value, out result) && !TOther.TryConvertToTruncating(value, out result)) { ThrowHelper.ThrowNotSupportedException(); } @@ -268,24 +274,30 @@ static virtual TSelf CreateTruncating(TOther value) /// On return, contains an instance of converted from . /// false if is not supported; otherwise, true. /// is not representable by . - protected static abstract bool TryConvertFromChecked(TOther value, [NotNullWhen(true)] out TSelf? result) + protected static abstract bool TryConvertFromChecked(TOther value, [MaybeNullWhen(false)] out TSelf result) +#nullable disable where TOther : INumberBase; +#nullable restore /// Tries to convert a value to an instance of the current type, saturating any values that fall outside the representable range of the current type. /// The type of . /// The value which is used to create the instance of . /// On return, contains an instance of converted from . /// false if is not supported; otherwise, true. - protected static abstract bool TryConvertFromSaturating(TOther value, [NotNullWhen(true)] out TSelf? result) + protected static abstract bool TryConvertFromSaturating(TOther value, [MaybeNullWhen(false)] out TSelf result) +#nullable disable where TOther : INumberBase; +#nullable restore /// Tries to convert a value to an instance of the current type, truncating any values that fall outside the representable range of the current type. /// The type of . /// The value which is used to create the instance of . /// On return, contains an instance of converted from . /// false if is not supported; otherwise, true. - protected static abstract bool TryConvertFromTruncating(TOther value, [NotNullWhen(true)] out TSelf? result) + protected static abstract bool TryConvertFromTruncating(TOther value, [MaybeNullWhen(false)] out TSelf result) +#nullable disable where TOther : INumberBase; +#nullable restore /// Tries to convert an instance of the current type to another type, throwing an overflow exception for any values that fall outside the representable range of the current type. /// The type to which should be converted. @@ -293,24 +305,30 @@ protected static abstract bool TryConvertFromTruncating(TOther value, [N /// On return, contains an instance of converted from . /// false if is not supported; otherwise, true. /// is not representable by . - protected static abstract bool TryConvertToChecked(TSelf value, [NotNullWhen(true)] out TOther? result) + protected static abstract bool TryConvertToChecked(TSelf value, [MaybeNullWhen(false)] out TOther result) +#nullable disable where TOther : INumberBase; +#nullable restore /// Tries to convert an instance of the current type to another type, saturating any values that fall outside the representable range of the current type. /// The type to which should be converted. /// The value which is used to create the instance of . /// On return, contains an instance of converted from . /// false if is not supported; otherwise, true. - protected static abstract bool TryConvertToSaturating(TSelf value, [NotNullWhen(true)] out TOther? result) + protected static abstract bool TryConvertToSaturating(TSelf value, [MaybeNullWhen(false)] out TOther result) +#nullable disable where TOther : INumberBase; +#nullable restore /// Tries to convert an instance of the current type to another type, truncating any values that fall outside the representable range of the current type. /// The type to which should be converted. /// The value which is used to create the instance of . /// On return, contains an instance of converted from . /// false if is not supported; otherwise, true. - protected static abstract bool TryConvertToTruncating(TSelf value, [NotNullWhen(true)] out TOther? result) + protected static abstract bool TryConvertToTruncating(TSelf value, [MaybeNullWhen(false)] out TOther result) +#nullable disable where TOther : INumberBase; +#nullable restore /// Tries to parses a string into a value. /// The string to parse. diff --git a/src/libraries/System.Private.CoreLib/src/System/Numerics/IPowerFunctions.cs b/src/libraries/System.Private.CoreLib/src/System/Numerics/IPowerFunctions.cs index 9c37729b6a649..5f054364e4c75 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Numerics/IPowerFunctions.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Numerics/IPowerFunctions.cs @@ -7,7 +7,7 @@ namespace System.Numerics /// The type that implements this interface. public interface IPowerFunctions : INumberBase - where TSelf : IPowerFunctions + where TSelf : IPowerFunctions? { /// Computes a value raised to a given power. /// The value which is raised to the power of . diff --git a/src/libraries/System.Private.CoreLib/src/System/Numerics/IRootFunctions.cs b/src/libraries/System.Private.CoreLib/src/System/Numerics/IRootFunctions.cs index f8eef19b5f6ff..715ab83e5a503 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Numerics/IRootFunctions.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Numerics/IRootFunctions.cs @@ -7,7 +7,7 @@ namespace System.Numerics /// The type that implements this interface. public interface IRootFunctions : IFloatingPointConstants - where TSelf : IRootFunctions + where TSelf : IRootFunctions? { /// Computes the cube-root of a value. /// The value whose cube-root is to be computed. diff --git a/src/libraries/System.Private.CoreLib/src/System/Numerics/IShiftOperators.cs b/src/libraries/System.Private.CoreLib/src/System/Numerics/IShiftOperators.cs index 0ef088e5f5b44..45ccece20b9bd 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Numerics/IShiftOperators.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Numerics/IShiftOperators.cs @@ -8,7 +8,7 @@ namespace System.Numerics /// The type used to specify the amount by which should be shifted. /// The type that contains the result of shifting by . public interface IShiftOperators - where TSelf : IShiftOperators + where TSelf : IShiftOperators? { /// Shifts a value left by a given amount. /// The value which is shifted left by . diff --git a/src/libraries/System.Private.CoreLib/src/System/Numerics/ISignedNumber.cs b/src/libraries/System.Private.CoreLib/src/System/Numerics/ISignedNumber.cs index df1ed28b19563..cc4e9651d5d30 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Numerics/ISignedNumber.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Numerics/ISignedNumber.cs @@ -7,7 +7,7 @@ namespace System.Numerics /// The type that implements the interface. public interface ISignedNumber : INumberBase - where TSelf : ISignedNumber + where TSelf : ISignedNumber? { /// Gets the value -1 for the type. static abstract TSelf NegativeOne { get; } diff --git a/src/libraries/System.Private.CoreLib/src/System/Numerics/ISubtractionOperators.cs b/src/libraries/System.Private.CoreLib/src/System/Numerics/ISubtractionOperators.cs index b79879bef3651..e422900d60496 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Numerics/ISubtractionOperators.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Numerics/ISubtractionOperators.cs @@ -8,7 +8,7 @@ namespace System.Numerics /// The type that will be subtracted from . /// The type that contains the difference of subtracted from . public interface ISubtractionOperators - where TSelf : ISubtractionOperators + where TSelf : ISubtractionOperators? { /// Subtracts two values to compute their difference. /// The value from which is subtracted. diff --git a/src/libraries/System.Private.CoreLib/src/System/Numerics/ITrigonometricFunctions.cs b/src/libraries/System.Private.CoreLib/src/System/Numerics/ITrigonometricFunctions.cs index 8539cd13c5f5e..cac27fad00834 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Numerics/ITrigonometricFunctions.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Numerics/ITrigonometricFunctions.cs @@ -7,7 +7,7 @@ namespace System.Numerics /// The type that implements this interface. public interface ITrigonometricFunctions : IFloatingPointConstants - where TSelf : ITrigonometricFunctions + where TSelf : ITrigonometricFunctions? { /// Computes the arc-cosine of a value. /// The value whose arc-cosine is to be computed. diff --git a/src/libraries/System.Private.CoreLib/src/System/Numerics/IUnaryNegationOperators.cs b/src/libraries/System.Private.CoreLib/src/System/Numerics/IUnaryNegationOperators.cs index 6a8ee11fe07a4..0af4580635cb3 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Numerics/IUnaryNegationOperators.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Numerics/IUnaryNegationOperators.cs @@ -7,7 +7,7 @@ namespace System.Numerics /// The type that implements this interface. /// The type that contains the result of negating . public interface IUnaryNegationOperators - where TSelf : IUnaryNegationOperators + where TSelf : IUnaryNegationOperators? { /// Computes the unary negation of a value. /// The value for which to compute its unary negation. diff --git a/src/libraries/System.Private.CoreLib/src/System/Numerics/IUnaryPlusOperators.cs b/src/libraries/System.Private.CoreLib/src/System/Numerics/IUnaryPlusOperators.cs index 916c5f13fc5b1..5ba2d43f6a94c 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Numerics/IUnaryPlusOperators.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Numerics/IUnaryPlusOperators.cs @@ -7,7 +7,7 @@ namespace System.Numerics /// The type that implements this interface. /// The type that contains the result of negating . public interface IUnaryPlusOperators - where TSelf : IUnaryPlusOperators + where TSelf : IUnaryPlusOperators? { /// Computes the unary plus of a value. /// The value for which to compute its unary plus. diff --git a/src/libraries/System.Private.CoreLib/src/System/Numerics/IUnsignedNumber.cs b/src/libraries/System.Private.CoreLib/src/System/Numerics/IUnsignedNumber.cs index 1cae84b36b7af..d5de09443e2e5 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Numerics/IUnsignedNumber.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Numerics/IUnsignedNumber.cs @@ -7,7 +7,7 @@ namespace System.Numerics /// The type that implements the interface. public interface IUnsignedNumber : INumberBase - where TSelf : IUnsignedNumber + where TSelf : IUnsignedNumber? { } } 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 f312049b82fca..9aeef16dadb4d 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 @@ -1492,14 +1492,14 @@ private static bool TryConvertFrom(TOther value, out NFloat result) } else { - result = default!; + result = default; return false; } } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToChecked(NFloat value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToChecked(NFloat value, [MaybeNullWhen(false)] out TOther result) { if (typeof(TOther) == typeof(byte)) { @@ -1605,26 +1605,26 @@ static bool INumberBase.TryConvertToChecked(NFloat value, [NotNu } else { - result = default!; + result = default; return false; } } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToSaturating(NFloat value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToSaturating(NFloat value, [MaybeNullWhen(false)] out TOther result) { return TryConvertTo(value, out result); } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToTruncating(NFloat value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToTruncating(NFloat value, [MaybeNullWhen(false)] out TOther result) { return TryConvertTo(value, out result); } - private static bool TryConvertTo(NFloat value, [NotNullWhen(true)] out TOther result) + private static bool TryConvertTo(NFloat value, [MaybeNullWhen(false)] out TOther result) where TOther : INumberBase { if (typeof(TOther) == typeof(byte)) @@ -1754,7 +1754,7 @@ private static bool TryConvertTo(NFloat value, [NotNullWhen(true)] out T } else { - result = default!; + result = default; return false; } } diff --git a/src/libraries/System.Private.CoreLib/src/System/SByte.cs b/src/libraries/System.Private.CoreLib/src/System/SByte.cs index 8b9dc686c15a2..afd9b04f08e26 100644 --- a/src/libraries/System.Private.CoreLib/src/System/SByte.cs +++ b/src/libraries/System.Private.CoreLib/src/System/SByte.cs @@ -1114,7 +1114,7 @@ private static bool TryConvertFromTruncating(TOther value, out sbyte res /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToChecked(sbyte value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToChecked(sbyte value, [MaybeNullWhen(false)] out TOther result) { // In order to reduce overall code duplication and improve the inlinabilty of these // methods for the corelib types we have `ConvertFrom` handle the same sign and @@ -1175,14 +1175,14 @@ static bool INumberBase.TryConvertToChecked(sbyte value, [NotNull } else { - result = default!; + result = default; return false; } } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToSaturating(sbyte value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToSaturating(sbyte value, [MaybeNullWhen(false)] out TOther result) { // In order to reduce overall code duplication and improve the inlinabilty of these // methods for the corelib types we have `ConvertFrom` handle the same sign and @@ -1243,14 +1243,14 @@ static bool INumberBase.TryConvertToSaturating(sbyte value, [NotN } else { - result = default!; + result = default; return false; } } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToTruncating(sbyte value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToTruncating(sbyte value, [MaybeNullWhen(false)] out TOther result) { // In order to reduce overall code duplication and improve the inlinabilty of these // methods for the corelib types we have `ConvertFrom` handle the same sign and @@ -1311,7 +1311,7 @@ static bool INumberBase.TryConvertToTruncating(sbyte value, [NotN } else { - result = default!; + result = default; return false; } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Single.cs b/src/libraries/System.Private.CoreLib/src/System/Single.cs index cd31393df23ae..54e1ef148e9f1 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Single.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Single.cs @@ -1223,7 +1223,7 @@ private static bool TryConvertFrom(TOther value, out float result) /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToChecked(float value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToChecked(float value, [MaybeNullWhen(false)] out TOther result) { // In order to reduce overall code duplication and improve the inlinabilty of these // methods for the corelib types we have `ConvertFrom` handle the same sign and @@ -1284,26 +1284,26 @@ static bool INumberBase.TryConvertToChecked(float value, [NotNull } else { - result = default!; + result = default; return false; } } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToSaturating(float value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToSaturating(float value, [MaybeNullWhen(false)] out TOther result) { return TryConvertTo(value, out result); } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToTruncating(float value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToTruncating(float value, [MaybeNullWhen(false)] out TOther result) { return TryConvertTo(value, out result); } - private static bool TryConvertTo(float value, [NotNullWhen(true)] out TOther result) + private static bool TryConvertTo(float value, [MaybeNullWhen(false)] out TOther result) where TOther : INumberBase { // In order to reduce overall code duplication and improve the inlinabilty of these @@ -1382,7 +1382,7 @@ private static bool TryConvertTo(float value, [NotNullWhen(true)] out TO } else { - result = default!; + result = default; return false; } } diff --git a/src/libraries/System.Private.CoreLib/src/System/UInt128.cs b/src/libraries/System.Private.CoreLib/src/System/UInt128.cs index e75cb7f0650af..fb30f2c9996a2 100644 --- a/src/libraries/System.Private.CoreLib/src/System/UInt128.cs +++ b/src/libraries/System.Private.CoreLib/src/System/UInt128.cs @@ -1793,7 +1793,7 @@ private static bool TryConvertFromTruncating(TOther value, out UInt128 r /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToChecked(UInt128 value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToChecked(UInt128 value, [MaybeNullWhen(false)] out TOther result) { // In order to reduce overall code duplication and improve the inlinabilty of these // methods for the corelib types we have `ConvertFrom` handle the same sign and @@ -1860,14 +1860,14 @@ static bool INumberBase.TryConvertToChecked(UInt128 value, [Not } else { - result = default!; + result = default; return false; } } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToSaturating(UInt128 value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToSaturating(UInt128 value, [MaybeNullWhen(false)] out TOther result) { // In order to reduce overall code duplication and improve the inlinabilty of these // methods for the corelib types we have `ConvertFrom` handle the same sign and @@ -1940,14 +1940,14 @@ static bool INumberBase.TryConvertToSaturating(UInt128 value, [ } else { - result = default!; + result = default; return false; } } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToTruncating(UInt128 value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToTruncating(UInt128 value, [MaybeNullWhen(false)] out TOther result) { // In order to reduce overall code duplication and improve the inlinabilty of these // methods for the corelib types we have `ConvertFrom` handle the same sign and @@ -2014,7 +2014,7 @@ static bool INumberBase.TryConvertToTruncating(UInt128 value, [ } else { - result = default!; + result = default; return false; } } diff --git a/src/libraries/System.Private.CoreLib/src/System/UInt16.cs b/src/libraries/System.Private.CoreLib/src/System/UInt16.cs index 19069064d1369..5e50f54f64193 100644 --- a/src/libraries/System.Private.CoreLib/src/System/UInt16.cs +++ b/src/libraries/System.Private.CoreLib/src/System/UInt16.cs @@ -946,7 +946,7 @@ private static bool TryConvertFromTruncating(TOther value, out ushort re /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToChecked(ushort value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToChecked(ushort value, [MaybeNullWhen(false)] out TOther result) { // In order to reduce overall code duplication and improve the inlinabilty of these // methods for the corelib types we have `ConvertFrom` handle the same sign and @@ -1013,14 +1013,14 @@ static bool INumberBase.TryConvertToChecked(ushort value, [NotNu } else { - result = default!; + result = default; return false; } } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToSaturating(ushort value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToSaturating(ushort value, [MaybeNullWhen(false)] out TOther result) { // In order to reduce overall code duplication and improve the inlinabilty of these // methods for the corelib types we have `ConvertFrom` handle the same sign and @@ -1087,14 +1087,14 @@ static bool INumberBase.TryConvertToSaturating(ushort value, [No } else { - result = default!; + result = default; return false; } } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToTruncating(ushort value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToTruncating(ushort value, [MaybeNullWhen(false)] out TOther result) { // In order to reduce overall code duplication and improve the inlinabilty of these // methods for the corelib types we have `ConvertFrom` handle the same sign and @@ -1161,7 +1161,7 @@ static bool INumberBase.TryConvertToTruncating(ushort value, [No } else { - result = default!; + result = default; return false; } } diff --git a/src/libraries/System.Private.CoreLib/src/System/UInt32.cs b/src/libraries/System.Private.CoreLib/src/System/UInt32.cs index cce0a8b78a629..4f137f25dd303 100644 --- a/src/libraries/System.Private.CoreLib/src/System/UInt32.cs +++ b/src/libraries/System.Private.CoreLib/src/System/UInt32.cs @@ -949,7 +949,7 @@ private static bool TryConvertFromTruncating(TOther value, out uint resu /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToChecked(uint value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToChecked(uint value, [MaybeNullWhen(false)] out TOther result) { // In order to reduce overall code duplication and improve the inlinabilty of these // methods for the corelib types we have `ConvertFrom` handle the same sign and @@ -1016,14 +1016,14 @@ static bool INumberBase.TryConvertToChecked(uint value, [NotNullWh } else { - result = default!; + result = default; return false; } } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToSaturating(uint value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToSaturating(uint value, [MaybeNullWhen(false)] out TOther result) { // In order to reduce overall code duplication and improve the inlinabilty of these // methods for the corelib types we have `ConvertFrom` handle the same sign and @@ -1096,14 +1096,14 @@ static bool INumberBase.TryConvertToSaturating(uint value, [NotNul } else { - result = default!; + result = default; return false; } } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToTruncating(uint value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToTruncating(uint value, [MaybeNullWhen(false)] out TOther result) { // In order to reduce overall code duplication and improve the inlinabilty of these // methods for the corelib types we have `ConvertFrom` handle the same sign and @@ -1170,7 +1170,7 @@ static bool INumberBase.TryConvertToTruncating(uint value, [NotNul } else { - result = default!; + result = default; return false; } } diff --git a/src/libraries/System.Private.CoreLib/src/System/UInt64.cs b/src/libraries/System.Private.CoreLib/src/System/UInt64.cs index f3010971b12a2..c3f210e350dad 100644 --- a/src/libraries/System.Private.CoreLib/src/System/UInt64.cs +++ b/src/libraries/System.Private.CoreLib/src/System/UInt64.cs @@ -948,7 +948,7 @@ private static bool TryConvertFromTruncating(TOther value, out ulong res /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToChecked(ulong value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToChecked(ulong value, [MaybeNullWhen(false)] out TOther result) { // In order to reduce overall code duplication and improve the inlinabilty of these // methods for the corelib types we have `ConvertFrom` handle the same sign and @@ -1015,14 +1015,14 @@ static bool INumberBase.TryConvertToChecked(ulong value, [NotNull } else { - result = default!; + result = default; return false; } } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToSaturating(ulong value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToSaturating(ulong value, [MaybeNullWhen(false)] out TOther result) { // In order to reduce overall code duplication and improve the inlinabilty of these // methods for the corelib types we have `ConvertFrom` handle the same sign and @@ -1089,14 +1089,14 @@ static bool INumberBase.TryConvertToSaturating(ulong value, [NotN } else { - result = default!; + result = default; return false; } } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToTruncating(ulong value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToTruncating(ulong value, [MaybeNullWhen(false)] out TOther result) { // In order to reduce overall code duplication and improve the inlinabilty of these // methods for the corelib types we have `ConvertFrom` handle the same sign and @@ -1163,7 +1163,7 @@ static bool INumberBase.TryConvertToTruncating(ulong value, [NotN } else { - result = default!; + result = default; return false; } } diff --git a/src/libraries/System.Private.CoreLib/src/System/UIntPtr.cs b/src/libraries/System.Private.CoreLib/src/System/UIntPtr.cs index 29403c4e09907..04c8384c34957 100644 --- a/src/libraries/System.Private.CoreLib/src/System/UIntPtr.cs +++ b/src/libraries/System.Private.CoreLib/src/System/UIntPtr.cs @@ -933,7 +933,7 @@ private static bool TryConvertFromTruncating(TOther value, out nuint res /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToChecked(nuint value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToChecked(nuint value, [MaybeNullWhen(false)] out TOther result) { // In order to reduce overall code duplication and improve the inlinabilty of these // methods for the corelib types we have `ConvertFrom` handle the same sign and @@ -1000,14 +1000,14 @@ static bool INumberBase.TryConvertToChecked(nuint value, [NotNull } else { - result = default!; + result = default; return false; } } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToSaturating(nuint value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToSaturating(nuint value, [MaybeNullWhen(false)] out TOther result) { // In order to reduce overall code duplication and improve the inlinabilty of these // methods for the corelib types we have `ConvertFrom` handle the same sign and @@ -1074,14 +1074,14 @@ static bool INumberBase.TryConvertToSaturating(nuint value, [NotN } else { - result = default!; + result = default; return false; } } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToTruncating(nuint value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToTruncating(nuint value, [MaybeNullWhen(false)] out TOther result) { // In order to reduce overall code duplication and improve the inlinabilty of these // methods for the corelib types we have `ConvertFrom` handle the same sign and @@ -1148,7 +1148,7 @@ static bool INumberBase.TryConvertToTruncating(nuint value, [NotN } else { - result = default!; + result = default; return false; } } diff --git a/src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs b/src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs index b5a7b209486d9..c1ace3807df84 100644 --- a/src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs +++ b/src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs @@ -1314,9 +1314,9 @@ public static void Free(void* ptr) { } static bool System.Numerics.INumberBase.TryConvertFromChecked(TOther value, out System.Runtime.InteropServices.NFloat result) { throw null; } static bool System.Numerics.INumberBase.TryConvertFromSaturating(TOther value, out System.Runtime.InteropServices.NFloat result) { throw null; } static bool System.Numerics.INumberBase.TryConvertFromTruncating(TOther value, out System.Runtime.InteropServices.NFloat result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToChecked(System.Runtime.InteropServices.NFloat value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToSaturating(System.Runtime.InteropServices.NFloat value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToTruncating(System.Runtime.InteropServices.NFloat value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToChecked(System.Runtime.InteropServices.NFloat value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToSaturating(System.Runtime.InteropServices.NFloat value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToTruncating(System.Runtime.InteropServices.NFloat value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } static System.Runtime.InteropServices.NFloat System.Numerics.ISubtractionOperators.operator checked -(System.Runtime.InteropServices.NFloat left, System.Runtime.InteropServices.NFloat right) { throw null; } static System.Runtime.InteropServices.NFloat System.Numerics.IUnaryNegationOperators.operator checked -(System.Runtime.InteropServices.NFloat value) { throw null; } public static System.Runtime.InteropServices.NFloat Tan(System.Runtime.InteropServices.NFloat x) { throw null; } diff --git a/src/libraries/System.Runtime.Numerics/ref/System.Runtime.Numerics.cs b/src/libraries/System.Runtime.Numerics/ref/System.Runtime.Numerics.cs index 443aae6338ffc..0d371c4d7886c 100644 --- a/src/libraries/System.Runtime.Numerics/ref/System.Runtime.Numerics.cs +++ b/src/libraries/System.Runtime.Numerics/ref/System.Runtime.Numerics.cs @@ -218,9 +218,9 @@ namespace System.Numerics static bool System.Numerics.INumberBase.TryConvertFromChecked(TOther value, out System.Numerics.BigInteger result) { throw null; } static bool System.Numerics.INumberBase.TryConvertFromSaturating(TOther value, out System.Numerics.BigInteger result) { throw null; } static bool System.Numerics.INumberBase.TryConvertFromTruncating(TOther value, out System.Numerics.BigInteger result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToChecked(System.Numerics.BigInteger value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToSaturating(System.Numerics.BigInteger value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToTruncating(System.Numerics.BigInteger value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToChecked(System.Numerics.BigInteger value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToSaturating(System.Numerics.BigInteger value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToTruncating(System.Numerics.BigInteger value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } static System.Numerics.BigInteger System.Numerics.INumber.MaxNumber(System.Numerics.BigInteger x, System.Numerics.BigInteger y) { throw null; } static System.Numerics.BigInteger System.Numerics.INumber.MinNumber(System.Numerics.BigInteger x, System.Numerics.BigInteger y) { throw null; } static int System.Numerics.INumber.Sign(System.Numerics.BigInteger value) { throw null; } @@ -367,9 +367,9 @@ namespace System.Numerics static bool System.Numerics.INumberBase.TryConvertFromChecked(TOther value, out System.Numerics.Complex result) { throw null; } static bool System.Numerics.INumberBase.TryConvertFromSaturating(TOther value, out System.Numerics.Complex result) { throw null; } static bool System.Numerics.INumberBase.TryConvertFromTruncating(TOther value, out System.Numerics.Complex result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToChecked(System.Numerics.Complex value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToSaturating(System.Numerics.Complex value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToTruncating(System.Numerics.Complex value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToChecked(System.Numerics.Complex value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToSaturating(System.Numerics.Complex value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToTruncating(System.Numerics.Complex value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } public static System.Numerics.Complex Tan(System.Numerics.Complex value) { throw null; } public static System.Numerics.Complex Tanh(System.Numerics.Complex value) { throw null; } public override string ToString() { throw null; } diff --git a/src/libraries/System.Runtime.Numerics/src/System/Numerics/BigInteger.cs b/src/libraries/System.Runtime.Numerics/src/System/Numerics/BigInteger.cs index 4956fac177a40..1175591a97e00 100644 --- a/src/libraries/System.Runtime.Numerics/src/System/Numerics/BigInteger.cs +++ b/src/libraries/System.Runtime.Numerics/src/System/Numerics/BigInteger.cs @@ -4489,7 +4489,7 @@ private static bool TryConvertFromTruncating(TOther value, out BigIntege /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToChecked(BigInteger value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToChecked(BigInteger value, [MaybeNullWhen(false)] out TOther result) { if (typeof(TOther) == typeof(byte)) { @@ -4601,14 +4601,14 @@ static bool INumberBase.TryConvertToChecked(BigInteger value } else { - result = default!; + result = default; return false; } } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToSaturating(BigInteger value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToSaturating(BigInteger value, [MaybeNullWhen(false)] out TOther result) { if (typeof(TOther) == typeof(byte)) { @@ -4794,14 +4794,14 @@ static bool INumberBase.TryConvertToSaturating(BigInteger va } else { - result = default!; + result = default; return false; } } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToTruncating(BigInteger value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToTruncating(BigInteger value, [MaybeNullWhen(false)] out TOther result) { if (typeof(TOther) == typeof(byte)) { @@ -5190,7 +5190,7 @@ static bool INumberBase.TryConvertToTruncating(BigInteger va } else { - result = default!; + result = default; return false; } } diff --git a/src/libraries/System.Runtime.Numerics/src/System/Numerics/Complex.cs b/src/libraries/System.Runtime.Numerics/src/System/Numerics/Complex.cs index 97c0a5558f5e1..f2e2220b6ba08 100644 --- a/src/libraries/System.Runtime.Numerics/src/System/Numerics/Complex.cs +++ b/src/libraries/System.Runtime.Numerics/src/System/Numerics/Complex.cs @@ -1613,7 +1613,7 @@ private static bool TryConvertFrom(TOther value, out Complex result) /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToChecked(Complex value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToChecked(Complex value, [MaybeNullWhen(false)] out TOther result) { // Complex numbers with an imaginary part can't be represented as a "real number" // so we'll throw an OverflowException for this scenario for integer types and @@ -1805,14 +1805,14 @@ static bool INumberBase.TryConvertToChecked(Complex value, [Not } else { - result = default!; + result = default; return false; } } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToSaturating(Complex value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToSaturating(Complex value, [MaybeNullWhen(false)] out TOther result) { // Complex numbers with an imaginary part can't be represented as a "real number" // and there isn't really a well-defined way to "saturate" to just a real value. @@ -1949,14 +1949,14 @@ static bool INumberBase.TryConvertToSaturating(Complex value, [ } else { - result = default!; + result = default; return false; } } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool INumberBase.TryConvertToTruncating(Complex value, [NotNullWhen(true)] out TOther result) + static bool INumberBase.TryConvertToTruncating(Complex value, [MaybeNullWhen(false)] out TOther result) { // Complex numbers with an imaginary part can't be represented as a "real number" // so we'll only consider the real part for the purposes of truncation. @@ -2085,7 +2085,7 @@ static bool INumberBase.TryConvertToTruncating(Complex value, [ } else { - result = default!; + result = default; return false; } } diff --git a/src/libraries/System.Runtime/ref/System.Runtime.cs b/src/libraries/System.Runtime/ref/System.Runtime.cs index 5d04d15a81dc9..6ad2debb08822 100644 --- a/src/libraries/System.Runtime/ref/System.Runtime.cs +++ b/src/libraries/System.Runtime/ref/System.Runtime.cs @@ -818,9 +818,9 @@ public static void SetByte(System.Array array, int index, byte value) { } static bool System.Numerics.INumberBase.TryConvertFromChecked(TOther value, out byte result) { throw null; } static bool System.Numerics.INumberBase.TryConvertFromSaturating(TOther value, out byte result) { throw null; } static bool System.Numerics.INumberBase.TryConvertFromTruncating(TOther value, out byte result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToChecked(byte value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToSaturating(byte value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToTruncating(byte value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToChecked(byte value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToSaturating(byte value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToTruncating(byte value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } static byte System.Numerics.INumber.CopySign(byte value, byte sign) { throw null; } static byte System.Numerics.INumber.MaxNumber(byte x, byte y) { throw null; } static byte System.Numerics.INumber.MinNumber(byte x, byte y) { throw null; } @@ -1000,9 +1000,9 @@ public CannotUnloadAppDomainException(string? message, System.Exception? innerEx static bool System.Numerics.INumberBase.TryConvertFromChecked(TOther value, out char result) { throw null; } static bool System.Numerics.INumberBase.TryConvertFromSaturating(TOther value, out char result) { throw null; } static bool System.Numerics.INumberBase.TryConvertFromTruncating(TOther value, out char result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToChecked(char value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToSaturating(char value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToTruncating(char value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToChecked(char value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToSaturating(char value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToTruncating(char value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } static bool System.Numerics.INumberBase.TryParse(System.ReadOnlySpan s, System.Globalization.NumberStyles style, System.IFormatProvider? provider, out char result) { throw null; } static bool System.Numerics.INumberBase.TryParse([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] string? s, System.Globalization.NumberStyles style, System.IFormatProvider? provider, out char result) { throw null; } static char System.Numerics.IShiftOperators.operator <<(char value, int shiftAmount) { throw null; } @@ -2016,9 +2016,9 @@ public void GetObjectData(System.Runtime.Serialization.SerializationInfo info, S static bool System.Numerics.INumberBase.TryConvertFromChecked(TOther value, out decimal result) { throw null; } static bool System.Numerics.INumberBase.TryConvertFromSaturating(TOther value, out decimal result) { throw null; } static bool System.Numerics.INumberBase.TryConvertFromTruncating(TOther value, out decimal result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToChecked(decimal value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToSaturating(decimal value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToTruncating(decimal value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToChecked(decimal value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToSaturating(decimal value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToTruncating(decimal value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } static decimal System.Numerics.INumber.MaxNumber(decimal x, decimal y) { throw null; } static decimal System.Numerics.INumber.MinNumber(decimal x, decimal y) { throw null; } void System.Runtime.Serialization.IDeserializationCallback.OnDeserialization(object? sender) { } @@ -2266,9 +2266,9 @@ public DivideByZeroException(string? message, System.Exception? innerException) static bool System.Numerics.INumberBase.TryConvertFromChecked(TOther value, out double result) { throw null; } static bool System.Numerics.INumberBase.TryConvertFromSaturating(TOther value, out double result) { throw null; } static bool System.Numerics.INumberBase.TryConvertFromTruncating(TOther value, out double result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToChecked(double value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToSaturating(double value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToTruncating(double value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToChecked(double value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToSaturating(double value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToTruncating(double value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } static double System.Numerics.ISubtractionOperators.operator -(double left, double right) { throw null; } static double System.Numerics.IUnaryNegationOperators.operator -(double value) { throw null; } static double System.Numerics.IUnaryPlusOperators.operator +(double value) { throw null; } @@ -2908,9 +2908,9 @@ public enum GCNotificationStatus static bool System.Numerics.INumberBase.TryConvertFromChecked(TOther value, out System.Half result) { throw null; } static bool System.Numerics.INumberBase.TryConvertFromSaturating(TOther value, out System.Half result) { throw null; } static bool System.Numerics.INumberBase.TryConvertFromTruncating(TOther value, out System.Half result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToChecked(System.Half value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToSaturating(System.Half value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToTruncating(System.Half value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToChecked(System.Half value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToSaturating(System.Half value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToTruncating(System.Half value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } public static System.Half Tan(System.Half x) { throw null; } public static System.Half Tanh(System.Half x) { throw null; } public static System.Half TanPi(System.Half x) { throw null; } @@ -3209,9 +3209,9 @@ public InsufficientMemoryException(string? message, System.Exception? innerExcep static bool System.Numerics.INumberBase.TryConvertFromChecked(TOther value, out System.Int128 result) { throw null; } static bool System.Numerics.INumberBase.TryConvertFromSaturating(TOther value, out System.Int128 result) { throw null; } static bool System.Numerics.INumberBase.TryConvertFromTruncating(TOther value, out System.Int128 result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToChecked(System.Int128 value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToSaturating(System.Int128 value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToTruncating(System.Int128 value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToChecked(System.Int128 value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToSaturating(System.Int128 value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToTruncating(System.Int128 value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } static System.Int128 System.Numerics.INumber.MaxNumber(System.Int128 x, System.Int128 y) { throw null; } static System.Int128 System.Numerics.INumber.MinNumber(System.Int128 x, System.Int128 y) { throw null; } public override string ToString() { throw null; } @@ -3334,9 +3334,9 @@ public InsufficientMemoryException(string? message, System.Exception? innerExcep static bool System.Numerics.INumberBase.TryConvertFromChecked(TOther value, out short result) { throw null; } static bool System.Numerics.INumberBase.TryConvertFromSaturating(TOther value, out short result) { throw null; } static bool System.Numerics.INumberBase.TryConvertFromTruncating(TOther value, out short result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToChecked(short value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToSaturating(short value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToTruncating(short value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToChecked(short value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToSaturating(short value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToTruncating(short value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } static short System.Numerics.INumber.MaxNumber(short x, short y) { throw null; } static short System.Numerics.INumber.MinNumber(short x, short y) { throw null; } static short System.Numerics.IShiftOperators.operator <<(short value, int shiftAmount) { throw null; } @@ -3467,9 +3467,9 @@ public InsufficientMemoryException(string? message, System.Exception? innerExcep static bool System.Numerics.INumberBase.TryConvertFromChecked(TOther value, out int result) { throw null; } static bool System.Numerics.INumberBase.TryConvertFromSaturating(TOther value, out int result) { throw null; } static bool System.Numerics.INumberBase.TryConvertFromTruncating(TOther value, out int result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToChecked(int value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToSaturating(int value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToTruncating(int value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToChecked(int value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToSaturating(int value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToTruncating(int value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } static int System.Numerics.INumber.MaxNumber(int x, int y) { throw null; } static int System.Numerics.INumber.MinNumber(int x, int y) { throw null; } static int System.Numerics.IShiftOperators.operator <<(int value, int shiftAmount) { throw null; } @@ -3600,9 +3600,9 @@ public InsufficientMemoryException(string? message, System.Exception? innerExcep static bool System.Numerics.INumberBase.TryConvertFromChecked(TOther value, out long result) { throw null; } static bool System.Numerics.INumberBase.TryConvertFromSaturating(TOther value, out long result) { throw null; } static bool System.Numerics.INumberBase.TryConvertFromTruncating(TOther value, out long result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToChecked(long value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToSaturating(long value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToTruncating(long value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToChecked(long value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToSaturating(long value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToTruncating(long value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } static long System.Numerics.INumber.MaxNumber(long x, long y) { throw null; } static long System.Numerics.INumber.MinNumber(long x, long y) { throw null; } static long System.Numerics.IShiftOperators.operator <<(long value, int shiftAmount) { throw null; } @@ -3735,9 +3735,9 @@ public InsufficientMemoryException(string? message, System.Exception? innerExcep static bool System.Numerics.INumberBase.TryConvertFromChecked(TOther value, out nint result) { throw null; } static bool System.Numerics.INumberBase.TryConvertFromSaturating(TOther value, out nint result) { throw null; } static bool System.Numerics.INumberBase.TryConvertFromTruncating(TOther value, out nint result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToChecked(nint value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToSaturating(nint value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToTruncating(nint value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToChecked(nint value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToSaturating(nint value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToTruncating(nint value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } static nint System.Numerics.INumber.MaxNumber(nint x, nint y) { throw null; } static nint System.Numerics.INumber.MinNumber(nint x, nint y) { throw null; } static nint System.Numerics.IShiftOperators.operator <<(nint value, int shiftAmount) { throw null; } @@ -3804,7 +3804,7 @@ public partial interface IObserver void OnError(System.Exception error); void OnNext(T value); } - public partial interface IParsable where TSelf : System.IParsable + public partial interface IParsable where TSelf : System.IParsable? { static abstract TSelf Parse(string s, System.IFormatProvider? provider); static abstract bool TryParse([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] string? s, System.IFormatProvider? provider, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TSelf result); @@ -3817,7 +3817,7 @@ public partial interface ISpanFormattable : System.IFormattable { bool TryFormat(System.Span destination, out int charsWritten, System.ReadOnlySpan format, System.IFormatProvider? provider); } - public partial interface ISpanParsable : System.IParsable where TSelf : System.ISpanParsable + public partial interface ISpanParsable : System.IParsable where TSelf : System.ISpanParsable? { static abstract TSelf Parse(System.ReadOnlySpan s, System.IFormatProvider? provider); static abstract bool TryParse(System.ReadOnlySpan s, System.IFormatProvider? provider, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TSelf result); @@ -4664,9 +4664,9 @@ public void GetObjectData(System.Runtime.Serialization.SerializationInfo info, S static bool System.Numerics.INumberBase.TryConvertFromChecked(TOther value, out sbyte result) { throw null; } static bool System.Numerics.INumberBase.TryConvertFromSaturating(TOther value, out sbyte result) { throw null; } static bool System.Numerics.INumberBase.TryConvertFromTruncating(TOther value, out sbyte result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToChecked(sbyte value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToSaturating(sbyte value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToTruncating(sbyte value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToChecked(sbyte value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToSaturating(sbyte value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToTruncating(sbyte value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } static sbyte System.Numerics.INumber.MaxNumber(sbyte x, sbyte y) { throw null; } static sbyte System.Numerics.INumber.MinNumber(sbyte x, sbyte y) { throw null; } static sbyte System.Numerics.IShiftOperators.operator <<(sbyte value, int shiftAmount) { throw null; } @@ -4863,9 +4863,9 @@ public SerializableAttribute() { } static bool System.Numerics.INumberBase.TryConvertFromChecked(TOther value, out float result) { throw null; } static bool System.Numerics.INumberBase.TryConvertFromSaturating(TOther value, out float result) { throw null; } static bool System.Numerics.INumberBase.TryConvertFromTruncating(TOther value, out float result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToChecked(float value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToSaturating(float value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToTruncating(float value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToChecked(float value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToSaturating(float value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToTruncating(float value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } static float System.Numerics.ISubtractionOperators.operator -(float left, float right) { throw null; } static float System.Numerics.IUnaryNegationOperators.operator -(float value) { throw null; } static float System.Numerics.IUnaryPlusOperators.operator +(float value) { throw null; } @@ -6221,9 +6221,9 @@ public TypeUnloadedException(string? message, System.Exception? innerException) static bool System.Numerics.INumberBase.TryConvertFromChecked(TOther value, out System.UInt128 result) { throw null; } static bool System.Numerics.INumberBase.TryConvertFromSaturating(TOther value, out System.UInt128 result) { throw null; } static bool System.Numerics.INumberBase.TryConvertFromTruncating(TOther value, out System.UInt128 result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToChecked(System.UInt128 value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToSaturating(System.UInt128 value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToTruncating(System.UInt128 value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToChecked(System.UInt128 value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToSaturating(System.UInt128 value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToTruncating(System.UInt128 value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } static System.UInt128 System.Numerics.INumber.CopySign(System.UInt128 value, System.UInt128 sign) { throw null; } static System.UInt128 System.Numerics.INumber.MaxNumber(System.UInt128 x, System.UInt128 y) { throw null; } static System.UInt128 System.Numerics.INumber.MinNumber(System.UInt128 x, System.UInt128 y) { throw null; } @@ -6346,9 +6346,9 @@ public TypeUnloadedException(string? message, System.Exception? innerException) static bool System.Numerics.INumberBase.TryConvertFromChecked(TOther value, out ushort result) { throw null; } static bool System.Numerics.INumberBase.TryConvertFromSaturating(TOther value, out ushort result) { throw null; } static bool System.Numerics.INumberBase.TryConvertFromTruncating(TOther value, out ushort result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToChecked(ushort value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToSaturating(ushort value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToTruncating(ushort value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToChecked(ushort value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToSaturating(ushort value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToTruncating(ushort value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } static ushort System.Numerics.INumber.CopySign(ushort value, ushort sign) { throw null; } static ushort System.Numerics.INumber.MaxNumber(ushort x, ushort y) { throw null; } static ushort System.Numerics.INumber.MinNumber(ushort x, ushort y) { throw null; } @@ -6479,9 +6479,9 @@ public TypeUnloadedException(string? message, System.Exception? innerException) static bool System.Numerics.INumberBase.TryConvertFromChecked(TOther value, out uint result) { throw null; } static bool System.Numerics.INumberBase.TryConvertFromSaturating(TOther value, out uint result) { throw null; } static bool System.Numerics.INumberBase.TryConvertFromTruncating(TOther value, out uint result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToChecked(uint value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToSaturating(uint value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToTruncating(uint value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToChecked(uint value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToSaturating(uint value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToTruncating(uint value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } static uint System.Numerics.INumber.CopySign(uint value, uint sign) { throw null; } static uint System.Numerics.INumber.MaxNumber(uint x, uint y) { throw null; } static uint System.Numerics.INumber.MinNumber(uint x, uint y) { throw null; } @@ -6612,9 +6612,9 @@ public TypeUnloadedException(string? message, System.Exception? innerException) static bool System.Numerics.INumberBase.TryConvertFromChecked(TOther value, out ulong result) { throw null; } static bool System.Numerics.INumberBase.TryConvertFromSaturating(TOther value, out ulong result) { throw null; } static bool System.Numerics.INumberBase.TryConvertFromTruncating(TOther value, out ulong result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToChecked(ulong value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToSaturating(ulong value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToTruncating(ulong value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToChecked(ulong value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToSaturating(ulong value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToTruncating(ulong value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } static ulong System.Numerics.INumber.CopySign(ulong value, ulong sign) { throw null; } static ulong System.Numerics.INumber.MaxNumber(ulong x, ulong y) { throw null; } static ulong System.Numerics.INumber.MinNumber(ulong x, ulong y) { throw null; } @@ -6744,9 +6744,9 @@ public TypeUnloadedException(string? message, System.Exception? innerException) static bool System.Numerics.INumberBase.TryConvertFromChecked(TOther value, out nuint result) { throw null; } static bool System.Numerics.INumberBase.TryConvertFromSaturating(TOther value, out nuint result) { throw null; } static bool System.Numerics.INumberBase.TryConvertFromTruncating(TOther value, out nuint result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToChecked(nuint value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToSaturating(nuint value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } - static bool System.Numerics.INumberBase.TryConvertToTruncating(nuint value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToChecked(nuint value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToSaturating(nuint value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } + static bool System.Numerics.INumberBase.TryConvertToTruncating(nuint value, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TOther result) { throw null; } static nuint System.Numerics.INumber.CopySign(nuint value, nuint sign) { throw null; } static nuint System.Numerics.INumber.MaxNumber(nuint x, nuint y) { throw null; } static nuint System.Numerics.INumber.MinNumber(nuint x, nuint y) { throw null; } @@ -10218,19 +10218,19 @@ public static partial class BitOperations [System.CLSCompliantAttribute(false)] public static int TrailingZeroCount(nuint value) { throw null; } } - public partial interface IAdditionOperators where TSelf : System.Numerics.IAdditionOperators + public partial interface IAdditionOperators where TSelf : System.Numerics.IAdditionOperators? { static abstract TResult operator +(TSelf left, TOther right); static virtual TResult operator checked +(TSelf left, TOther right) { throw null; } } - public partial interface IAdditiveIdentity where TSelf : System.Numerics.IAdditiveIdentity + public partial interface IAdditiveIdentity where TSelf : System.Numerics.IAdditiveIdentity? { static abstract TResult AdditiveIdentity { get; } } - public partial interface IBinaryFloatingPointIeee754 : System.IComparable, System.IComparable, System.IEquatable, System.IFormattable, System.IParsable, System.ISpanFormattable, System.ISpanParsable, System.Numerics.IAdditionOperators, System.Numerics.IAdditiveIdentity, System.Numerics.IBinaryNumber, System.Numerics.IBitwiseOperators, System.Numerics.IComparisonOperators, System.Numerics.IDecrementOperators, System.Numerics.IDivisionOperators, System.Numerics.IEqualityOperators, System.Numerics.IExponentialFunctions, System.Numerics.IFloatingPoint, System.Numerics.IFloatingPointConstants, System.Numerics.IFloatingPointIeee754, System.Numerics.IHyperbolicFunctions, System.Numerics.IIncrementOperators, System.Numerics.ILogarithmicFunctions, System.Numerics.IModulusOperators, System.Numerics.IMultiplicativeIdentity, System.Numerics.IMultiplyOperators, System.Numerics.INumber, System.Numerics.INumberBase, System.Numerics.IPowerFunctions, System.Numerics.IRootFunctions, System.Numerics.ISignedNumber, System.Numerics.ISubtractionOperators, System.Numerics.ITrigonometricFunctions, System.Numerics.IUnaryNegationOperators, System.Numerics.IUnaryPlusOperators where TSelf : System.Numerics.IBinaryFloatingPointIeee754 + public partial interface IBinaryFloatingPointIeee754 : System.IComparable, System.IComparable, System.IEquatable, System.IFormattable, System.IParsable, System.ISpanFormattable, System.ISpanParsable, System.Numerics.IAdditionOperators, System.Numerics.IAdditiveIdentity, System.Numerics.IBinaryNumber, System.Numerics.IBitwiseOperators, System.Numerics.IComparisonOperators, System.Numerics.IDecrementOperators, System.Numerics.IDivisionOperators, System.Numerics.IEqualityOperators, System.Numerics.IExponentialFunctions, System.Numerics.IFloatingPoint, System.Numerics.IFloatingPointConstants, System.Numerics.IFloatingPointIeee754, System.Numerics.IHyperbolicFunctions, System.Numerics.IIncrementOperators, System.Numerics.ILogarithmicFunctions, System.Numerics.IModulusOperators, System.Numerics.IMultiplicativeIdentity, System.Numerics.IMultiplyOperators, System.Numerics.INumber, System.Numerics.INumberBase, System.Numerics.IPowerFunctions, System.Numerics.IRootFunctions, System.Numerics.ISignedNumber, System.Numerics.ISubtractionOperators, System.Numerics.ITrigonometricFunctions, System.Numerics.IUnaryNegationOperators, System.Numerics.IUnaryPlusOperators where TSelf : System.Numerics.IBinaryFloatingPointIeee754? { } - public partial interface IBinaryInteger : System.IComparable, System.IComparable, System.IEquatable, System.IFormattable, System.IParsable, System.ISpanFormattable, System.ISpanParsable, System.Numerics.IAdditionOperators, System.Numerics.IAdditiveIdentity, System.Numerics.IBinaryNumber, System.Numerics.IBitwiseOperators, System.Numerics.IComparisonOperators, System.Numerics.IDecrementOperators, System.Numerics.IDivisionOperators, System.Numerics.IEqualityOperators, System.Numerics.IIncrementOperators, System.Numerics.IModulusOperators, System.Numerics.IMultiplicativeIdentity, System.Numerics.IMultiplyOperators, System.Numerics.INumber, System.Numerics.INumberBase, System.Numerics.IShiftOperators, System.Numerics.ISubtractionOperators, System.Numerics.IUnaryNegationOperators, System.Numerics.IUnaryPlusOperators where TSelf : System.Numerics.IBinaryInteger + public partial interface IBinaryInteger : System.IComparable, System.IComparable, System.IEquatable, System.IFormattable, System.IParsable, System.ISpanFormattable, System.ISpanParsable, System.Numerics.IAdditionOperators, System.Numerics.IAdditiveIdentity, System.Numerics.IBinaryNumber, System.Numerics.IBitwiseOperators, System.Numerics.IComparisonOperators, System.Numerics.IDecrementOperators, System.Numerics.IDivisionOperators, System.Numerics.IEqualityOperators, System.Numerics.IIncrementOperators, System.Numerics.IModulusOperators, System.Numerics.IMultiplicativeIdentity, System.Numerics.IMultiplyOperators, System.Numerics.INumber, System.Numerics.INumberBase, System.Numerics.IShiftOperators, System.Numerics.ISubtractionOperators, System.Numerics.IUnaryNegationOperators, System.Numerics.IUnaryPlusOperators where TSelf : System.Numerics.IBinaryInteger? { static virtual (TSelf Quotient, TSelf Remainder) DivRem(TSelf left, TSelf right) { throw null; } int GetByteCount(); @@ -10257,42 +10257,42 @@ public partial interface IBinaryInteger : System.IComparable, System.ICom int WriteLittleEndian(byte[] destination, int startIndex) { throw null; } int WriteLittleEndian(System.Span destination) { throw null; } } - public partial interface IBinaryNumber : System.IComparable, System.IComparable, System.IEquatable, System.IFormattable, System.IParsable, System.ISpanFormattable, System.ISpanParsable, System.Numerics.IAdditionOperators, System.Numerics.IAdditiveIdentity, System.Numerics.IBitwiseOperators, System.Numerics.IComparisonOperators, System.Numerics.IDecrementOperators, System.Numerics.IDivisionOperators, System.Numerics.IEqualityOperators, System.Numerics.IIncrementOperators, System.Numerics.IModulusOperators, System.Numerics.IMultiplicativeIdentity, System.Numerics.IMultiplyOperators, System.Numerics.INumber, System.Numerics.INumberBase, System.Numerics.ISubtractionOperators, System.Numerics.IUnaryNegationOperators, System.Numerics.IUnaryPlusOperators where TSelf : System.Numerics.IBinaryNumber + public partial interface IBinaryNumber : System.IComparable, System.IComparable, System.IEquatable, System.IFormattable, System.IParsable, System.ISpanFormattable, System.ISpanParsable, System.Numerics.IAdditionOperators, System.Numerics.IAdditiveIdentity, System.Numerics.IBitwiseOperators, System.Numerics.IComparisonOperators, System.Numerics.IDecrementOperators, System.Numerics.IDivisionOperators, System.Numerics.IEqualityOperators, System.Numerics.IIncrementOperators, System.Numerics.IModulusOperators, System.Numerics.IMultiplicativeIdentity, System.Numerics.IMultiplyOperators, System.Numerics.INumber, System.Numerics.INumberBase, System.Numerics.ISubtractionOperators, System.Numerics.IUnaryNegationOperators, System.Numerics.IUnaryPlusOperators where TSelf : System.Numerics.IBinaryNumber? { static virtual TSelf AllBitsSet { get { throw null; } } static abstract bool IsPow2(TSelf value); static abstract TSelf Log2(TSelf value); } - public partial interface IBitwiseOperators where TSelf : System.Numerics.IBitwiseOperators + public partial interface IBitwiseOperators where TSelf : System.Numerics.IBitwiseOperators? { static abstract TResult operator &(TSelf left, TOther right); static abstract TResult operator |(TSelf left, TOther right); static abstract TResult operator ^(TSelf left, TOther right); static abstract TResult operator ~(TSelf value); } - public partial interface IComparisonOperators : System.Numerics.IEqualityOperators where TSelf : System.Numerics.IComparisonOperators + public partial interface IComparisonOperators : System.Numerics.IEqualityOperators where TSelf : System.Numerics.IComparisonOperators? { static abstract TResult operator >(TSelf left, TOther right); static abstract TResult operator >=(TSelf left, TOther right); static abstract TResult operator <(TSelf left, TOther right); static abstract TResult operator <=(TSelf left, TOther right); } - public partial interface IDecrementOperators where TSelf : System.Numerics.IDecrementOperators + public partial interface IDecrementOperators where TSelf : System.Numerics.IDecrementOperators? { static virtual TSelf operator checked --(TSelf value) { throw null; } static abstract TSelf operator --(TSelf value); } - public partial interface IDivisionOperators where TSelf : System.Numerics.IDivisionOperators + public partial interface IDivisionOperators where TSelf : System.Numerics.IDivisionOperators? { static virtual TResult operator checked /(TSelf left, TOther right) { throw null; } static abstract TResult operator /(TSelf left, TOther right); } - public partial interface IEqualityOperators where TSelf : System.Numerics.IEqualityOperators + public partial interface IEqualityOperators where TSelf : System.Numerics.IEqualityOperators? { - static abstract TResult operator ==(TSelf left, TOther right); - static abstract TResult operator !=(TSelf left, TOther right); + static abstract TResult operator ==(TSelf? left, TOther? right); + static abstract TResult operator !=(TSelf? left, TOther? right); } - public partial interface IExponentialFunctions : System.Numerics.IFloatingPointConstants, System.Numerics.INumberBase where TSelf : System.Numerics.IExponentialFunctions + public partial interface IExponentialFunctions : System.Numerics.IFloatingPointConstants, System.Numerics.INumberBase where TSelf : System.Numerics.IExponentialFunctions? { static abstract TSelf Exp(TSelf x); static abstract TSelf Exp10(TSelf x); @@ -10301,13 +10301,13 @@ public partial interface IExponentialFunctions : System.Numerics.IFloatin static virtual TSelf Exp2M1(TSelf x) { throw null; } static virtual TSelf ExpM1(TSelf x) { throw null; } } - public partial interface IFloatingPointConstants : System.Numerics.INumberBase where TSelf : System.Numerics.IFloatingPointConstants + public partial interface IFloatingPointConstants : System.Numerics.INumberBase where TSelf : System.Numerics.IFloatingPointConstants? { static abstract TSelf E { get; } static abstract TSelf Pi { get; } static abstract TSelf Tau { get; } } - public partial interface IFloatingPointIeee754 : System.IComparable, System.IComparable, System.IEquatable, System.IFormattable, System.IParsable, System.ISpanFormattable, System.ISpanParsable, System.Numerics.IAdditionOperators, System.Numerics.IAdditiveIdentity, System.Numerics.IComparisonOperators, System.Numerics.IDecrementOperators, System.Numerics.IDivisionOperators, System.Numerics.IEqualityOperators, System.Numerics.IExponentialFunctions, System.Numerics.IFloatingPoint, System.Numerics.IFloatingPointConstants, System.Numerics.IHyperbolicFunctions, System.Numerics.IIncrementOperators, System.Numerics.ILogarithmicFunctions, System.Numerics.IModulusOperators, System.Numerics.IMultiplicativeIdentity, System.Numerics.IMultiplyOperators, System.Numerics.INumber, System.Numerics.INumberBase, System.Numerics.IPowerFunctions, System.Numerics.IRootFunctions, System.Numerics.ISignedNumber, System.Numerics.ISubtractionOperators, System.Numerics.ITrigonometricFunctions, System.Numerics.IUnaryNegationOperators, System.Numerics.IUnaryPlusOperators where TSelf : System.Numerics.IFloatingPointIeee754 + public partial interface IFloatingPointIeee754 : System.IComparable, System.IComparable, System.IEquatable, System.IFormattable, System.IParsable, System.ISpanFormattable, System.ISpanParsable, System.Numerics.IAdditionOperators, System.Numerics.IAdditiveIdentity, System.Numerics.IComparisonOperators, System.Numerics.IDecrementOperators, System.Numerics.IDivisionOperators, System.Numerics.IEqualityOperators, System.Numerics.IExponentialFunctions, System.Numerics.IFloatingPoint, System.Numerics.IFloatingPointConstants, System.Numerics.IHyperbolicFunctions, System.Numerics.IIncrementOperators, System.Numerics.ILogarithmicFunctions, System.Numerics.IModulusOperators, System.Numerics.IMultiplicativeIdentity, System.Numerics.IMultiplyOperators, System.Numerics.INumber, System.Numerics.INumberBase, System.Numerics.IPowerFunctions, System.Numerics.IRootFunctions, System.Numerics.ISignedNumber, System.Numerics.ISubtractionOperators, System.Numerics.ITrigonometricFunctions, System.Numerics.IUnaryNegationOperators, System.Numerics.IUnaryPlusOperators where TSelf : System.Numerics.IFloatingPointIeee754? { static abstract TSelf Epsilon { get; } static abstract TSelf NaN { get; } @@ -10325,7 +10325,7 @@ public partial interface IFloatingPointIeee754 : System.IComparable, Syst static virtual TSelf ReciprocalSqrtEstimate(TSelf x) { throw null; } static abstract TSelf ScaleB(TSelf x, int n); } - public partial interface IFloatingPoint : System.IComparable, System.IComparable, System.IEquatable, System.IFormattable, System.IParsable, System.ISpanFormattable, System.ISpanParsable, System.Numerics.IAdditionOperators, System.Numerics.IAdditiveIdentity, System.Numerics.IComparisonOperators, System.Numerics.IDecrementOperators, System.Numerics.IDivisionOperators, System.Numerics.IEqualityOperators, System.Numerics.IFloatingPointConstants, System.Numerics.IIncrementOperators, System.Numerics.IModulusOperators, System.Numerics.IMultiplicativeIdentity, System.Numerics.IMultiplyOperators, System.Numerics.INumber, System.Numerics.INumberBase, System.Numerics.ISignedNumber, System.Numerics.ISubtractionOperators, System.Numerics.IUnaryNegationOperators, System.Numerics.IUnaryPlusOperators where TSelf : System.Numerics.IFloatingPoint + public partial interface IFloatingPoint : System.IComparable, System.IComparable, System.IEquatable, System.IFormattable, System.IParsable, System.ISpanFormattable, System.ISpanParsable, System.Numerics.IAdditionOperators, System.Numerics.IAdditiveIdentity, System.Numerics.IComparisonOperators, System.Numerics.IDecrementOperators, System.Numerics.IDivisionOperators, System.Numerics.IEqualityOperators, System.Numerics.IFloatingPointConstants, System.Numerics.IIncrementOperators, System.Numerics.IModulusOperators, System.Numerics.IMultiplicativeIdentity, System.Numerics.IMultiplyOperators, System.Numerics.INumber, System.Numerics.INumberBase, System.Numerics.ISignedNumber, System.Numerics.ISubtractionOperators, System.Numerics.IUnaryNegationOperators, System.Numerics.IUnaryPlusOperators where TSelf : System.Numerics.IFloatingPoint? { static virtual TSelf Ceiling(TSelf x) { throw null; } static virtual TSelf Floor(TSelf x) { throw null; } @@ -10355,7 +10355,7 @@ public partial interface IFloatingPoint : System.IComparable, System.ICom int WriteSignificandLittleEndian(byte[] destination, int startIndex) { throw null; } int WriteSignificandLittleEndian(System.Span destination) { throw null; } } - public partial interface IHyperbolicFunctions : System.Numerics.IFloatingPointConstants, System.Numerics.INumberBase where TSelf : System.Numerics.IHyperbolicFunctions + public partial interface IHyperbolicFunctions : System.Numerics.IFloatingPointConstants, System.Numerics.INumberBase where TSelf : System.Numerics.IHyperbolicFunctions? { static abstract TSelf Acosh(TSelf x); static abstract TSelf Asinh(TSelf x); @@ -10364,12 +10364,12 @@ public partial interface IHyperbolicFunctions : System.Numerics.IFloating static abstract TSelf Sinh(TSelf x); static abstract TSelf Tanh(TSelf x); } - public partial interface IIncrementOperators where TSelf : System.Numerics.IIncrementOperators + public partial interface IIncrementOperators where TSelf : System.Numerics.IIncrementOperators? { static virtual TSelf operator checked ++(TSelf value) { throw null; } static abstract TSelf operator ++(TSelf value); } - public partial interface ILogarithmicFunctions : System.Numerics.IFloatingPointConstants, System.Numerics.INumberBase where TSelf : System.Numerics.ILogarithmicFunctions + public partial interface ILogarithmicFunctions : System.Numerics.IFloatingPointConstants, System.Numerics.INumberBase where TSelf : System.Numerics.ILogarithmicFunctions? { static abstract TSelf Log(TSelf x); static abstract TSelf Log(TSelf x, TSelf newBase); @@ -10379,33 +10379,42 @@ public partial interface ILogarithmicFunctions : System.Numerics.IFloatin static virtual TSelf Log2P1(TSelf x) { throw null; } static virtual TSelf LogP1(TSelf x) { throw null; } } - public partial interface IMinMaxValue where TSelf : System.Numerics.IMinMaxValue + public partial interface IMinMaxValue where TSelf : System.Numerics.IMinMaxValue? { static abstract TSelf MaxValue { get; } static abstract TSelf MinValue { get; } } - public partial interface IModulusOperators where TSelf : System.Numerics.IModulusOperators + public partial interface IModulusOperators where TSelf : System.Numerics.IModulusOperators? { static abstract TResult operator %(TSelf left, TOther right); } - public partial interface IMultiplicativeIdentity where TSelf : System.Numerics.IMultiplicativeIdentity + public partial interface IMultiplicativeIdentity where TSelf : System.Numerics.IMultiplicativeIdentity? { static abstract TResult MultiplicativeIdentity { get; } } - public partial interface IMultiplyOperators where TSelf : System.Numerics.IMultiplyOperators + public partial interface IMultiplyOperators where TSelf : System.Numerics.IMultiplyOperators? { static virtual TResult operator checked *(TSelf left, TOther right) { throw null; } static abstract TResult operator *(TSelf left, TOther right); } - public partial interface INumberBase : System.IEquatable, System.IFormattable, System.IParsable, System.ISpanFormattable, System.ISpanParsable, System.Numerics.IAdditionOperators, System.Numerics.IAdditiveIdentity, System.Numerics.IDecrementOperators, System.Numerics.IDivisionOperators, System.Numerics.IEqualityOperators, System.Numerics.IIncrementOperators, System.Numerics.IMultiplicativeIdentity, System.Numerics.IMultiplyOperators, System.Numerics.ISubtractionOperators, System.Numerics.IUnaryNegationOperators, System.Numerics.IUnaryPlusOperators where TSelf : System.Numerics.INumberBase + public partial interface INumberBase : System.IEquatable, System.IFormattable, System.IParsable, System.ISpanFormattable, System.ISpanParsable, System.Numerics.IAdditionOperators, System.Numerics.IAdditiveIdentity, System.Numerics.IDecrementOperators, System.Numerics.IDivisionOperators, System.Numerics.IEqualityOperators, System.Numerics.IIncrementOperators, System.Numerics.IMultiplicativeIdentity, System.Numerics.IMultiplyOperators, System.Numerics.ISubtractionOperators, System.Numerics.IUnaryNegationOperators, System.Numerics.IUnaryPlusOperators where TSelf : System.Numerics.INumberBase? { static abstract TSelf One { get; } static abstract int Radix { get; } static abstract TSelf Zero { get; } static abstract TSelf Abs(TSelf value); - static virtual TSelf CreateChecked(TOther value) where TOther : System.Numerics.INumberBase { throw null; } - static virtual TSelf CreateSaturating(TOther value) where TOther : System.Numerics.INumberBase { throw null; } - static virtual TSelf CreateTruncating(TOther value) where TOther : System.Numerics.INumberBase { throw null; } + static virtual TSelf CreateChecked(TOther value) +#nullable disable + where TOther : System.Numerics.INumberBase { throw null; } +#nullable restore + static virtual TSelf CreateSaturating(TOther value) +#nullable disable + where TOther : System.Numerics.INumberBase { throw null; } +#nullable restore + static virtual TSelf CreateTruncating(TOther value) +#nullable disable + where TOther : System.Numerics.INumberBase { throw null; } +#nullable restore static abstract bool IsCanonical(TSelf value); static abstract bool IsComplexNumber(TSelf value); static abstract bool IsEvenInteger(TSelf value); @@ -10429,16 +10438,34 @@ public partial interface INumberBase : System.IEquatable, System.I static abstract TSelf MinMagnitudeNumber(TSelf x, TSelf y); static abstract TSelf Parse(System.ReadOnlySpan s, System.Globalization.NumberStyles style, System.IFormatProvider? provider); static abstract TSelf Parse(string s, System.Globalization.NumberStyles style, System.IFormatProvider? provider); - protected static abstract bool TryConvertFromChecked(TOther value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TSelf? result) where TOther : System.Numerics.INumberBase; - protected static abstract bool TryConvertFromSaturating(TOther value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TSelf? result) where TOther : System.Numerics.INumberBase; - protected static abstract bool TryConvertFromTruncating(TOther value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TSelf? result) where TOther : System.Numerics.INumberBase; - protected static abstract bool TryConvertToChecked(TSelf value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther? result) where TOther : System.Numerics.INumberBase; - protected static abstract bool TryConvertToSaturating(TSelf value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther? result) where TOther : System.Numerics.INumberBase; - protected static abstract bool TryConvertToTruncating(TSelf value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TOther? result) where TOther : System.Numerics.INumberBase; + protected static abstract bool TryConvertFromChecked(TOther value, [System.Diagnostics.CodeAnalysis.MaybeNullWhen(false)] out TSelf result) +#nullable disable + where TOther : System.Numerics.INumberBase; +#nullable restore + protected static abstract bool TryConvertFromSaturating(TOther value, [System.Diagnostics.CodeAnalysis.MaybeNullWhen(false)] out TSelf result) +#nullable disable + where TOther : System.Numerics.INumberBase; +#nullable restore + protected static abstract bool TryConvertFromTruncating(TOther value, [System.Diagnostics.CodeAnalysis.MaybeNullWhen(false)] out TSelf result) +#nullable disable + where TOther : System.Numerics.INumberBase; +#nullable restore + protected static abstract bool TryConvertToChecked(TSelf value, [System.Diagnostics.CodeAnalysis.MaybeNullWhen(false)] out TOther result) +#nullable disable + where TOther : System.Numerics.INumberBase; +#nullable restore + protected static abstract bool TryConvertToSaturating(TSelf value, [System.Diagnostics.CodeAnalysis.MaybeNullWhen(false)] out TOther result) +#nullable disable + where TOther : System.Numerics.INumberBase; +#nullable restore + protected static abstract bool TryConvertToTruncating(TSelf value, [System.Diagnostics.CodeAnalysis.MaybeNullWhen(false)] out TOther result) +#nullable disable + where TOther : System.Numerics.INumberBase; +#nullable restore static abstract bool TryParse(System.ReadOnlySpan s, System.Globalization.NumberStyles style, System.IFormatProvider? provider, out TSelf result); static abstract bool TryParse([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] string? s, System.Globalization.NumberStyles style, System.IFormatProvider? provider, out TSelf result); } - public partial interface INumber : System.IComparable, System.IComparable, System.IEquatable, System.IFormattable, System.IParsable, System.ISpanFormattable, System.ISpanParsable, System.Numerics.IAdditionOperators, System.Numerics.IAdditiveIdentity, System.Numerics.IComparisonOperators, System.Numerics.IDecrementOperators, System.Numerics.IDivisionOperators, System.Numerics.IEqualityOperators, System.Numerics.IIncrementOperators, System.Numerics.IModulusOperators, System.Numerics.IMultiplicativeIdentity, System.Numerics.IMultiplyOperators, System.Numerics.INumberBase, System.Numerics.ISubtractionOperators, System.Numerics.IUnaryNegationOperators, System.Numerics.IUnaryPlusOperators where TSelf : System.Numerics.INumber + public partial interface INumber : System.IComparable, System.IComparable, System.IEquatable, System.IFormattable, System.IParsable, System.ISpanFormattable, System.ISpanParsable, System.Numerics.IAdditionOperators, System.Numerics.IAdditiveIdentity, System.Numerics.IComparisonOperators, System.Numerics.IDecrementOperators, System.Numerics.IDivisionOperators, System.Numerics.IEqualityOperators, System.Numerics.IIncrementOperators, System.Numerics.IModulusOperators, System.Numerics.IMultiplicativeIdentity, System.Numerics.IMultiplyOperators, System.Numerics.INumberBase, System.Numerics.ISubtractionOperators, System.Numerics.IUnaryNegationOperators, System.Numerics.IUnaryPlusOperators where TSelf : System.Numerics.INumber? { static virtual TSelf Clamp(TSelf value, TSelf min, TSelf max) { throw null; } static virtual TSelf CopySign(TSelf value, TSelf sign) { throw null; } @@ -10448,33 +10475,33 @@ public partial interface INumber : System.IComparable, System.IComparable static virtual TSelf MinNumber(TSelf x, TSelf y) { throw null; } static virtual int Sign(TSelf value) { throw null; } } - public partial interface IPowerFunctions : System.Numerics.INumberBase where TSelf : System.Numerics.IPowerFunctions + public partial interface IPowerFunctions : System.Numerics.INumberBase where TSelf : System.Numerics.IPowerFunctions? { static abstract TSelf Pow(TSelf x, TSelf y); } - public partial interface IRootFunctions : System.Numerics.IFloatingPointConstants, System.Numerics.INumberBase where TSelf : System.Numerics.IRootFunctions + public partial interface IRootFunctions : System.Numerics.IFloatingPointConstants, System.Numerics.INumberBase where TSelf : System.Numerics.IRootFunctions? { static abstract TSelf Cbrt(TSelf x); static abstract TSelf Hypot(TSelf x, TSelf y); static abstract TSelf RootN(TSelf x, int n); static abstract TSelf Sqrt(TSelf x); } - public partial interface IShiftOperators where TSelf : System.Numerics.IShiftOperators + public partial interface IShiftOperators where TSelf : System.Numerics.IShiftOperators? { static abstract TResult operator <<(TSelf value, TOther shiftAmount); static abstract TResult operator >>(TSelf value, TOther shiftAmount); static abstract TResult operator >>>(TSelf value, TOther shiftAmount); } - public partial interface ISignedNumber : System.Numerics.INumberBase where TSelf : System.Numerics.ISignedNumber + public partial interface ISignedNumber : System.Numerics.INumberBase where TSelf : System.Numerics.ISignedNumber? { static abstract TSelf NegativeOne { get; } } - public partial interface ISubtractionOperators where TSelf : System.Numerics.ISubtractionOperators + public partial interface ISubtractionOperators where TSelf : System.Numerics.ISubtractionOperators? { static virtual TResult operator checked -(TSelf left, TOther right) { throw null; } static abstract TResult operator -(TSelf left, TOther right); } - public partial interface ITrigonometricFunctions : System.Numerics.IFloatingPointConstants, System.Numerics.INumberBase where TSelf : System.Numerics.ITrigonometricFunctions + public partial interface ITrigonometricFunctions : System.Numerics.IFloatingPointConstants, System.Numerics.INumberBase where TSelf : System.Numerics.ITrigonometricFunctions? { static abstract TSelf Acos(TSelf x); static abstract TSelf AcosPi(TSelf x); @@ -10491,16 +10518,16 @@ public partial interface ITrigonometricFunctions : System.Numerics.IFloat static abstract TSelf Tan(TSelf x); static abstract TSelf TanPi(TSelf x); } - public partial interface IUnaryNegationOperators where TSelf : System.Numerics.IUnaryNegationOperators + public partial interface IUnaryNegationOperators where TSelf : System.Numerics.IUnaryNegationOperators? { static virtual TResult operator checked -(TSelf value) { throw null; } static abstract TResult operator -(TSelf value); } - public partial interface IUnaryPlusOperators where TSelf : System.Numerics.IUnaryPlusOperators + public partial interface IUnaryPlusOperators where TSelf : System.Numerics.IUnaryPlusOperators? { static abstract TResult operator +(TSelf value); } - public partial interface IUnsignedNumber : System.Numerics.INumberBase where TSelf : System.Numerics.IUnsignedNumber + public partial interface IUnsignedNumber : System.Numerics.INumberBase where TSelf : System.Numerics.IUnsignedNumber? { } } diff --git a/src/libraries/System.Runtime/tests/System/Numerics/GenericMathDimHelpers.cs b/src/libraries/System.Runtime/tests/System/Numerics/GenericMathDimHelpers.cs index d6b34be311441..c072ce36ad29f 100644 --- a/src/libraries/System.Runtime/tests/System/Numerics/GenericMathDimHelpers.cs +++ b/src/libraries/System.Runtime/tests/System/Numerics/GenericMathDimHelpers.cs @@ -60,9 +60,9 @@ private BinaryNumberDimHelper(int value) static BinaryNumberDimHelper INumberBase.Parse(string s, NumberStyles style, IFormatProvider? provider) => throw new NotImplementedException(); static BinaryNumberDimHelper ISpanParsable.Parse(ReadOnlySpan s, IFormatProvider? provider) => throw new NotImplementedException(); static BinaryNumberDimHelper IParsable.Parse(string s, IFormatProvider? provider) => throw new NotImplementedException(); - static bool INumberBase.TryConvertToChecked(BinaryNumberDimHelper value, out TOther? result) where TOther : default => throw new NotImplementedException(); - static bool INumberBase.TryConvertToSaturating(BinaryNumberDimHelper value, out TOther? result) where TOther : default => throw new NotImplementedException(); - static bool INumberBase.TryConvertToTruncating(BinaryNumberDimHelper value, out TOther? result) where TOther : default => throw new NotImplementedException(); + static bool INumberBase.TryConvertToChecked(BinaryNumberDimHelper value, out TOther result) where TOther : default => throw new NotImplementedException(); + static bool INumberBase.TryConvertToSaturating(BinaryNumberDimHelper value, out TOther result) where TOther : default => throw new NotImplementedException(); + static bool INumberBase.TryConvertToTruncating(BinaryNumberDimHelper value, out TOther result) where TOther : default => throw new NotImplementedException(); static bool INumberBase.TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out BinaryNumberDimHelper result) => throw new NotImplementedException(); static bool INumberBase.TryParse(string? s, NumberStyles style, IFormatProvider? provider, out BinaryNumberDimHelper result) => throw new NotImplementedException(); static bool ISpanParsable.TryParse(ReadOnlySpan s, IFormatProvider? provider, out BinaryNumberDimHelper result) => throw new NotImplementedException();