diff --git a/X10D/src/ComparableExtensions/ComparableExtensions.cs b/X10D/src/ComparableExtensions/ComparableExtensions.cs index dd7615e..5454a87 100644 --- a/X10D/src/ComparableExtensions/ComparableExtensions.cs +++ b/X10D/src/ComparableExtensions/ComparableExtensions.cs @@ -125,6 +125,11 @@ namespace X10D public static bool GreaterThan(this T1 value, T2 other) where T1 : IComparable { + if (value is null) + { + throw new ArgumentNullException(nameof(value)); + } + return value.CompareTo(other) > 0; } @@ -152,6 +157,11 @@ namespace X10D public static bool GreaterThanOrEqualTo(this T1 value, T2 other) where T1 : IComparable { + if (value is null) + { + throw new ArgumentNullException(nameof(value)); + } + return value.CompareTo(other) >= 0; } @@ -179,6 +189,11 @@ namespace X10D public static bool LessThan(this T1 value, T2 other) where T1 : IComparable { + if (value is null) + { + throw new ArgumentNullException(nameof(value)); + } + return value.CompareTo(other) < 0; } @@ -206,6 +221,11 @@ namespace X10D public static bool LessThanOrEqualTo(this T1 value, T2 other) where T1 : IComparable { + if (value is null) + { + throw new ArgumentNullException(nameof(value)); + } + return value.CompareTo(other) <= 0; } @@ -232,6 +252,11 @@ namespace X10D public static T Max(this T value, T other) where T : IComparable { + if (value is null) + { + throw new ArgumentNullException(nameof(value)); + } + return value.GreaterThan(other) ? value : other; } @@ -258,6 +283,11 @@ namespace X10D public static T Min(this T value, T other) where T : IComparable { + if (value is null) + { + throw new ArgumentNullException(nameof(value)); + } + return value.LessThan(other) ? value : other; } }