Add and use ArgumentOutOfRangeExceptionExtensions.ThrowIfNotZero
このコミットが含まれているのは:
1 親
1c6f144064
コミット
e4c7b5161c
3ファイル変更
+16
-4
検索条件に一致するファイルはありません
@@ -8,6 +8,20 @@ namespace System;
|
||||
/// </summary>
|
||||
internal static class ArgumentOutOfRangeExceptionExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Throws an <see cref="ArgumentOutOfRangeException"/> if <paramref name="value"/> is not zero.
|
||||
/// </summary>
|
||||
/// <param name="_">Dummy value to invoke the extension upon (always pass <see langword="null"/>.</param>
|
||||
/// <param name="value">The argument to validate as zero.</param>
|
||||
/// <param name="parameterName">The name of the parameter with which <paramref name="value"/> corresponds.</param>
|
||||
public static void ThrowIfNotZero(this ArgumentOutOfRangeException? _, int value, [CallerArgumentExpression(nameof(value))] string? parameterName = null)
|
||||
{
|
||||
if (value != 0)
|
||||
{
|
||||
Throw(parameterName, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an <see cref="ArgumentOutOfRangeException"/> if <paramref name="value"/> is negative.
|
||||
/// </summary>
|
||||
|
||||
@@ -2,7 +2,6 @@ using System;
|
||||
using System.Buffers;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.CompilerServices;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Graphics.Extensions;
|
||||
using ComputeSharp.Graphics.Helpers;
|
||||
@@ -192,7 +191,7 @@ public abstract unsafe partial class TransferBuffer<T> : IReferenceTrackedObject
|
||||
/// <inheritdoc/>
|
||||
public override MemoryHandle Pin(int elementIndex = 0)
|
||||
{
|
||||
Guard.IsEqualTo(elementIndex, 0);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotZero(elementIndex);
|
||||
|
||||
using ReferenceTracker.Lease _0 = this.buffer.GetReferenceTracker().GetLease();
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Runtime.CompilerServices;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Graphics.Extensions;
|
||||
using ComputeSharp.Graphics.Helpers;
|
||||
@@ -197,7 +196,7 @@ public abstract unsafe partial class TransferTexture1D<T> : IReferenceTrackedObj
|
||||
/// <inheritdoc/>
|
||||
public override MemoryHandle Pin(int elementIndex = 0)
|
||||
{
|
||||
Guard.IsEqualTo(elementIndex, 0);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotZero(elementIndex);
|
||||
|
||||
using ReferenceTracker.Lease _0 = this.buffer.GetReferenceTracker().GetLease();
|
||||
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする