diff --git a/src/ComputeSharp.Core/Polyfills/ArgumentOutOfRangeExceptionExtensions.cs b/src/ComputeSharp.Core/Polyfills/ArgumentOutOfRangeExceptionExtensions.cs
index 3f66f9be..0e2d4cb0 100644
--- a/src/ComputeSharp.Core/Polyfills/ArgumentOutOfRangeExceptionExtensions.cs
+++ b/src/ComputeSharp.Core/Polyfills/ArgumentOutOfRangeExceptionExtensions.cs
@@ -8,6 +8,20 @@ namespace System;
///
internal static class ArgumentOutOfRangeExceptionExtensions
{
+ ///
+ /// Throws an if is not zero.
+ ///
+ /// Dummy value to invoke the extension upon (always pass .
+ /// The argument to validate as zero.
+ /// The name of the parameter with which corresponds.
+ public static void ThrowIfNotZero(this ArgumentOutOfRangeException? _, int value, [CallerArgumentExpression(nameof(value))] string? parameterName = null)
+ {
+ if (value != 0)
+ {
+ Throw(parameterName, value);
+ }
+ }
+
///
/// Throws an if is negative.
///
diff --git a/src/ComputeSharp/Graphics/Resources/Abstract/TransferBuffer{T}.cs b/src/ComputeSharp/Graphics/Resources/Abstract/TransferBuffer{T}.cs
index a41710ef..9e4cbffe 100644
--- a/src/ComputeSharp/Graphics/Resources/Abstract/TransferBuffer{T}.cs
+++ b/src/ComputeSharp/Graphics/Resources/Abstract/TransferBuffer{T}.cs
@@ -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 : IReferenceTrackedObject
///
public override MemoryHandle Pin(int elementIndex = 0)
{
- Guard.IsEqualTo(elementIndex, 0);
+ default(ArgumentOutOfRangeException).ThrowIfNotZero(elementIndex);
using ReferenceTracker.Lease _0 = this.buffer.GetReferenceTracker().GetLease();
diff --git a/src/ComputeSharp/Graphics/Resources/Abstract/TransferTexture1D{T}.cs b/src/ComputeSharp/Graphics/Resources/Abstract/TransferTexture1D{T}.cs
index 762bc93a..0b985869 100644
--- a/src/ComputeSharp/Graphics/Resources/Abstract/TransferTexture1D{T}.cs
+++ b/src/ComputeSharp/Graphics/Resources/Abstract/TransferTexture1D{T}.cs
@@ -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 : IReferenceTrackedObj
///
public override MemoryHandle Pin(int elementIndex = 0)
{
- Guard.IsEqualTo(elementIndex, 0);
+ default(ArgumentOutOfRangeException).ThrowIfNotZero(elementIndex);
using ReferenceTracker.Lease _0 = this.buffer.GetReferenceTracker().GetLease();