diff --git a/src/ComputeSharp.Core/Polyfills/ArgumentExceptionExtensions.cs b/src/ComputeSharp.Core/Polyfills/ArgumentExceptionExtensions.cs
index e2782394..7ba9a88f 100644
--- a/src/ComputeSharp.Core/Polyfills/ArgumentExceptionExtensions.cs
+++ b/src/ComputeSharp.Core/Polyfills/ArgumentExceptionExtensions.cs
@@ -8,6 +8,32 @@ namespace System;
///
internal static class ArgumentExceptionExtensions
{
+ ///
+ /// Throws an for a given parameter name.
+ ///
+ /// Dummy value to invoke the extension upon (always pass .
+ /// The name of the parameter to report in the exception.
+ /// Thrown with .
+ [DoesNotReturn]
+ public static void Throw(this ArgumentException? _, string? parameterName)
+ {
+ throw new ArgumentException(null, parameterName);
+ }
+
+ ///
+ /// Throws an for a given parameter name.
+ ///
+ /// The type to let the compiler assume it returns.
+ /// Dummy value to invoke the extension upon (always pass .
+ /// The name of the parameter to report in the exception.
+ /// This method never returns any values.
+ /// Thrown with .
+ [DoesNotReturn]
+ public static T Throw(this ArgumentException? _, string? parameterName)
+ {
+ throw new ArgumentException(null, parameterName);
+ }
+
///
/// Throws an if is .
///
@@ -31,6 +57,6 @@ internal static class ArgumentExceptionExtensions
[DoesNotReturn]
private static void Throw(string? parameterName)
{
- throw new ArgumentException(parameterName);
+ throw new ArgumentException(null, parameterName);
}
}
diff --git a/src/ComputeSharp/Core/Attributes/EmbeddedBytecodeAttribute.cs b/src/ComputeSharp/Core/Attributes/EmbeddedBytecodeAttribute.cs
index ec80ea6f..f614e7c9 100644
--- a/src/ComputeSharp/Core/Attributes/EmbeddedBytecodeAttribute.cs
+++ b/src/ComputeSharp/Core/Attributes/EmbeddedBytecodeAttribute.cs
@@ -1,7 +1,4 @@
using System;
-#if !SOURCE_GENERATOR
-using CommunityToolkit.Diagnostics;
-#endif
namespace ComputeSharp;
@@ -64,7 +61,7 @@ public sealed class EmbeddedBytecodeAttribute : Attribute
DispatchAxis.XZ => (8, 1, 8),
DispatchAxis.YZ => (1, 8, 8),
DispatchAxis.XYZ => (4, 4, 4),
- _ => ThrowHelper.ThrowArgumentException<(int, int, int)>(nameof(dispatchAxis), "Invalid dispatch axis value.")
+ _ => default(ArgumentException).Throw<(int, int, int)>(nameof(dispatchAxis))
};
#endif
}
diff --git a/src/ComputeSharp/Graphics/Exceptions/UnsupportedTextureTypeException.cs b/src/ComputeSharp/Graphics/Exceptions/UnsupportedTextureTypeException.cs
index 4d4c5863..25ab893d 100644
--- a/src/ComputeSharp/Graphics/Exceptions/UnsupportedTextureTypeException.cs
+++ b/src/ComputeSharp/Graphics/Exceptions/UnsupportedTextureTypeException.cs
@@ -1,6 +1,5 @@
using System;
using System.Text;
-using CommunityToolkit.Diagnostics;
namespace ComputeSharp.Exceptions;
@@ -36,7 +35,7 @@ public sealed class UnsupportedTextureTypeException : NotSupportedException
1 => $"{nameof(GraphicsDevice.IsReadOnlyTexture1DSupportedForType)}() or {nameof(GraphicsDevice)}.{nameof(GraphicsDevice.IsReadWriteTexture1DSupportedForType)}().",
2 => $"{nameof(GraphicsDevice.IsReadOnlyTexture2DSupportedForType)}() or {nameof(GraphicsDevice)}.{nameof(GraphicsDevice.IsReadWriteTexture2DSupportedForType)}().",
3 => $"{nameof(GraphicsDevice.IsReadOnlyTexture3DSupportedForType)}() or {nameof(GraphicsDevice)}.{nameof(GraphicsDevice.IsReadWriteTexture3DSupportedForType)}().",
- _ => ThrowHelper.ThrowArgumentException("Invalid texture rank.")
+ _ => default(ArgumentException).Throw(nameof(rank))
});
_ = builder.Append("As a possible workaround on older devices, consider using a texture type of lower rank, or a linear buffer.");
diff --git a/src/ComputeSharp/Graphics/Extensions/Interop/AllocatorExtensions.cs b/src/ComputeSharp/Graphics/Extensions/Interop/AllocatorExtensions.cs
index cc66f091..973b978d 100644
--- a/src/ComputeSharp/Graphics/Extensions/Interop/AllocatorExtensions.cs
+++ b/src/ComputeSharp/Graphics/Extensions/Interop/AllocatorExtensions.cs
@@ -1,6 +1,6 @@
#if NET6_0_OR_GREATER
-using CommunityToolkit.Diagnostics;
+using System;
using ComputeSharp.Core.Extensions;
using TerraFX.Interop.DirectX;
using TerraFX.Interop.Windows;
@@ -66,7 +66,7 @@ internal static unsafe class AllocatorExtensions
ResourceType.ReadWrite => (D3D12_HEAP_TYPE_DEFAULT, D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COMMON),
ResourceType.ReadBack => (D3D12_HEAP_TYPE_READBACK, D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_COPY_DEST),
ResourceType.Upload => (D3D12_HEAP_TYPE_UPLOAD, D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_GENERIC_READ),
- _ => ThrowHelper.ThrowArgumentException<(D3D12_HEAP_TYPE, D3D12_RESOURCE_FLAGS, D3D12_RESOURCE_STATES)>()
+ _ => default(ArgumentException).Throw<(D3D12_HEAP_TYPE, D3D12_RESOURCE_FLAGS, D3D12_RESOURCE_STATES)>(nameof(resourceType))
};
using ComPtr allocation = default;
@@ -117,7 +117,7 @@ internal static unsafe class AllocatorExtensions
{
ResourceType.ReadOnly => (D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_COMMON),
ResourceType.ReadWrite => (D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_UNORDERED_ACCESS),
- _ => ThrowHelper.ThrowArgumentException<(D3D12_RESOURCE_FLAGS, D3D12_RESOURCE_STATES)>()
+ _ => default(ArgumentException).Throw<(D3D12_RESOURCE_FLAGS, D3D12_RESOURCE_STATES)>(nameof(resourceType))
};
using ComPtr allocation = default;
@@ -170,7 +170,7 @@ internal static unsafe class AllocatorExtensions
{
ResourceType.ReadOnly => (D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_COMMON),
ResourceType.ReadWrite => (D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_UNORDERED_ACCESS),
- _ => ThrowHelper.ThrowArgumentException<(D3D12_RESOURCE_FLAGS, D3D12_RESOURCE_STATES)>()
+ _ => default(ArgumentException).Throw<(D3D12_RESOURCE_FLAGS, D3D12_RESOURCE_STATES)>(nameof(resourceType))
};
using ComPtr allocation = default;
@@ -225,7 +225,7 @@ internal static unsafe class AllocatorExtensions
{
ResourceType.ReadOnly => (D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_COMMON),
ResourceType.ReadWrite => (D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_UNORDERED_ACCESS),
- _ => ThrowHelper.ThrowArgumentException<(D3D12_RESOURCE_FLAGS, D3D12_RESOURCE_STATES)>()
+ _ => default(ArgumentException).Throw<(D3D12_RESOURCE_FLAGS, D3D12_RESOURCE_STATES)>(nameof(resourceType))
};
using ComPtr allocation = default;
diff --git a/src/ComputeSharp/Graphics/Extensions/Interop/ID3D12DeviceExtensions.cs b/src/ComputeSharp/Graphics/Extensions/Interop/ID3D12DeviceExtensions.cs
index 08c1e529..19f04410 100644
--- a/src/ComputeSharp/Graphics/Extensions/Interop/ID3D12DeviceExtensions.cs
+++ b/src/ComputeSharp/Graphics/Extensions/Interop/ID3D12DeviceExtensions.cs
@@ -1,8 +1,6 @@
using System;
#if NET6_0_OR_GREATER
using System.Runtime.CompilerServices;
-#else
-using CommunityToolkit.Diagnostics;
#endif
using ComputeSharp.Core.Extensions;
#if !NET6_0_OR_GREATER
@@ -82,7 +80,7 @@ internal static unsafe class ID3D12DeviceExtensions
ResourceType.ReadWrite => (D3D12_HEAP_TYPE_DEFAULT, D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COMMON),
ResourceType.ReadBack => (D3D12_HEAP_TYPE_READBACK, D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_COPY_DEST),
ResourceType.Upload => (D3D12_HEAP_TYPE_UPLOAD, D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_GENERIC_READ),
- _ => ThrowHelper.ThrowArgumentException<(D3D12_HEAP_TYPE, D3D12_RESOURCE_FLAGS, D3D12_RESOURCE_STATES)>()
+ _ => default(ArgumentException).Throw<(D3D12_HEAP_TYPE, D3D12_RESOURCE_FLAGS, D3D12_RESOURCE_STATES)>(nameof(resourceType))
};
using ComPtr d3D12Resource = default;
@@ -142,7 +140,7 @@ internal static unsafe class ID3D12DeviceExtensions
{
ResourceType.ReadOnly => (D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_COMMON),
ResourceType.ReadWrite => (D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_UNORDERED_ACCESS),
- _ => ThrowHelper.ThrowArgumentException<(D3D12_RESOURCE_FLAGS, D3D12_RESOURCE_STATES)>()
+ _ => default(ArgumentException).Throw<(D3D12_RESOURCE_FLAGS, D3D12_RESOURCE_STATES)>(nameof(resourceType))
};
using ComPtr d3D12Resource = default;
@@ -204,7 +202,7 @@ internal static unsafe class ID3D12DeviceExtensions
{
ResourceType.ReadOnly => (D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_COMMON),
ResourceType.ReadWrite => (D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_UNORDERED_ACCESS),
- _ => ThrowHelper.ThrowArgumentException<(D3D12_RESOURCE_FLAGS, D3D12_RESOURCE_STATES)>()
+ _ => default(ArgumentException).Throw<(D3D12_RESOURCE_FLAGS, D3D12_RESOURCE_STATES)>(nameof(resourceType))
};
using ComPtr d3D12Resource = default;
@@ -268,7 +266,7 @@ internal static unsafe class ID3D12DeviceExtensions
{
ResourceType.ReadOnly => (D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_COMMON),
ResourceType.ReadWrite => (D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_UNORDERED_ACCESS),
- _ => ThrowHelper.ThrowArgumentException<(D3D12_RESOURCE_FLAGS, D3D12_RESOURCE_STATES)>()
+ _ => default(ArgumentException).Throw<(D3D12_RESOURCE_FLAGS, D3D12_RESOURCE_STATES)>(nameof(resourceType))
};
using ComPtr d3D12Resource = default;
diff --git a/src/ComputeSharp/Graphics/GraphicsDevice.Execute.cs b/src/ComputeSharp/Graphics/GraphicsDevice.Execute.cs
index ea8e6097..957ff01a 100644
--- a/src/ComputeSharp/Graphics/GraphicsDevice.Execute.cs
+++ b/src/ComputeSharp/Graphics/GraphicsDevice.Execute.cs
@@ -59,7 +59,7 @@ unsafe partial class GraphicsDevice
d3D12Fence = this.d3D12CopyFence;
d3D12FenceValue = ref this.nextD3D12CopyFenceValue;
break;
- default: ThrowHelper.ThrowArgumentException(); return;
+ default: default(ArgumentException).Throw(nameof(commandList)); return;
}
// Execute the command list
diff --git a/src/ComputeSharp/Graphics/GraphicsDevice.cs b/src/ComputeSharp/Graphics/GraphicsDevice.cs
index 7c2af3eb..08d5cbf1 100644
--- a/src/ComputeSharp/Graphics/GraphicsDevice.cs
+++ b/src/ComputeSharp/Graphics/GraphicsDevice.cs
@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
-using CommunityToolkit.Diagnostics;
using ComputeSharp.Graphics.Commands.Interop;
#if NET6_0_OR_GREATER
using ComputeSharp.Core.Extensions;
@@ -440,7 +439,7 @@ public sealed unsafe partial class GraphicsDevice : IReferenceTrackedObject
this.copyCommandListPool.Rent(this.d3D12Device.Get(), null, out d3D12CommandList, out d3D12CommandAllocator);
break;
default:
- _ = ThrowHelper.ThrowArgumentException>();
+ default(ArgumentException).Throw(nameof(d3D12CommandListType));
d3D12CommandList = null;
d3D12CommandAllocator = null;
break;
diff --git a/src/ComputeSharp/Graphics/Helpers/DXGIFormatHelper.cs b/src/ComputeSharp/Graphics/Helpers/DXGIFormatHelper.cs
index 38be3c55..d0bb296d 100644
--- a/src/ComputeSharp/Graphics/Helpers/DXGIFormatHelper.cs
+++ b/src/ComputeSharp/Graphics/Helpers/DXGIFormatHelper.cs
@@ -1,6 +1,6 @@
+using System;
using System.Numerics;
using System.Runtime.CompilerServices;
-using CommunityToolkit.Diagnostics;
using TerraFX.Interop.DirectX;
using static TerraFX.Interop.DirectX.DXGI_FORMAT;
@@ -46,7 +46,7 @@ internal static class DXGIFormatHelper
if (typeof(T) == typeof(Rg16)) return DXGI_FORMAT_R8G8_UNORM;
if (typeof(T) == typeof(Rg32)) return DXGI_FORMAT_R16G16_UNORM;
- return ThrowHelper.ThrowArgumentException("Invalid texture type.");
+ return default(ArgumentException).Throw(nameof(T));
}
///
@@ -89,7 +89,7 @@ internal static class DXGIFormatHelper
return true;
}
- return ThrowHelper.ThrowArgumentException("Invalid texture type.");
+ return default(ArgumentException).Throw(nameof(T));
}
///
diff --git a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.ID3D12InfoQueue.cs b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.ID3D12InfoQueue.cs
index 2ede7bee..a51063ae 100644
--- a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.ID3D12InfoQueue.cs
+++ b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.ID3D12InfoQueue.cs
@@ -72,17 +72,26 @@ partial class DeviceHelper
// If the device removal reason is available, also include that in the output message
if (result != S.S_OK)
{
- string deviceRemovalReason = (int)result switch
+ string? deviceRemovalReason = (int)result switch
{
DXGI.DXGI_ERROR_DEVICE_HUNG => nameof(DXGI.DXGI_ERROR_DEVICE_HUNG),
DXGI.DXGI_ERROR_DEVICE_REMOVED => nameof(DXGI.DXGI_ERROR_DEVICE_REMOVED),
DXGI.DXGI_ERROR_DEVICE_RESET => nameof(DXGI.DXGI_ERROR_DEVICE_RESET),
DXGI.DXGI_ERROR_DRIVER_INTERNAL_ERROR => nameof(DXGI.DXGI_ERROR_DRIVER_INTERNAL_ERROR),
DXGI.DXGI_ERROR_INVALID_CALL => nameof(DXGI.DXGI_ERROR_INVALID_CALL),
- _ => ThrowHelper.ThrowArgumentOutOfRangeException("Invalid GetDeviceRemovedReason HRESULT.")
+ _ => null
};
- _ = builder.AppendLine($"[Reason]: {deviceRemovalReason}");
+ // If it is a known HRESULT (this should always be the case), print the nicely formatted value
+ if (deviceRemovalReason is not null)
+ {
+ _ = builder.AppendLine($"[Reason]: {deviceRemovalReason}");
+ }
+ else
+ {
+ // Otherwise just format the HRESULT as a hexadecimal number
+ _ = builder.AppendLine($"[Reason]: 0x{(int)result:X8}");
+ }
}
}
diff --git a/src/ComputeSharp/Graphics/Helpers/WICFormatHelper.cs b/src/ComputeSharp/Graphics/Helpers/WICFormatHelper.cs
index fcc39ee1..ec13519f 100644
--- a/src/ComputeSharp/Graphics/Helpers/WICFormatHelper.cs
+++ b/src/ComputeSharp/Graphics/Helpers/WICFormatHelper.cs
@@ -1,6 +1,5 @@
using System;
using System.Runtime.CompilerServices;
-using CommunityToolkit.Diagnostics;
using TerraFX.Interop.Windows;
#if NET6_0_OR_GREATER
using Path = System.IO.Path;
@@ -33,7 +32,7 @@ internal static class WICFormatHelper
if (typeof(T) == typeof(R8)) return GUID.GUID_WICPixelFormat8bppGray;
if (typeof(T) == typeof(R16)) return GUID.GUID_WICPixelFormat16bppGray;
- return ThrowHelper.ThrowArgumentException("Invalid texture type.");
+ return default(ArgumentException).Throw(nameof(T));
}
///
@@ -53,7 +52,7 @@ internal static class WICFormatHelper
else if (typeof(T) == typeof(Rgba64)) intermediateFormat = GUID.GUID_WICPixelFormat32bppBGRA;
else if (typeof(T) == typeof(R8)) intermediateFormat = GUID.GUID_WICPixelFormat24bppBGR;
else if (typeof(T) == typeof(R16)) intermediateFormat = GUID.GUID_WICPixelFormat24bppBGR;
- else intermediateFormat = ThrowHelper.ThrowArgumentException("Invalid texture type.");
+ else intermediateFormat = default(ArgumentException).Throw(nameof(T));
}
else if (containerFormat == GUID.GUID_ContainerFormatPng)
{
@@ -62,7 +61,7 @@ internal static class WICFormatHelper
else if (typeof(T) == typeof(Rgba64)) intermediateFormat = default;
else if (typeof(T) == typeof(R8)) intermediateFormat = default;
else if (typeof(T) == typeof(R16)) intermediateFormat = GUID.GUID_WICPixelFormat8bppGray;
- else intermediateFormat = ThrowHelper.ThrowArgumentException("Invalid texture type.");
+ else intermediateFormat = default(ArgumentException).Throw(nameof(T));
}
else if (containerFormat == GUID.GUID_ContainerFormatJpeg)
{
@@ -71,7 +70,7 @@ internal static class WICFormatHelper
else if (typeof(T) == typeof(Rgba64)) intermediateFormat = GUID.GUID_WICPixelFormat24bppBGR;
else if (typeof(T) == typeof(R8)) intermediateFormat = default;
else if (typeof(T) == typeof(R16)) intermediateFormat = GUID.GUID_WICPixelFormat8bppGray;
- else intermediateFormat = ThrowHelper.ThrowArgumentException("Invalid texture type.");
+ else intermediateFormat = default(ArgumentException).Throw(nameof(T));
}
else if (containerFormat == GUID.GUID_ContainerFormatWmp)
{
@@ -80,7 +79,7 @@ internal static class WICFormatHelper
else if (typeof(T) == typeof(Rgba64)) intermediateFormat = default;
else if (typeof(T) == typeof(R8)) intermediateFormat = default;
else if (typeof(T) == typeof(R16)) intermediateFormat = default;
- else intermediateFormat = ThrowHelper.ThrowArgumentException("Invalid texture type.");
+ else intermediateFormat = default(ArgumentException).Throw(nameof(T));
}
else if (containerFormat == GUID.GUID_ContainerFormatTiff)
{
@@ -89,7 +88,7 @@ internal static class WICFormatHelper
else if (typeof(T) == typeof(Rgba64)) intermediateFormat = default;
else if (typeof(T) == typeof(R8)) intermediateFormat = default;
else if (typeof(T) == typeof(R16)) intermediateFormat = default;
- else intermediateFormat = ThrowHelper.ThrowArgumentException("Invalid texture type.");
+ else intermediateFormat = default(ArgumentException).Throw(nameof(T));
}
else if (containerFormat == GUID.GUID_ContainerFormatDds)
{
@@ -98,11 +97,11 @@ internal static class WICFormatHelper
else if (typeof(T) == typeof(Rgba64)) intermediateFormat = GUID.GUID_WICPixelFormat32bppBGRA;
else if (typeof(T) == typeof(R8)) intermediateFormat = GUID.GUID_WICPixelFormat32bppBGRA;
else if (typeof(T) == typeof(R16)) intermediateFormat = GUID.GUID_WICPixelFormat32bppBGRA;
- else intermediateFormat = ThrowHelper.ThrowArgumentException("Invalid texture type.");
+ else intermediateFormat = default(ArgumentException).Throw(nameof(T));
}
else
{
- intermediateFormat = ThrowHelper.ThrowArgumentException("Invalid container format.");
+ intermediateFormat = default(ArgumentException).Throw(nameof(containerFormat));
}
return intermediateFormat != default;
@@ -128,7 +127,7 @@ internal static class WICFormatHelper
".wmp" => GUID.GUID_ContainerFormatWmp,
".tiff" => GUID.GUID_ContainerFormatTiff,
".dds" => GUID.GUID_ContainerFormatDds,
- _ => ThrowHelper.ThrowArgumentException("Invalid filename."),
+ _ => default(ArgumentException).Throw(nameof(filename))
};
}
@@ -148,7 +147,7 @@ internal static class WICFormatHelper
ImageFormat.Wmp => GUID.GUID_ContainerFormatWmp,
ImageFormat.Tiff => GUID.GUID_ContainerFormatTiff,
ImageFormat.Dds => GUID.GUID_ContainerFormatDds,
- _ => ThrowHelper.ThrowArgumentException("Invalid format."),
+ _ => default(ArgumentException).Throw(nameof(format))
};
}
}
\ No newline at end of file
diff --git a/src/ComputeSharp/Graphics/Helpers/__Internals/GraphicsResourceHelper.cs b/src/ComputeSharp/Graphics/Helpers/__Internals/GraphicsResourceHelper.cs
index 8ecc696b..5884f50e 100644
--- a/src/ComputeSharp/Graphics/Helpers/__Internals/GraphicsResourceHelper.cs
+++ b/src/ComputeSharp/Graphics/Helpers/__Internals/GraphicsResourceHelper.cs
@@ -1,7 +1,6 @@
using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
-using CommunityToolkit.Diagnostics;
using ComputeSharp.Interop;
using ComputeSharp.Resources;
using TerraFX.Interop.DirectX;
@@ -140,7 +139,7 @@ public static class GraphicsResourceHelper
return *(ulong*)&d3D12GpuDescriptorHandle;
}
- return ThrowHelper.ThrowArgumentException("The input texture is not a valid instance.");
+ return default(ArgumentException).Throw(nameof(texture));
}
///
@@ -163,7 +162,7 @@ public static class GraphicsResourceHelper
return *(ulong*)&d3D12GpuDescriptorHandle;
}
- return ThrowHelper.ThrowArgumentException("The input texture is not a valid instance.");
+ return default(ArgumentException).Throw(nameof(texture));
}
///
@@ -186,7 +185,7 @@ public static class GraphicsResourceHelper
return *(ulong*)&d3D12GpuDescriptorHandle;
}
- return ThrowHelper.ThrowArgumentException("The input texture is not a valid instance.");
+ return default(ArgumentException).Throw(nameof(texture));
}
///
@@ -253,7 +252,7 @@ public static class GraphicsResourceHelper
return *(ulong*)&d3D12GpuDescriptorHandle;
}
- return ThrowHelper.ThrowArgumentException("The input texture is not a valid instance.");
+ return default(ArgumentException).Throw(nameof(texture));
}
///
@@ -276,7 +275,7 @@ public static class GraphicsResourceHelper
return *(ulong*)&d3D12GpuDescriptorHandle;
}
- return ThrowHelper.ThrowArgumentException("The input texture is not a valid instance.");
+ return default(ArgumentException).Throw(nameof(texture));
}
///
@@ -299,7 +298,7 @@ public static class GraphicsResourceHelper
return *(ulong*)&d3D12GpuDescriptorHandle;
}
- return ThrowHelper.ThrowArgumentException("The input texture is not a valid instance.");
+ return default(ArgumentException).Throw(nameof(texture));
}
///
@@ -366,7 +365,7 @@ public static class GraphicsResourceHelper
return *(ulong*)&d3D12GpuDescriptorHandle;
}
- return ThrowHelper.ThrowArgumentException("The input texture is not a valid instance.");
+ return default(ArgumentException).Throw(nameof(texture));
}
///
@@ -389,7 +388,7 @@ public static class GraphicsResourceHelper
return *(ulong*)&d3D12GpuDescriptorHandle;
}
- return ThrowHelper.ThrowArgumentException("The input texture is not a valid instance.");
+ return default(ArgumentException).Throw(nameof(texture));
}
///
@@ -412,6 +411,6 @@ public static class GraphicsResourceHelper
return *(ulong*)&d3D12GpuDescriptorHandle;
}
- return ThrowHelper.ThrowArgumentException("The input texture is not a valid instance.");
+ return default(ArgumentException).Throw(nameof(texture));
}
}
\ No newline at end of file
diff --git a/src/ComputeSharp/Graphics/Interop/ReferenceTracker.cs b/src/ComputeSharp/Graphics/Interop/ReferenceTracker.cs
index ae4c0587..15ed47be 100644
--- a/src/ComputeSharp/Graphics/Interop/ReferenceTracker.cs
+++ b/src/ComputeSharp/Graphics/Interop/ReferenceTracker.cs
@@ -68,7 +68,7 @@ internal struct ReferenceTracker : IDisposable
if (!leaseTaken)
{
- // We can't use ThrowHelper here as we only want to invoke ToString if we
+ // We can't use a throw helper here as we only want to invoke ToString if we
// are about to throw an exception. The JIT will recognize this pattern
// as this method has a single basic block that always throws an exception.
static void Throw(object trackedObject) => throw new ObjectDisposedException(trackedObject.ToString());
diff --git a/src/ComputeSharp/Graphics/Resources/Helpers/ResourceStateHelper.cs b/src/ComputeSharp/Graphics/Resources/Helpers/ResourceStateHelper.cs
index 6d06aefc..42b8aa4d 100644
--- a/src/ComputeSharp/Graphics/Resources/Helpers/ResourceStateHelper.cs
+++ b/src/ComputeSharp/Graphics/Resources/Helpers/ResourceStateHelper.cs
@@ -1,5 +1,5 @@
+using System;
using System.Runtime.CompilerServices;
-using CommunityToolkit.Diagnostics;
using TerraFX.Interop.DirectX;
using static TerraFX.Interop.DirectX.D3D12_RESOURCE_STATES;
@@ -28,6 +28,6 @@ internal static class ResourceStateHelper
return D3D12_RESOURCE_STATE_UNORDERED_ACCESS;
}
- return ThrowHelper.ThrowArgumentException("The target resource state is not valid.");
+ return default(ArgumentException).Throw(nameof(resourceState));
}
}
\ No newline at end of file