public virtual object? ActualValue => _actualValue;
[DoesNotReturn]
- private static void ThrowZero<T>(string? paramName, T value) =>
+ private static void ThrowZero<T>(T value, string? paramName) =>
throw new ArgumentOutOfRangeException(paramName, value, SR.Format(SR.ArgumentOutOfRange_Generic_MustBeNonZero, paramName, value));
[DoesNotReturn]
- private static void ThrowNegative<T>(string? paramName, T value) =>
+ private static void ThrowNegative<T>(T value, string? paramName) =>
throw new ArgumentOutOfRangeException(paramName, value, SR.Format(SR.ArgumentOutOfRange_Generic_MustBeNonNegative, paramName, value));
[DoesNotReturn]
- private static void ThrowNegativeOrZero<T>(string? paramName, T value) =>
+ private static void ThrowNegativeOrZero<T>(T value, string? paramName) =>
throw new ArgumentOutOfRangeException(paramName, value, SR.Format(SR.ArgumentOutOfRange_Generic_MustBeNonNegativeNonZero, paramName, value));
[DoesNotReturn]
- private static void ThrowGreater<T>(string? paramName, T value, T other) =>
+ private static void ThrowGreater<T>(T value, T other, string? paramName) =>
throw new ArgumentOutOfRangeException(paramName, value, SR.Format(SR.ArgumentOutOfRange_Generic_MustBeLessOrEqual, paramName, value, other));
[DoesNotReturn]
- private static void ThrowGreaterEqual<T>(string? paramName, T value, T other) =>
+ private static void ThrowGreaterEqual<T>(T value, T other, string? paramName) =>
throw new ArgumentOutOfRangeException(paramName, value, SR.Format(SR.ArgumentOutOfRange_Generic_MustBeLess, paramName, value, other));
[DoesNotReturn]
- private static void ThrowLess<T>(string? paramName, T value, T other) =>
+ private static void ThrowLess<T>(T value, T other, string? paramName) =>
throw new ArgumentOutOfRangeException(paramName, value, SR.Format(SR.ArgumentOutOfRange_Generic_MustBeGreaterOrEqual, paramName, value, other));
[DoesNotReturn]
- private static void ThrowLessEqual<T>(string? paramName, T value, T other) =>
+ private static void ThrowLessEqual<T>(T value, T other, string? paramName) =>
throw new ArgumentOutOfRangeException(paramName, value, SR.Format(SR.ArgumentOutOfRange_Generic_MustBeGreater, paramName, value, other));
[DoesNotReturn]
- private static void ThrowEqual<T>(string? paramName, T value, T other) =>
+ private static void ThrowEqual<T>(T value, T other, string? paramName) =>
throw new ArgumentOutOfRangeException(paramName, value, SR.Format(SR.ArgumentOutOfRange_Generic_MustBeNotEqual, paramName, (object?)value ?? "null", (object?)other ?? "null"));
[DoesNotReturn]
- private static void ThrowNotEqual<T>(string? paramName, T value, T other) =>
+ private static void ThrowNotEqual<T>(T value, T other, string? paramName) =>
throw new ArgumentOutOfRangeException(paramName, value, SR.Format(SR.ArgumentOutOfRange_Generic_MustBeEqual, paramName, (object?)value ?? "null", (object?)other ?? "null"));
/// <summary>Throws an <see cref="ArgumentOutOfRangeException"/> if <paramref name="value"/> is zero.</summary>
where T : INumberBase<T>
{
if (T.IsZero(value))
- ThrowZero(paramName, value);
+ ThrowZero(value, paramName);
}
/// <summary>Throws an <see cref="ArgumentOutOfRangeException"/> if <paramref name="value"/> is negative.</summary>
where T : INumberBase<T>
{
if (T.IsNegative(value))
- ThrowNegative(paramName, value);
+ ThrowNegative(value, paramName);
}
/// <summary>Throws an <see cref="ArgumentOutOfRangeException"/> if <paramref name="value"/> is negative or zero.</summary>
where T : INumberBase<T>
{
if (T.IsNegative(value) || T.IsZero(value))
- ThrowNegativeOrZero(paramName, value);
+ ThrowNegativeOrZero(value, paramName);
}
/// <summary>Throws an <see cref="ArgumentOutOfRangeException"/> if <paramref name="value"/> is equal to <paramref name="other"/>.</summary>
public static void ThrowIfEqual<T>(T value, T other, [CallerArgumentExpression(nameof(value))] string? paramName = null) where T : IEquatable<T>?
{
if (EqualityComparer<T>.Default.Equals(value, other))
- ThrowEqual(paramName, value, other);
+ ThrowEqual(value, other, paramName);
}
/// <summary>Throws an <see cref="ArgumentOutOfRangeException"/> if <paramref name="value"/> is not equal to <paramref name="other"/>.</summary>
public static void ThrowIfNotEqual<T>(T value, T other, [CallerArgumentExpression(nameof(value))] string? paramName = null) where T : IEquatable<T>?
{
if (!EqualityComparer<T>.Default.Equals(value, other))
- ThrowNotEqual(paramName, value, other);
+ ThrowNotEqual(value, other, paramName);
}
/// <summary>Throws an <see cref="ArgumentOutOfRangeException"/> if <paramref name="value"/> is greater than <paramref name="other"/>.</summary>
where T : IComparable<T>
{
if (value.CompareTo(other) > 0)
- ThrowGreater(paramName, value, other);
+ ThrowGreater(value, other, paramName);
}
/// <summary>Throws an <see cref="ArgumentOutOfRangeException"/> if <paramref name="value"/> is greater than or equal <paramref name="other"/>.</summary>
where T : IComparable<T>
{
if (value.CompareTo(other) >= 0)
- ThrowGreaterEqual(paramName, value, other);
+ ThrowGreaterEqual(value, other, paramName);
}
/// <summary>Throws an <see cref="ArgumentOutOfRangeException"/> if <paramref name="value"/> is less than <paramref name="other"/>.</summary>
where T : IComparable<T>
{
if (value.CompareTo(other) < 0)
- ThrowLess(paramName, value, other);
+ ThrowLess(value, other, paramName);
}
/// <summary>Throws an <see cref="ArgumentOutOfRangeException"/> if <paramref name="value"/> is less than or equal <paramref name="other"/>.</summary>
where T : IComparable<T>
{
if (value.CompareTo(other) <= 0)
- ThrowLessEqual(paramName, value, other);
+ ThrowLessEqual(value, other, paramName);
}
}
}