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
The current main branch code-base added some support to classes to OutOfRange, but not for Nullable.
privatestaticvoidTestStruct(intx){
Guard.Against.OutOfRange(x, nameof(x),-10,10);// OK
Guard.Against.OutOfRange<int>(x, nameof(x),-10,10);// OK}privatestaticvoidTestNullableStruct(int?x){
Guard.Against.OutOfRange(x, nameof(x),-10,10);// Compiler Error
Guard.Against.OutOfRange<int?>(x, nameof(x),-10,10);// Compiler Error}privatestaticvoidTestClass(Versionx){varfirstVersion=new Version(1,0);varcuurentVersion=new Version(10,0);
Guard.Against.OutOfRange(x, nameof(x), firstVersion, cuurentVersion);// Compilation OK, but NullReferenceException in Runtime when x is null
Guard.Against.OutOfRange<Version>(x, nameof(x), firstVersion, cuurentVersion);// Compilation OK, but NullReferenceException in Runtime when x is null}privatestaticvoidTestClassWithNull(Versionx){varfirstVersion=new Version(1,0);varcuurentVersion=new Version(10,0);
Guard.Against.OutOfRange((Version)null, nameof(x), firstVersion, cuurentVersion);// Compilation OK, but NullReferenceException in Runtime when x is null
Guard.Against.OutOfRange<Version>((Version)null, nameof(x), firstVersion, cuurentVersion);// Compilation OK, but NullReferenceException in Runtime when x is null
Guard.Against.OutOfRange(null, nameof(x), firstVersion, cuurentVersion);// Compiler Error
Guard.Against.OutOfRange<Version>(null, nameof(x), firstVersion, cuurentVersion);// Compiler Error}
GuardClauses could add a NullOrOutOfRange clause to add support to Nullable classes/structs. And checking the input parameter fo null values, thowing ArgumentNullException insted of a NullReferenceException.
The current 3.2.0 Nuget Release. Don't have any support for
Nullable
classes/structs toOutOfRange
The current
main
branch code-base added some support to classes toOutOfRange
, but not forNullable
.GuardClauses could add a
NullOrOutOfRange
clause to add support to Nullable classes/structs. And checking theinput
parameter fo null values, thowingArgumentNullException
insted of aNullReferenceException
.See this dotnetfiddle https://dotnetfiddle.net/nbXa8U
Kind Related: #139
The text was updated successfully, but these errors were encountered: