Add and use ArgumentOutOfRangeException.ThrowIfLessThan
このコミットが含まれているのは:
1 親
b00fc5d9d4
コミット
7a5daf0a61
4ファイル変更
+36
-9
検索条件に一致するファイルはありません
@@ -53,6 +53,36 @@ internal static class ArgumentOutOfRangeExceptionExtensions
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an <see cref="ArgumentOutOfRangeException"/> if <paramref name="value"/> is less than <paramref name="other"/>.
|
||||
/// </summary>
|
||||
/// <param name="_">Dummy value to invoke the extension upon (always pass <see langword="null"/>.</param>
|
||||
/// <param name="value">The argument to validate as less or equal than <paramref name="other"/>.</param>
|
||||
/// <param name="other">The value to compare with <paramref name="value"/>.</param>
|
||||
/// <param name="parameterName">The name of the parameter with which <paramref name="value"/> corresponds.</param>
|
||||
public static void ThrowIfLessThan(this ArgumentOutOfRangeException? _, int value, int other, [CallerArgumentExpression(nameof(value))] string? parameterName = null)
|
||||
{
|
||||
if (value < other)
|
||||
{
|
||||
Throw(parameterName, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an <see cref="ArgumentOutOfRangeException"/> if <paramref name="value"/> is less than <paramref name="other"/>.
|
||||
/// </summary>
|
||||
/// <param name="_">Dummy value to invoke the extension upon (always pass <see langword="null"/>.</param>
|
||||
/// <param name="value">The argument to validate as less or equal than <paramref name="other"/>.</param>
|
||||
/// <param name="other">The value to compare with <paramref name="value"/>.</param>
|
||||
/// <param name="parameterName">The name of the parameter with which <paramref name="value"/> corresponds.</param>
|
||||
public static void ThrowIfLessThan(this ArgumentOutOfRangeException? _, long value, long other, [CallerArgumentExpression(nameof(value))] string? parameterName = null)
|
||||
{
|
||||
if (value < other)
|
||||
{
|
||||
Throw(parameterName, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an <see cref="ArgumentOutOfRangeException"/> if <paramref name="value"/> is not in the specified range.
|
||||
/// </summary>
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする