Add and use ArgumentOutOfRangeException.ThrowIfNotInRange
このコミットが含まれているのは:
1 親
98fb8e68ce
コミット
56031f443a
8ファイル変更
+88
-69
検索条件に一致するファイルはありません
@@ -38,6 +38,23 @@ internal static class ArgumentOutOfRangeExceptionExtensions
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an <see cref="ArgumentOutOfRangeException"/> if <paramref name="value"/> is not in the specified range.
|
||||
/// </summary>
|
||||
/// <param name="_">Dummy value to invoke the extension upon (always pass <see langword="null"/>.</param>
|
||||
/// <param name="value">The argument to validate as non-zero or non-negative.</param>
|
||||
/// <param name="minimum">The inclusive starting value for the range.</param>
|
||||
/// <param name="maximum">The exclusive ending value for the range.</param>
|
||||
/// <param name="parameterName">The name of the parameter with which <paramref name="value"/> corresponds.</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void ThrowIfNotInRange(this ArgumentOutOfRangeException? _, int value, int minimum, int maximum, [CallerArgumentExpression(nameof(value))] string? parameterName = null)
|
||||
{
|
||||
if (value < minimum || value >= maximum)
|
||||
{
|
||||
Throw(parameterName, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an <see cref="ArgumentOutOfRangeException"/> for a given parameter name.
|
||||
/// </summary>
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする