Add messages to all InvalidOperationException-s
このコミットが含まれているのは:
1 親
296ca9f6de
コミット
a58e5e8c40
3ファイル変更
+32
-6
検索条件に一致するファイルはありません
@@ -36,7 +36,22 @@ internal static class InvalidOperationExceptionExtensions
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an <see cref="InvalidOperationException"/> for a given parameter name.
|
||||
/// Throws an <see cref="InvalidOperationException"/> if <paramref name="condition"/> is <see langword="true"/>.
|
||||
/// </summary>
|
||||
/// <param name="_">Dummy value to invoke the extension upon (always pass <see langword="null"/>.</param>
|
||||
/// <param name="condition">The condition to decide whether to throw the exception.</param>
|
||||
/// <param name="message">The message to include in the exception.</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void ThrowIf(this InvalidOperationException? _, [DoesNotReturnIf(true)] bool condition, string message)
|
||||
{
|
||||
if (condition)
|
||||
{
|
||||
Throw(message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an <see cref="InvalidOperationException"/>.
|
||||
/// </summary>
|
||||
/// <exception cref="InvalidOperationException">Always thrown with no parameters.</exception>
|
||||
[DoesNotReturn]
|
||||
@@ -44,4 +59,15 @@ internal static class InvalidOperationExceptionExtensions
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an <see cref="InvalidOperationException"/> with a given message.
|
||||
/// </summary>
|
||||
/// <param name="message">The message to include in the exception.</param>
|
||||
/// <exception cref="InvalidOperationException">Always thrown with no parameters.</exception>
|
||||
[DoesNotReturn]
|
||||
private static void Throw(string message)
|
||||
{
|
||||
throw new InvalidOperationException(message);
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする