diff --git a/src/libraries/System.Private.CoreLib/src/System/ArgumentOutOfRangeException.cs b/src/libraries/System.Private.CoreLib/src/System/ArgumentOutOfRangeException.cs index f59f360286b7eb..f4fb49058a998c 100644 --- a/src/libraries/System.Private.CoreLib/src/System/ArgumentOutOfRangeException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/ArgumentOutOfRangeException.cs @@ -157,7 +157,7 @@ public static void ThrowIfNegativeOrZero(T value, [CallerArgumentExpression(n /// The argument to validate as not equal to . /// The value to compare with . /// The name of the parameter with which corresponds. - public static void ThrowIfEqual(T value, T other, [CallerArgumentExpression(nameof(value))] string? paramName = null) where T : IEquatable? + public static void ThrowIfEqual(T value, T other, [CallerArgumentExpression(nameof(value))] string? paramName = null) { if (EqualityComparer.Default.Equals(value, other)) ThrowEqual(value, other, paramName); @@ -167,7 +167,7 @@ public static void ThrowIfEqual(T value, T other, [CallerArgumentExpression(n /// The argument to validate as equal to . /// The value to compare with . /// The name of the parameter with which corresponds. - public static void ThrowIfNotEqual(T value, T other, [CallerArgumentExpression(nameof(value))] string? paramName = null) where T : IEquatable? + public static void ThrowIfNotEqual(T value, T other, [CallerArgumentExpression(nameof(value))] string? paramName = null) { if (!EqualityComparer.Default.Equals(value, other)) ThrowNotEqual(value, other, paramName); diff --git a/src/libraries/System.Runtime/ref/System.Runtime.cs b/src/libraries/System.Runtime/ref/System.Runtime.cs index 9f7001057f0b7b..40bc08a108bd0f 100644 --- a/src/libraries/System.Runtime/ref/System.Runtime.cs +++ b/src/libraries/System.Runtime/ref/System.Runtime.cs @@ -474,14 +474,14 @@ public ArgumentOutOfRangeException(string? paramName, string? message) { } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")] public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } - public static void ThrowIfEqual(T value, T other, [System.Runtime.CompilerServices.CallerArgumentExpressionAttribute("value")] string? paramName = null) where T : System.IEquatable? { } + public static void ThrowIfEqual(T value, T other, [System.Runtime.CompilerServices.CallerArgumentExpressionAttribute("value")] string? paramName = null) { } public static void ThrowIfGreaterThanOrEqual(T value, T other, [System.Runtime.CompilerServices.CallerArgumentExpressionAttribute("value")] string? paramName = null) where T : System.IComparable { } public static void ThrowIfGreaterThan(T value, T other, [System.Runtime.CompilerServices.CallerArgumentExpressionAttribute("value")] string? paramName = null) where T : System.IComparable { } public static void ThrowIfLessThanOrEqual(T value, T other, [System.Runtime.CompilerServices.CallerArgumentExpressionAttribute("value")] string? paramName = null) where T : System.IComparable { } public static void ThrowIfLessThan(T value, T other, [System.Runtime.CompilerServices.CallerArgumentExpressionAttribute("value")] string? paramName = null) where T : System.IComparable { } public static void ThrowIfNegativeOrZero(T value, [System.Runtime.CompilerServices.CallerArgumentExpressionAttribute("value")] string? paramName = null) where T : System.Numerics.INumberBase { } public static void ThrowIfNegative(T value, [System.Runtime.CompilerServices.CallerArgumentExpressionAttribute("value")] string? paramName = null) where T : System.Numerics.INumberBase { } - public static void ThrowIfNotEqual(T value, T other, [System.Runtime.CompilerServices.CallerArgumentExpressionAttribute("value")] string? paramName = null) where T : System.IEquatable? { } + public static void ThrowIfNotEqual(T value, T other, [System.Runtime.CompilerServices.CallerArgumentExpressionAttribute("value")] string? paramName = null) { } public static void ThrowIfZero(T value, [System.Runtime.CompilerServices.CallerArgumentExpressionAttribute("value")] string? paramName = null) where T : System.Numerics.INumberBase { } } public partial class ArithmeticException : System.SystemException diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/ArgumentOutOfRangeExceptionTests.cs b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/ArgumentOutOfRangeExceptionTests.cs index 7fc6828e9dfdc4..e9e1ea6a4d1ab0 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/ArgumentOutOfRangeExceptionTests.cs +++ b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/ArgumentOutOfRangeExceptionTests.cs @@ -74,8 +74,8 @@ public static void Ctor_String_Object_String() private static Action GreaterThanOrEqualHelper(T value, T other) where T : IComparable => () => ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(value, other); private static Action LessThanHelper(T value, T other) where T : IComparable => () => ArgumentOutOfRangeException.ThrowIfLessThan(value, other); private static Action LessThanOrEqualHelper(T value, T other) where T : IComparable => () => ArgumentOutOfRangeException.ThrowIfLessThanOrEqual(value, other); - private static Action EqualHelper(T value, T other) where T : IEquatable => () => ArgumentOutOfRangeException.ThrowIfEqual(value, other); - private static Action NotEqualHelper(T value, T other) where T : IEquatable => () => ArgumentOutOfRangeException.ThrowIfNotEqual(value, other); + private static Action EqualHelper(T value, T other) => () => ArgumentOutOfRangeException.ThrowIfEqual(value, other); + private static Action NotEqualHelper(T value, T other) => () => ArgumentOutOfRangeException.ThrowIfNotEqual(value, other); [Fact] public static void GenericHelpers_ThrowIfZero_Throws()