You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Improve ArgumentOutOfRange exception in Math.Clamp (#118824)
* Improve ArgumentOutOfRange exception in Math.Clamp
Replaces e.g. "System.ArgumentException: '0' cannot be greater than -2."
with
System.ArgumentException: 'minValue = 0' cannot be greater than maxValue
= -2
This follows the behavior of System.Math.Random
Fix#115337
* Update src/libraries/System.Private.CoreLib/src/System/Math.cs
Co-authored-by: skyoxZ <skyoxZ@qq.com>
* Follow suggestions from GH comments and code quality rules
* Apply the Math.cs change to BigInteger.Clamp
* Use 'nameof'
* Update src/libraries/System.Private.CoreLib/src/System/Math.cs
Co-authored-by: kasperk81 <83082615+kasperk81@users.noreply.github.com>
* Applied suggestions from GH comments
* Use ArgumentOutOfRangeException.ThrowLess in Math.cs and BigInteger.cs
* Replace Math.ThrowMinMaxException with available method in ArgumentOutOfRangeException: ThrowIfLessThan
* Add back Math.ThrowMinMaxException(min, max)
This is to support throwing the error from INumber.Clamp as
ArgumentOutOfRangeException.ThrowIfLessThan has a type constraint
IComparable<T> so it cannot be used with nullable types.
All other places use ArgumentOutOfRangeException.ThrowIfLessThan
directly.
* Fixed typo in Math.ThrowMinMaxException
* Fixed tests for Math.Clamp
Assert that Math.Clamp throws ArgumentOutOfRangeException
* Fix the param name in the test so they pass
* Remove Argument_MinMaxValue as it is no longer used
---------
Co-authored-by: skyoxZ <skyoxZ@qq.com>
Co-authored-by: = <=>
Co-authored-by: kasperk81 <83082615+kasperk81@users.noreply.github.com>
<value>With the AllowHexSpecifier bit set in the enum bit field, the only other valid bits that can be combined into the enum value must be a subset of those in HexNumber.</value>
0 commit comments