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);
|
||||
}
|
||||
}
|
||||
@@ -80,7 +80,7 @@ partial class CanvasEffect
|
||||
{
|
||||
default(ArgumentNullException).ThrowIfNull(canvasImage);
|
||||
default(InvalidOperationException).ThrowIf(this.owner is null);
|
||||
default(InvalidOperationException).ThrowIf(this.owner.invalidationType != InvalidationType.Creation);
|
||||
default(InvalidOperationException).ThrowIf(this.owner.invalidationType != InvalidationType.Creation, "The effect graph cannot be modified after its creation.");
|
||||
|
||||
// Use a new dummy object as key to register the anonymous effect node. This is cheaper than having to maintain a different
|
||||
// data structure (eg. a HashSet<ICanvasImage> instance) just to hold the anonymous effects that may be registered. This way,
|
||||
@@ -109,7 +109,7 @@ partial class CanvasEffect
|
||||
default(ArgumentNullException).ThrowIfNull(effectNode);
|
||||
default(ArgumentNullException).ThrowIfNull(canvasImage);
|
||||
default(InvalidOperationException).ThrowIf(this.owner is null);
|
||||
default(InvalidOperationException).ThrowIf(this.owner.invalidationType != InvalidationType.Creation);
|
||||
default(InvalidOperationException).ThrowIf(this.owner.invalidationType != InvalidationType.Creation, "The effect graph cannot be modified after its creation.");
|
||||
|
||||
// Try to add the new canvas image associated with the input effect node marker.
|
||||
// This must not have been previously added from another RegisterNode call.
|
||||
@@ -138,7 +138,7 @@ partial class CanvasEffect
|
||||
{
|
||||
default(ArgumentNullException).ThrowIfNull(canvasImage);
|
||||
default(InvalidOperationException).ThrowIf(this.owner is null);
|
||||
default(InvalidOperationException).ThrowIf(this.owner.invalidationType != InvalidationType.Creation);
|
||||
default(InvalidOperationException).ThrowIf(this.owner.invalidationType != InvalidationType.Creation, "The effect graph cannot be modified after its creation.");
|
||||
|
||||
// Register the anonymous effect node with a dummy object, same as above
|
||||
_ = this.owner.transformNodes.TryAdd(new object(), canvasImage);
|
||||
@@ -158,7 +158,7 @@ partial class CanvasEffect
|
||||
default(ArgumentNullException).ThrowIfNull(effectNode);
|
||||
default(ArgumentNullException).ThrowIfNull(canvasImage);
|
||||
default(InvalidOperationException).ThrowIf(this.owner is null);
|
||||
default(InvalidOperationException).ThrowIf(this.owner.invalidationType != InvalidationType.Creation);
|
||||
default(InvalidOperationException).ThrowIf(this.owner.invalidationType != InvalidationType.Creation, "The effect graph cannot be modified after its creation.");
|
||||
|
||||
// Try to add the output node as in the method above (but with an extra check before doing so)
|
||||
if (!this.owner.transformNodes.TryAdd(effectNode, canvasImage))
|
||||
|
||||
@@ -97,7 +97,7 @@ unsafe partial class CanvasEffect
|
||||
|
||||
// At this point, there must be an output canvas image being set.
|
||||
// If not, it means a derived type has forgot to set an output node.
|
||||
default(InvalidOperationException).ThrowIf(this.canvasImage is null);
|
||||
default(InvalidOperationException).ThrowIf(this.canvasImage is null, "No output node is set in the effect graph.");
|
||||
|
||||
return this.canvasImage;
|
||||
}
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする