From 6f7bbff6cf70a6eeff26aea9b7bfbb26cb8e7239 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sat, 25 Feb 2023 16:20:04 +0100 Subject: [PATCH] Switch to ArgumentNullException.ThrowIfNull extension --- .../ArgumentNullExceptionExtensions.cs | 62 ++++ .../Helpers/SwapChainManager.Rendering.cs | 3 +- src/ComputeSharp.UI/ShaderRunner{T}.cs | 5 +- .../Graphics/Extensions/BufferExtensions.cs | 44 +-- .../GraphicsDeviceExtensions.Dispatching.cs | 20 +- .../GraphicsDeviceExtensions.Resources.cs | 281 +++++++++--------- .../Extensions/ReadBackBufferExtensions.cs | 10 +- .../Extensions/ReadBackTexture1DExtensions.cs | 14 +- .../Extensions/ReadBackTexture2DExtensions.cs | 27 +- .../Extensions/ReadBackTexture3DExtensions.cs | 14 +- .../ReadWriteTexture1DExtensions.cs | 11 +- .../ReadWriteTexture2DExtensions.cs | 11 +- .../ReadWriteTexture3DExtensions.cs | 11 +- .../Extensions/StructuredBufferExtensions.cs | 18 +- .../Extensions/Texture1DExtensions.cs | 108 +++---- .../Extensions/Texture2DExtensions.cs | 130 ++++---- .../Extensions/Texture3DExtensions.cs | 104 +++---- .../Extensions/UploadBufferExtensions.cs | 10 +- .../Extensions/UploadTexture1DExtensions.cs | 14 +- .../Extensions/UploadTexture2DExtensions.cs | 25 +- .../Extensions/UploadTexture3DExtensions.cs | 14 +- .../Graphics/GraphicsDevice.GetDevice.cs | 3 +- .../__Internals/GraphicsResourceHelper.cs | 32 +- .../Extensions/ComputeContextExtensions.cs | 88 +++--- 24 files changed, 556 insertions(+), 503 deletions(-) create mode 100644 src/ComputeSharp.Core/Polyfills/ArgumentNullExceptionExtensions.cs diff --git a/src/ComputeSharp.Core/Polyfills/ArgumentNullExceptionExtensions.cs b/src/ComputeSharp.Core/Polyfills/ArgumentNullExceptionExtensions.cs new file mode 100644 index 00000000..7f6e276d --- /dev/null +++ b/src/ComputeSharp.Core/Polyfills/ArgumentNullExceptionExtensions.cs @@ -0,0 +1,62 @@ +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; + +namespace System; + +/// +/// Throw helper extensions for . +/// +internal static class ArgumentNullExceptionExtensions +{ + /// + /// 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 . + [MethodImpl(MethodImplOptions.AggressiveInlining)] + [DoesNotReturn] + public static void Throw(this ArgumentNullException? _, string? parameterName) + { + Throw(parameterName); + } + + /// + /// Throws an if is . + /// + /// Dummy value to invoke the extension upon (always pass . + /// The reference type argument to validate as non-. + /// The name of the parameter with which corresponds. + /// Thrown if is . + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static void ThrowIfNull(this ArgumentNullException? _, [NotNull] object? argument, [CallerArgumentExpression(nameof(argument))] string? parameterName = null) + { + if (argument is null) + { + Throw(parameterName); + } + } + + /// + /// Throws an if is . + /// + /// Dummy value to invoke the extension upon (always pass . + /// The pointer argument to validate as non-. + /// The name of the parameter with which corresponds. + /// Thrown if is . + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static unsafe void ThrowIfNull(this ArgumentNullException? _, [NotNull] void* argument, [CallerArgumentExpression(nameof(argument))] string? parameterName = null) + { + if (argument is null) + { + Throw(parameterName); + } + } + + /// + [DoesNotReturn] + public static void Throw(string? parameterName) + { + throw new ArgumentNullException(parameterName); + } +} diff --git a/src/ComputeSharp.UI/Helpers/SwapChainManager.Rendering.cs b/src/ComputeSharp.UI/Helpers/SwapChainManager.Rendering.cs index 05db8cad..d35d92b4 100644 --- a/src/ComputeSharp.UI/Helpers/SwapChainManager.Rendering.cs +++ b/src/ComputeSharp.UI/Helpers/SwapChainManager.Rendering.cs @@ -2,7 +2,6 @@ using System; using System.Diagnostics; using System.Runtime.CompilerServices; using System.Threading; -using CommunityToolkit.Diagnostics; using ComputeSharp.Interop; #if WINDOWS_UWP using ComputeSharp.Uwp.Extensions; @@ -28,7 +27,7 @@ partial class SwapChainManager /// The instance to use to render frames. public async void StartRenderLoop(IFrameRequestQueue? frameRequestQueue, IShaderRunner shaderRunner) { - Guard.IsNotNull(shaderRunner); + default(ArgumentNullException).ThrowIfNull(shaderRunner); using (await this.setupSemaphore.LockAsync()) { diff --git a/src/ComputeSharp.UI/ShaderRunner{T}.cs b/src/ComputeSharp.UI/ShaderRunner{T}.cs index 08bca82b..8b355863 100644 --- a/src/ComputeSharp.UI/ShaderRunner{T}.cs +++ b/src/ComputeSharp.UI/ShaderRunner{T}.cs @@ -1,5 +1,4 @@ using System; -using CommunityToolkit.Diagnostics; #if WINDOWS_UWP namespace ComputeSharp.Uwp; @@ -40,7 +39,7 @@ public sealed class ShaderRunner : IShaderRunner /// The instance used to create shaders to run. public ShaderRunner(Func shaderFactory) { - Guard.IsNotNull(shaderFactory); + default(ArgumentNullException).ThrowIfNull(shaderFactory); this.shaderFactory = shaderFactory; } @@ -51,7 +50,7 @@ public sealed class ShaderRunner : IShaderRunner /// The instance used to create shaders to run. public ShaderRunner(Func shaderFactory) { - Guard.IsNotNull(shaderFactory); + default(ArgumentNullException).ThrowIfNull(shaderFactory); this.statefulShaderFactory = shaderFactory; } diff --git a/src/ComputeSharp/Graphics/Extensions/BufferExtensions.cs b/src/ComputeSharp/Graphics/Extensions/BufferExtensions.cs index c6cd4389..1534cc01 100644 --- a/src/ComputeSharp/Graphics/Extensions/BufferExtensions.cs +++ b/src/ComputeSharp/Graphics/Extensions/BufferExtensions.cs @@ -22,7 +22,7 @@ public static class BufferExtensions public static T[] ToArray(this Buffer source) where T : unmanaged { - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(source); return source.ToArray(0, source.Length); } @@ -38,7 +38,7 @@ public static class BufferExtensions public static T[] ToArray(this Buffer source, int offset, int count) where T : unmanaged { - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(source); Guard.IsGreaterThanOrEqualTo(count, 0); T[] data = GC.AllocateUninitializedArray(count); @@ -57,8 +57,8 @@ public static class BufferExtensions public static void CopyTo(this Buffer source, T[] destination) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); source.CopyTo(destination.AsSpan(), 0); } @@ -75,8 +75,8 @@ public static class BufferExtensions public static void CopyTo(this Buffer source, T[] destination, int sourceOffset, int destinationOffset, int count) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); Span span = destination.AsSpan(destinationOffset, count); @@ -92,7 +92,7 @@ public static class BufferExtensions public static void CopyTo(this Buffer source, Span destination) where T : unmanaged { - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(source); source.CopyTo(destination, 0); } @@ -107,7 +107,7 @@ public static class BufferExtensions public static void CopyTo(this Buffer source, Span destination, int sourceOffset) where T : unmanaged { - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(source); source.CopyTo(ref MemoryMarshal.GetReference(destination), sourceOffset, destination.Length); } @@ -121,8 +121,8 @@ public static class BufferExtensions public static void CopyTo(this Buffer source, Buffer destination) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); source.CopyTo(destination, 0, 0, source.Length); } @@ -139,8 +139,8 @@ public static class BufferExtensions public static void CopyTo(this Buffer source, Buffer destination, int sourceOffset, int destinationOffset, int count) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); source.CopyTo(destination, sourceOffset, destinationOffset, count); } @@ -154,8 +154,8 @@ public static class BufferExtensions public static void CopyFrom(this Buffer destination, T[] source) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); destination.CopyFrom(source.AsSpan(), 0); } @@ -172,8 +172,8 @@ public static class BufferExtensions public static void CopyFrom(this Buffer destination, T[] source, int sourceOffset, int destinationOffset, int count) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); ReadOnlySpan span = source.AsSpan(sourceOffset, count); @@ -189,7 +189,7 @@ public static class BufferExtensions public static void CopyFrom(this Buffer destination, ReadOnlySpan source) where T : unmanaged { - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(destination); destination.CopyFrom(source, 0); } @@ -204,7 +204,7 @@ public static class BufferExtensions public static void CopyFrom(this Buffer destination, ReadOnlySpan source, int destinationOffset) where T : unmanaged { - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(destination); destination.CopyFrom(ref MemoryMarshal.GetReference(source), destinationOffset, source.Length); } @@ -218,8 +218,8 @@ public static class BufferExtensions public static void CopyFrom(this Buffer destination, Buffer source) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); source.CopyTo(destination, 0, 0, source.Length); } @@ -236,8 +236,8 @@ public static class BufferExtensions public static void CopyFrom(this Buffer destination, Buffer source, int sourceOffset, int destinationOffset, int count) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); source.CopyTo(destination, sourceOffset, destinationOffset, count); } diff --git a/src/ComputeSharp/Graphics/Extensions/GraphicsDeviceExtensions.Dispatching.cs b/src/ComputeSharp/Graphics/Extensions/GraphicsDeviceExtensions.Dispatching.cs index 826d8f71..322b9166 100644 --- a/src/ComputeSharp/Graphics/Extensions/GraphicsDeviceExtensions.Dispatching.cs +++ b/src/ComputeSharp/Graphics/Extensions/GraphicsDeviceExtensions.Dispatching.cs @@ -1,5 +1,5 @@ +using System; using System.Runtime.CompilerServices; -using CommunityToolkit.Diagnostics; using ComputeSharp.Interop; namespace ComputeSharp; @@ -19,7 +19,7 @@ public static partial class GraphicsDeviceExtensions public static void For(this GraphicsDevice device, int x, in T shader) where T : struct, IComputeShader { - Guard.IsNotNull(device); + default(ArgumentNullException).ThrowIfNull(device); using ComputeContext context = device.CreateComputeContext(); @@ -37,7 +37,7 @@ public static partial class GraphicsDeviceExtensions public static void For(this GraphicsDevice device, int x, int y, in T shader) where T : struct, IComputeShader { - Guard.IsNotNull(device); + default(ArgumentNullException).ThrowIfNull(device); using ComputeContext context = device.CreateComputeContext(); @@ -56,7 +56,7 @@ public static partial class GraphicsDeviceExtensions public static void For(this GraphicsDevice device, int x, int y, int z, in T shader) where T : struct, IComputeShader { - Guard.IsNotNull(device); + default(ArgumentNullException).ThrowIfNull(device); using ComputeContext context = device.CreateComputeContext(); @@ -78,7 +78,7 @@ public static partial class GraphicsDeviceExtensions public static void For(this GraphicsDevice device, int x, int y, int z, int threadsX, int threadsY, int threadsZ, in T shader) where T : struct, IComputeShader { - Guard.IsNotNull(device); + default(ArgumentNullException).ThrowIfNull(device); using ComputeContext context = device.CreateComputeContext(); @@ -96,8 +96,8 @@ public static partial class GraphicsDeviceExtensions where T : struct, IPixelShader where TPixel : unmanaged { - Guard.IsNotNull(device); - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(device); + default(ArgumentNullException).ThrowIfNull(texture); using ComputeContext context = device.CreateComputeContext(); @@ -116,8 +116,8 @@ public static partial class GraphicsDeviceExtensions where T : struct, IPixelShader where TPixel : unmanaged { - Guard.IsNotNull(device); - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(device); + default(ArgumentNullException).ThrowIfNull(texture); using ComputeContext context = device.CreateComputeContext(); @@ -149,7 +149,7 @@ public static partial class GraphicsDeviceExtensions /// public static ComputeContext CreateComputeContext(this GraphicsDevice device) { - Guard.IsNotNull(device); + default(ArgumentNullException).ThrowIfNull(device); using ReferenceTracker.Lease _0 = device.GetReferenceTracker().GetLease(); diff --git a/src/ComputeSharp/Graphics/Extensions/GraphicsDeviceExtensions.Resources.cs b/src/ComputeSharp/Graphics/Extensions/GraphicsDeviceExtensions.Resources.cs index 320d05dc..631cb35b 100644 --- a/src/ComputeSharp/Graphics/Extensions/GraphicsDeviceExtensions.Resources.cs +++ b/src/ComputeSharp/Graphics/Extensions/GraphicsDeviceExtensions.Resources.cs @@ -1,7 +1,6 @@ using System; using System.Diagnostics.CodeAnalysis; using System.IO; -using CommunityToolkit.Diagnostics; using ComputeSharp.Graphics.Helpers; using ComputeSharp.Resources; @@ -22,7 +21,7 @@ partial class GraphicsDeviceExtensions public static ConstantBuffer AllocateConstantBuffer(this GraphicsDevice device, int length, AllocationMode allocationMode = AllocationMode.Default) where T : unmanaged { - Guard.IsNotNull(device); + default(ArgumentNullException).ThrowIfNull(device); return new(device, length, allocationMode); } @@ -38,8 +37,8 @@ partial class GraphicsDeviceExtensions public static ConstantBuffer AllocateConstantBuffer(this GraphicsDevice device, T[] source) where T : unmanaged { - Guard.IsNotNull(device); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(device); + default(ArgumentNullException).ThrowIfNull(source); return device.AllocateConstantBuffer(source.AsSpan()); } @@ -55,7 +54,7 @@ partial class GraphicsDeviceExtensions public static ConstantBuffer AllocateConstantBuffer(this GraphicsDevice device, ReadOnlySpan source) where T : unmanaged { - Guard.IsNotNull(device); + default(ArgumentNullException).ThrowIfNull(device); ConstantBuffer buffer = new(device, source.Length, AllocationMode.Default); @@ -75,8 +74,8 @@ partial class GraphicsDeviceExtensions public static ConstantBuffer AllocateConstantBuffer(this GraphicsDevice device, Buffer source) where T : unmanaged { - Guard.IsNotNull(device); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(device); + default(ArgumentNullException).ThrowIfNull(source); ConstantBuffer constantBuffer = new(device, source.Length, AllocationMode.Default); @@ -97,7 +96,7 @@ partial class GraphicsDeviceExtensions public static ReadOnlyBuffer AllocateReadOnlyBuffer(this GraphicsDevice device, int length, AllocationMode allocationMode = AllocationMode.Default) where T : unmanaged { - Guard.IsNotNull(device); + default(ArgumentNullException).ThrowIfNull(device); return new(device, length, allocationMode); } @@ -113,8 +112,8 @@ partial class GraphicsDeviceExtensions public static ReadOnlyBuffer AllocateReadOnlyBuffer(this GraphicsDevice device, T[] source) where T : unmanaged { - Guard.IsNotNull(device); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(device); + default(ArgumentNullException).ThrowIfNull(source); return device.AllocateReadOnlyBuffer(source.AsSpan()); } @@ -130,7 +129,7 @@ partial class GraphicsDeviceExtensions public static ReadOnlyBuffer AllocateReadOnlyBuffer(this GraphicsDevice device, ReadOnlySpan source) where T : unmanaged { - Guard.IsNotNull(device); + default(ArgumentNullException).ThrowIfNull(device); ReadOnlyBuffer buffer = new(device, source.Length, AllocationMode.Default); @@ -150,8 +149,8 @@ partial class GraphicsDeviceExtensions public static ReadOnlyBuffer AllocateReadOnlyBuffer(this GraphicsDevice device, Buffer source) where T : unmanaged { - Guard.IsNotNull(device); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(device); + default(ArgumentNullException).ThrowIfNull(source); ReadOnlyBuffer readWriteBuffer = new(device, source.Length, AllocationMode.Default); @@ -171,7 +170,7 @@ partial class GraphicsDeviceExtensions public static ReadOnlyTexture1D AllocateReadOnlyTexture1D(this GraphicsDevice device, int width, AllocationMode allocationMode = AllocationMode.Default) where T : unmanaged { - Guard.IsNotNull(device); + default(ArgumentNullException).ThrowIfNull(device); return new(device, width, allocationMode); } @@ -187,8 +186,8 @@ partial class GraphicsDeviceExtensions public static ReadOnlyTexture1D AllocateReadOnlyTexture1D(this GraphicsDevice device, T[] source, int width) where T : unmanaged { - Guard.IsNotNull(device); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(device); + default(ArgumentNullException).ThrowIfNull(source); return device.AllocateReadOnlyTexture1D(source.AsSpan(0, width)); } @@ -205,8 +204,8 @@ partial class GraphicsDeviceExtensions public static ReadOnlyTexture1D AllocateReadOnlyTexture1D(this GraphicsDevice device, T[] source, int offset, int width) where T : unmanaged { - Guard.IsNotNull(device); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(device); + default(ArgumentNullException).ThrowIfNull(source); return device.AllocateReadOnlyTexture1D(source.AsSpan(offset, width)); } @@ -221,8 +220,8 @@ partial class GraphicsDeviceExtensions public static ReadOnlyTexture1D AllocateReadOnlyTexture1D(this GraphicsDevice device, T[] source) where T : unmanaged { - Guard.IsNotNull(device); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(device); + default(ArgumentNullException).ThrowIfNull(source); ReadOnlyTexture1D texture = new(device, source.Length, AllocationMode.Default); @@ -241,7 +240,7 @@ partial class GraphicsDeviceExtensions public static ReadOnlyTexture1D AllocateReadOnlyTexture1D(this GraphicsDevice device, ReadOnlySpan source) where T : unmanaged { - Guard.IsNotNull(device); + default(ArgumentNullException).ThrowIfNull(device); ReadOnlyTexture1D texture = new(device, source.Length, AllocationMode.Default); @@ -263,7 +262,7 @@ partial class GraphicsDeviceExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(device); + default(ArgumentNullException).ThrowIfNull(device); return new(device, width, allocationMode); } @@ -281,8 +280,8 @@ partial class GraphicsDeviceExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(device); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(device); + default(ArgumentNullException).ThrowIfNull(source); return device.AllocateReadOnlyTexture1D(source.AsSpan(0, width)); } @@ -301,8 +300,8 @@ partial class GraphicsDeviceExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(device); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(device); + default(ArgumentNullException).ThrowIfNull(source); return device.AllocateReadOnlyTexture1D(source.AsSpan(offset, width)); } @@ -319,8 +318,8 @@ partial class GraphicsDeviceExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(device); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(device); + default(ArgumentNullException).ThrowIfNull(source); ReadOnlyTexture1D texture = new(device, source.Length, AllocationMode.Default); @@ -341,7 +340,7 @@ partial class GraphicsDeviceExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(device); + default(ArgumentNullException).ThrowIfNull(device); ReadOnlyTexture1D texture = new(device, source.Length, AllocationMode.Default); @@ -362,7 +361,7 @@ partial class GraphicsDeviceExtensions public static ReadOnlyTexture2D AllocateReadOnlyTexture2D(this GraphicsDevice device, int width, int height, AllocationMode allocationMode = AllocationMode.Default) where T : unmanaged { - Guard.IsNotNull(device); + default(ArgumentNullException).ThrowIfNull(device); return new(device, width, height, allocationMode); } @@ -379,8 +378,8 @@ partial class GraphicsDeviceExtensions public static ReadOnlyTexture2D AllocateReadOnlyTexture2D(this GraphicsDevice device, T[] source, int width, int height) where T : unmanaged { - Guard.IsNotNull(device); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(device); + default(ArgumentNullException).ThrowIfNull(source); return device.AllocateReadOnlyTexture2D(source.AsSpan(), width, height); } @@ -398,8 +397,8 @@ partial class GraphicsDeviceExtensions public static ReadOnlyTexture2D AllocateReadOnlyTexture2D(this GraphicsDevice device, T[] source, int offset, int width, int height) where T : unmanaged { - Guard.IsNotNull(device); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(device); + default(ArgumentNullException).ThrowIfNull(source); return device.AllocateReadOnlyTexture2D(source.AsSpan(offset), width, height); } @@ -414,8 +413,8 @@ partial class GraphicsDeviceExtensions public static ReadOnlyTexture2D AllocateReadOnlyTexture2D(this GraphicsDevice device, T[,] source) where T : unmanaged { - Guard.IsNotNull(device); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(device); + default(ArgumentNullException).ThrowIfNull(source); ReadOnlyTexture2D texture = new(device, source.GetLength(1), source.GetLength(0), AllocationMode.Default); @@ -436,7 +435,7 @@ partial class GraphicsDeviceExtensions public static ReadOnlyTexture2D AllocateReadOnlyTexture2D(this GraphicsDevice device, ReadOnlySpan source, int width, int height) where T : unmanaged { - Guard.IsNotNull(device); + default(ArgumentNullException).ThrowIfNull(device); ReadOnlyTexture2D texture = new(device, width, height, AllocationMode.Default); @@ -459,7 +458,7 @@ partial class GraphicsDeviceExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(device); + default(ArgumentNullException).ThrowIfNull(device); return new(device, width, height, allocationMode); } @@ -478,8 +477,8 @@ partial class GraphicsDeviceExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(device); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(device); + default(ArgumentNullException).ThrowIfNull(source); return device.AllocateReadOnlyTexture2D(source.AsSpan(), width, height); } @@ -499,8 +498,8 @@ partial class GraphicsDeviceExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(device); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(device); + default(ArgumentNullException).ThrowIfNull(source); return device.AllocateReadOnlyTexture2D(source.AsSpan(offset), width, height); } @@ -517,8 +516,8 @@ partial class GraphicsDeviceExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(device); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(device); + default(ArgumentNullException).ThrowIfNull(source); ReadOnlyTexture2D texture = new(device, source.GetLength(1), source.GetLength(0), AllocationMode.Default); @@ -541,7 +540,7 @@ partial class GraphicsDeviceExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(device); + default(ArgumentNullException).ThrowIfNull(device); ReadOnlyTexture2D texture = new(device, width, height, AllocationMode.Default); @@ -563,7 +562,7 @@ partial class GraphicsDeviceExtensions public static ReadOnlyTexture3D AllocateReadOnlyTexture3D(this GraphicsDevice device, int width, int height, int depth, AllocationMode allocationMode = AllocationMode.Default) where T : unmanaged { - Guard.IsNotNull(device); + default(ArgumentNullException).ThrowIfNull(device); return new(device, width, height, depth, allocationMode); } @@ -581,8 +580,8 @@ partial class GraphicsDeviceExtensions public static ReadOnlyTexture3D AllocateReadOnlyTexture3D(this GraphicsDevice device, T[] source, int width, int height, int depth) where T : unmanaged { - Guard.IsNotNull(device); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(device); + default(ArgumentNullException).ThrowIfNull(source); return device.AllocateReadOnlyTexture3D(source.AsSpan(), width, height, depth); } @@ -601,8 +600,8 @@ partial class GraphicsDeviceExtensions public static ReadOnlyTexture3D AllocateReadOnlyTexture3D(this GraphicsDevice device, T[] source, int offset, int width, int height, int depth) where T : unmanaged { - Guard.IsNotNull(device); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(device); + default(ArgumentNullException).ThrowIfNull(source); return device.AllocateReadOnlyTexture3D(source.AsSpan(offset), width, height, depth); } @@ -621,8 +620,8 @@ partial class GraphicsDeviceExtensions public static ReadOnlyTexture3D AllocateReadOnlyTexture3D(this GraphicsDevice device, T[,,] source) where T : unmanaged { - Guard.IsNotNull(device); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(device); + default(ArgumentNullException).ThrowIfNull(source); ReadOnlyTexture3D texture = new(device, source.GetLength(2), source.GetLength(1), source.GetLength(0), AllocationMode.Default); @@ -644,7 +643,7 @@ partial class GraphicsDeviceExtensions public static ReadOnlyTexture3D AllocateReadOnlyTexture3D(this GraphicsDevice device, ReadOnlySpan source, int width, int height, int depth) where T : unmanaged { - Guard.IsNotNull(device); + default(ArgumentNullException).ThrowIfNull(device); ReadOnlyTexture3D texture = new(device, width, height, depth, AllocationMode.Default); @@ -668,7 +667,7 @@ partial class GraphicsDeviceExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(device); + default(ArgumentNullException).ThrowIfNull(device); return new(device, width, height, depth, allocationMode); } @@ -688,8 +687,8 @@ partial class GraphicsDeviceExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(device); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(device); + default(ArgumentNullException).ThrowIfNull(source); return device.AllocateReadOnlyTexture3D(source.AsSpan(), width, height, depth); } @@ -710,8 +709,8 @@ partial class GraphicsDeviceExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(device); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(device); + default(ArgumentNullException).ThrowIfNull(source); return device.AllocateReadOnlyTexture3D(source.AsSpan(offset), width, height, depth); } @@ -732,8 +731,8 @@ partial class GraphicsDeviceExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(device); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(device); + default(ArgumentNullException).ThrowIfNull(source); ReadOnlyTexture3D texture = new(device, source.GetLength(2), source.GetLength(1), source.GetLength(0), AllocationMode.Default); @@ -757,7 +756,7 @@ partial class GraphicsDeviceExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(device); + default(ArgumentNullException).ThrowIfNull(device); ReadOnlyTexture3D texture = new(device, width, height, depth, AllocationMode.Default); @@ -778,7 +777,7 @@ partial class GraphicsDeviceExtensions public static ReadWriteBuffer AllocateReadWriteBuffer(this GraphicsDevice device, int length, AllocationMode allocationMode = AllocationMode.Default) where T : unmanaged { - Guard.IsNotNull(device); + default(ArgumentNullException).ThrowIfNull(device); return new(device, length, allocationMode); } @@ -794,8 +793,8 @@ partial class GraphicsDeviceExtensions public static ReadWriteBuffer AllocateReadWriteBuffer(this GraphicsDevice device, T[] source) where T : unmanaged { - Guard.IsNotNull(device); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(device); + default(ArgumentNullException).ThrowIfNull(source); return device.AllocateReadWriteBuffer(source.AsSpan()); } @@ -811,7 +810,7 @@ partial class GraphicsDeviceExtensions public static ReadWriteBuffer AllocateReadWriteBuffer(this GraphicsDevice device, ReadOnlySpan source) where T : unmanaged { - Guard.IsNotNull(device); + default(ArgumentNullException).ThrowIfNull(device); ReadWriteBuffer buffer = new(device, source.Length, AllocationMode.Default); @@ -831,8 +830,8 @@ partial class GraphicsDeviceExtensions public static ReadWriteBuffer AllocateReadWriteBuffer(this GraphicsDevice device, Buffer source) where T : unmanaged { - Guard.IsNotNull(device); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(device); + default(ArgumentNullException).ThrowIfNull(source); ReadWriteBuffer readWriteBuffer = new(device, source.Length, AllocationMode.Default); @@ -852,7 +851,7 @@ partial class GraphicsDeviceExtensions public static ReadWriteTexture1D AllocateReadWriteTexture1D(this GraphicsDevice device, int width, AllocationMode allocationMode = AllocationMode.Default) where T : unmanaged { - Guard.IsNotNull(device); + default(ArgumentNullException).ThrowIfNull(device); return new(device, width, allocationMode); } @@ -868,8 +867,8 @@ partial class GraphicsDeviceExtensions public static ReadWriteTexture1D AllocateReadWriteTexture1D(this GraphicsDevice device, T[] source, int width) where T : unmanaged { - Guard.IsNotNull(device); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(device); + default(ArgumentNullException).ThrowIfNull(source); return device.AllocateReadWriteTexture1D(source.AsSpan(0, width)); } @@ -886,8 +885,8 @@ partial class GraphicsDeviceExtensions public static ReadWriteTexture1D AllocateReadWriteTexture1D(this GraphicsDevice device, T[] source, int offset, int width) where T : unmanaged { - Guard.IsNotNull(device); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(device); + default(ArgumentNullException).ThrowIfNull(source); return device.AllocateReadWriteTexture1D(source.AsSpan(offset, width)); } @@ -902,8 +901,8 @@ partial class GraphicsDeviceExtensions public static ReadWriteTexture1D AllocateReadWriteTexture1D(this GraphicsDevice device, T[] source) where T : unmanaged { - Guard.IsNotNull(device); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(device); + default(ArgumentNullException).ThrowIfNull(source); ReadWriteTexture1D texture = new(device, source.Length, AllocationMode.Default); @@ -922,7 +921,7 @@ partial class GraphicsDeviceExtensions public static ReadWriteTexture1D AllocateReadWriteTexture1D(this GraphicsDevice device, ReadOnlySpan source) where T : unmanaged { - Guard.IsNotNull(device); + default(ArgumentNullException).ThrowIfNull(device); ReadWriteTexture1D texture = new(device, source.Length, AllocationMode.Default); @@ -944,7 +943,7 @@ partial class GraphicsDeviceExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(device); + default(ArgumentNullException).ThrowIfNull(device); return new(device, width, allocationMode); } @@ -962,8 +961,8 @@ partial class GraphicsDeviceExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(device); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(device); + default(ArgumentNullException).ThrowIfNull(source); return device.AllocateReadWriteTexture1D(source.AsSpan(0, width)); } @@ -982,8 +981,8 @@ partial class GraphicsDeviceExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(device); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(device); + default(ArgumentNullException).ThrowIfNull(source); return device.AllocateReadWriteTexture1D(source.AsSpan(offset, width)); } @@ -1000,8 +999,8 @@ partial class GraphicsDeviceExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(device); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(device); + default(ArgumentNullException).ThrowIfNull(source); ReadWriteTexture1D texture = new(device, source.Length, AllocationMode.Default); @@ -1022,7 +1021,7 @@ partial class GraphicsDeviceExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(device); + default(ArgumentNullException).ThrowIfNull(device); ReadWriteTexture1D texture = new(device, source.Length, AllocationMode.Default); @@ -1043,7 +1042,7 @@ partial class GraphicsDeviceExtensions public static ReadWriteTexture2D AllocateReadWriteTexture2D(this GraphicsDevice device, int width, int height, AllocationMode allocationMode = AllocationMode.Default) where T : unmanaged { - Guard.IsNotNull(device); + default(ArgumentNullException).ThrowIfNull(device); return new(device, width, height, allocationMode); } @@ -1060,8 +1059,8 @@ partial class GraphicsDeviceExtensions public static ReadWriteTexture2D AllocateReadWriteTexture2D(this GraphicsDevice device, T[] source, int width, int height) where T : unmanaged { - Guard.IsNotNull(device); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(device); + default(ArgumentNullException).ThrowIfNull(source); return device.AllocateReadWriteTexture2D(source.AsSpan(), width, height); } @@ -1079,8 +1078,8 @@ partial class GraphicsDeviceExtensions public static ReadWriteTexture2D AllocateReadWriteTexture2D(this GraphicsDevice device, T[] source, int offset, int width, int height) where T : unmanaged { - Guard.IsNotNull(device); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(device); + default(ArgumentNullException).ThrowIfNull(source); return device.AllocateReadWriteTexture2D(source.AsSpan(offset), width, height); } @@ -1095,8 +1094,8 @@ partial class GraphicsDeviceExtensions public static ReadWriteTexture2D AllocateReadWriteTexture2D(this GraphicsDevice device, T[,] source) where T : unmanaged { - Guard.IsNotNull(device); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(device); + default(ArgumentNullException).ThrowIfNull(source); ReadWriteTexture2D texture = new(device, source.GetLength(1), source.GetLength(0), AllocationMode.Default); @@ -1117,7 +1116,7 @@ partial class GraphicsDeviceExtensions public static ReadWriteTexture2D AllocateReadWriteTexture2D(this GraphicsDevice device, ReadOnlySpan source, int width, int height) where T : unmanaged { - Guard.IsNotNull(device); + default(ArgumentNullException).ThrowIfNull(device); ReadWriteTexture2D texture = new(device, width, height, AllocationMode.Default); @@ -1140,7 +1139,7 @@ partial class GraphicsDeviceExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(device); + default(ArgumentNullException).ThrowIfNull(device); return new(device, width, height, allocationMode); } @@ -1159,8 +1158,8 @@ partial class GraphicsDeviceExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(device); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(device); + default(ArgumentNullException).ThrowIfNull(source); return device.AllocateReadWriteTexture2D(source.AsSpan(), width, height); } @@ -1180,8 +1179,8 @@ partial class GraphicsDeviceExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(device); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(device); + default(ArgumentNullException).ThrowIfNull(source); return device.AllocateReadWriteTexture2D(source.AsSpan(offset), width, height); } @@ -1198,8 +1197,8 @@ partial class GraphicsDeviceExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(device); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(device); + default(ArgumentNullException).ThrowIfNull(source); ReadWriteTexture2D texture = new(device, source.GetLength(1), source.GetLength(0), AllocationMode.Default); @@ -1222,7 +1221,7 @@ partial class GraphicsDeviceExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(device); + default(ArgumentNullException).ThrowIfNull(device); ReadWriteTexture2D texture = new(device, width, height, AllocationMode.Default); @@ -1244,7 +1243,7 @@ partial class GraphicsDeviceExtensions public static ReadWriteTexture3D AllocateReadWriteTexture3D(this GraphicsDevice device, int width, int height, int depth, AllocationMode allocationMode = AllocationMode.Default) where T : unmanaged { - Guard.IsNotNull(device); + default(ArgumentNullException).ThrowIfNull(device); return new(device, width, height, depth, allocationMode); } @@ -1262,8 +1261,8 @@ partial class GraphicsDeviceExtensions public static ReadWriteTexture3D AllocateReadWriteTexture3D(this GraphicsDevice device, T[] source, int width, int height, int depth) where T : unmanaged { - Guard.IsNotNull(device); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(device); + default(ArgumentNullException).ThrowIfNull(source); return device.AllocateReadWriteTexture3D(source.AsSpan(), width, height, depth); } @@ -1282,8 +1281,8 @@ partial class GraphicsDeviceExtensions public static ReadWriteTexture3D AllocateReadWriteTexture3D(this GraphicsDevice device, T[] source, int offset, int width, int height, int depth) where T : unmanaged { - Guard.IsNotNull(device); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(device); + default(ArgumentNullException).ThrowIfNull(source); return device.AllocateReadWriteTexture3D(source.AsSpan(offset), width, height, depth); } @@ -1302,8 +1301,8 @@ partial class GraphicsDeviceExtensions public static ReadWriteTexture3D AllocateReadWriteTexture3D(this GraphicsDevice device, T[,,] source) where T : unmanaged { - Guard.IsNotNull(device); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(device); + default(ArgumentNullException).ThrowIfNull(source); ReadWriteTexture3D texture = new(device, source.GetLength(2), source.GetLength(1), source.GetLength(0), AllocationMode.Default); @@ -1325,7 +1324,7 @@ partial class GraphicsDeviceExtensions public static ReadWriteTexture3D AllocateReadWriteTexture3D(this GraphicsDevice device, ReadOnlySpan source, int width, int height, int depth) where T : unmanaged { - Guard.IsNotNull(device); + default(ArgumentNullException).ThrowIfNull(device); ReadWriteTexture3D texture = new(device, width, height, depth, AllocationMode.Default); @@ -1349,7 +1348,7 @@ partial class GraphicsDeviceExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(device); + default(ArgumentNullException).ThrowIfNull(device); return new(device, width, height, depth, allocationMode); } @@ -1369,8 +1368,8 @@ partial class GraphicsDeviceExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(device); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(device); + default(ArgumentNullException).ThrowIfNull(source); return device.AllocateReadWriteTexture3D(source.AsSpan(), width, height, depth); } @@ -1391,8 +1390,8 @@ partial class GraphicsDeviceExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(device); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(device); + default(ArgumentNullException).ThrowIfNull(source); return device.AllocateReadWriteTexture3D(source.AsSpan(offset), width, height, depth); } @@ -1413,8 +1412,8 @@ partial class GraphicsDeviceExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(device); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(device); + default(ArgumentNullException).ThrowIfNull(source); ReadWriteTexture3D texture = new(device, source.GetLength(2), source.GetLength(1), source.GetLength(0), AllocationMode.Default); @@ -1438,7 +1437,7 @@ partial class GraphicsDeviceExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(device); + default(ArgumentNullException).ThrowIfNull(device); ReadWriteTexture3D texture = new(device, width, height, depth, AllocationMode.Default); @@ -1459,7 +1458,7 @@ partial class GraphicsDeviceExtensions public static UploadBuffer AllocateUploadBuffer(this GraphicsDevice device, int length, AllocationMode allocationMode = AllocationMode.Default) where T : unmanaged { - Guard.IsNotNull(device); + default(ArgumentNullException).ThrowIfNull(device); return new(device, length, allocationMode); } @@ -1475,7 +1474,7 @@ partial class GraphicsDeviceExtensions public static UploadTexture1D AllocateUploadTexture1D(this GraphicsDevice device, int width, AllocationMode allocationMode = AllocationMode.Default) where T : unmanaged { - Guard.IsNotNull(device); + default(ArgumentNullException).ThrowIfNull(device); return new(device, width, allocationMode); } @@ -1492,7 +1491,7 @@ partial class GraphicsDeviceExtensions public static UploadTexture2D AllocateUploadTexture2D(this GraphicsDevice device, int width, int height, AllocationMode allocationMode = AllocationMode.Default) where T : unmanaged { - Guard.IsNotNull(device); + default(ArgumentNullException).ThrowIfNull(device); return new(device, width, height, allocationMode); } @@ -1510,7 +1509,7 @@ partial class GraphicsDeviceExtensions public static UploadTexture3D AllocateUploadTexture3D(this GraphicsDevice device, int width, int height, int depth, AllocationMode allocationMode = AllocationMode.Default) where T : unmanaged { - Guard.IsNotNull(device); + default(ArgumentNullException).ThrowIfNull(device); return new(device, width, height, depth, allocationMode); } @@ -1527,7 +1526,7 @@ partial class GraphicsDeviceExtensions public static ReadBackBuffer AllocateReadBackBuffer(this GraphicsDevice device, int length, AllocationMode allocationMode = AllocationMode.Default) where T : unmanaged { - Guard.IsNotNull(device); + default(ArgumentNullException).ThrowIfNull(device); return new(device, length, allocationMode); } @@ -1543,7 +1542,7 @@ partial class GraphicsDeviceExtensions public static ReadBackTexture1D AllocateReadBackTexture1D(this GraphicsDevice device, int width, AllocationMode allocationMode = AllocationMode.Default) where T : unmanaged { - Guard.IsNotNull(device); + default(ArgumentNullException).ThrowIfNull(device); return new(device, width, allocationMode); } @@ -1560,7 +1559,7 @@ partial class GraphicsDeviceExtensions public static ReadBackTexture2D AllocateReadBackTexture2D(this GraphicsDevice device, int width, int height, AllocationMode allocationMode = AllocationMode.Default) where T : unmanaged { - Guard.IsNotNull(device); + default(ArgumentNullException).ThrowIfNull(device); return new(device, width, height, allocationMode); } @@ -1578,7 +1577,7 @@ partial class GraphicsDeviceExtensions public static ReadBackTexture3D AllocateReadBackTexture3D(this GraphicsDevice device, int width, int height, int depth, AllocationMode allocationMode = AllocationMode.Default) where T : unmanaged { - Guard.IsNotNull(device); + default(ArgumentNullException).ThrowIfNull(device); return new(device, width, height, depth, allocationMode); } @@ -1595,8 +1594,8 @@ partial class GraphicsDeviceExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(device); - Guard.IsNotNull(filename); + default(ArgumentNullException).ThrowIfNull(device); + default(ArgumentNullException).ThrowIfNull(filename); return device.LoadReadOnlyTexture2D(filename.AsSpan()); } @@ -1613,7 +1612,7 @@ partial class GraphicsDeviceExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(device); + default(ArgumentNullException).ThrowIfNull(device); using UploadTexture2D upload = WICHelper.Instance.LoadTexture(device, filename); @@ -1636,7 +1635,7 @@ partial class GraphicsDeviceExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(device); + default(ArgumentNullException).ThrowIfNull(device); using UploadTexture2D upload = WICHelper.Instance.LoadTexture(device, span); @@ -1659,8 +1658,8 @@ partial class GraphicsDeviceExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(device); - Guard.IsNotNull(stream); + default(ArgumentNullException).ThrowIfNull(device); + default(ArgumentNullException).ThrowIfNull(stream); using UploadTexture2D upload = WICHelper.Instance.LoadTexture(device, stream); @@ -1683,8 +1682,8 @@ partial class GraphicsDeviceExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(device); - Guard.IsNotNull(filename); + default(ArgumentNullException).ThrowIfNull(device); + default(ArgumentNullException).ThrowIfNull(filename); return device.LoadReadWriteTexture2D(filename.AsSpan()); } @@ -1701,7 +1700,7 @@ partial class GraphicsDeviceExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(device); + default(ArgumentNullException).ThrowIfNull(device); using UploadTexture2D upload = WICHelper.Instance.LoadTexture(device, filename); @@ -1724,7 +1723,7 @@ partial class GraphicsDeviceExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(device); + default(ArgumentNullException).ThrowIfNull(device); using UploadTexture2D upload = WICHelper.Instance.LoadTexture(device, span); @@ -1747,8 +1746,8 @@ partial class GraphicsDeviceExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(device); - Guard.IsNotNull(stream); + default(ArgumentNullException).ThrowIfNull(device); + default(ArgumentNullException).ThrowIfNull(stream); using UploadTexture2D upload = WICHelper.Instance.LoadTexture(device, stream); @@ -1769,8 +1768,8 @@ partial class GraphicsDeviceExtensions public static UploadTexture2D LoadUploadTexture2D(this GraphicsDevice device, string filename) where T : unmanaged { - Guard.IsNotNull(device); - Guard.IsNotNull(filename); + default(ArgumentNullException).ThrowIfNull(device); + default(ArgumentNullException).ThrowIfNull(filename); return device.LoadUploadTexture2D(filename.AsSpan()); } @@ -1785,7 +1784,7 @@ partial class GraphicsDeviceExtensions public static UploadTexture2D LoadUploadTexture2D(this GraphicsDevice device, ReadOnlySpan filename) where T : unmanaged { - Guard.IsNotNull(device); + default(ArgumentNullException).ThrowIfNull(device); return WICHelper.Instance.LoadTexture(device, filename); } @@ -1800,7 +1799,7 @@ partial class GraphicsDeviceExtensions public static UploadTexture2D LoadUploadTexture2D(this GraphicsDevice device, ReadOnlySpan span) where T : unmanaged { - Guard.IsNotNull(device); + default(ArgumentNullException).ThrowIfNull(device); return WICHelper.Instance.LoadTexture(device, span); } @@ -1815,8 +1814,8 @@ partial class GraphicsDeviceExtensions public static UploadTexture2D LoadUploadTexture2D(this GraphicsDevice device, Stream stream) where T : unmanaged { - Guard.IsNotNull(device); - Guard.IsNotNull(stream); + default(ArgumentNullException).ThrowIfNull(device); + default(ArgumentNullException).ThrowIfNull(stream); return WICHelper.Instance.LoadTexture(device, stream); } diff --git a/src/ComputeSharp/Graphics/Extensions/ReadBackBufferExtensions.cs b/src/ComputeSharp/Graphics/Extensions/ReadBackBufferExtensions.cs index b35105da..2d9132de 100644 --- a/src/ComputeSharp/Graphics/Extensions/ReadBackBufferExtensions.cs +++ b/src/ComputeSharp/Graphics/Extensions/ReadBackBufferExtensions.cs @@ -1,4 +1,4 @@ -using CommunityToolkit.Diagnostics; +using System; using ComputeSharp.Resources; namespace ComputeSharp; @@ -17,8 +17,8 @@ public static class ReadBackBufferExtensions public static void CopyFrom(this ReadBackBuffer destination, StructuredBuffer source) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); source.CopyTo(destination, 0, 0, source.Length); } @@ -35,8 +35,8 @@ public static class ReadBackBufferExtensions public static void CopyFrom(this ReadBackBuffer destination, StructuredBuffer source, int sourceOffset, int destinationOffset, int count) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); source.CopyTo(destination, sourceOffset, destinationOffset, count); } diff --git a/src/ComputeSharp/Graphics/Extensions/ReadBackTexture1DExtensions.cs b/src/ComputeSharp/Graphics/Extensions/ReadBackTexture1DExtensions.cs index 7720a3fd..dbb09aef 100644 --- a/src/ComputeSharp/Graphics/Extensions/ReadBackTexture1DExtensions.cs +++ b/src/ComputeSharp/Graphics/Extensions/ReadBackTexture1DExtensions.cs @@ -1,4 +1,4 @@ -using CommunityToolkit.Diagnostics; +using System; using ComputeSharp.Resources; namespace ComputeSharp; @@ -17,8 +17,8 @@ public static class ReadBackTexture1DExtensions public static void CopyFrom(this ReadBackTexture1D destination, Texture1D source) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); source.CopyTo(destination, 0, 0, source.Width); } @@ -34,8 +34,8 @@ public static class ReadBackTexture1DExtensions public static void CopyFrom(this ReadBackTexture1D destination, Texture1D source, int sourceOffsetX, int width) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); source.CopyTo(destination, sourceOffsetX, 0, width); } @@ -52,8 +52,8 @@ public static class ReadBackTexture1DExtensions public static void CopyFrom(this ReadBackTexture1D destination, Texture1D source, int sourceOffsetX, int destinationOffsetX, int width) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); source.CopyTo(destination, sourceOffsetX, destinationOffsetX, width); } diff --git a/src/ComputeSharp/Graphics/Extensions/ReadBackTexture2DExtensions.cs b/src/ComputeSharp/Graphics/Extensions/ReadBackTexture2DExtensions.cs index fd196cca..0ef1e871 100644 --- a/src/ComputeSharp/Graphics/Extensions/ReadBackTexture2DExtensions.cs +++ b/src/ComputeSharp/Graphics/Extensions/ReadBackTexture2DExtensions.cs @@ -1,7 +1,6 @@ using System; using System.Buffers; using System.IO; -using CommunityToolkit.Diagnostics; using ComputeSharp.Graphics.Helpers; using ComputeSharp.Resources; @@ -21,8 +20,8 @@ public static class ReadBackTexture2DExtensions public static void CopyFrom(this ReadBackTexture2D destination, Texture2D source) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); source.CopyTo(destination, 0, 0, 0, 0, source.Width, source.Height); } @@ -40,8 +39,8 @@ public static class ReadBackTexture2DExtensions public static void CopyFrom(this ReadBackTexture2D destination, Texture2D source, int sourceOffsetX, int sourceOffsetY, int width, int height) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); source.CopyTo(destination, sourceOffsetX, sourceOffsetY, 0, 0, width, height); } @@ -61,8 +60,8 @@ public static class ReadBackTexture2DExtensions public static void CopyFrom(this ReadBackTexture2D destination, Texture2D source, int sourceOffsetX, int sourceOffsetY, int destinationOffsetX, int destinationOffsetY, int width, int height) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); source.CopyTo(destination, sourceOffsetX, sourceOffsetY, destinationOffsetX, destinationOffsetY, width, height); } @@ -76,8 +75,8 @@ public static class ReadBackTexture2DExtensions public static void Save(this ReadBackTexture2D texture, string filename) where T : unmanaged { - Guard.IsNotNull(texture); - Guard.IsNotNull(filename); + default(ArgumentNullException).ThrowIfNull(texture); + default(ArgumentNullException).ThrowIfNull(filename); WICHelper.Instance.SaveTexture(texture.View, filename.AsSpan()); } @@ -91,7 +90,7 @@ public static class ReadBackTexture2DExtensions public static void Save(this ReadBackTexture2D texture, ReadOnlySpan filename) where T : unmanaged { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); WICHelper.Instance.SaveTexture(texture.View, filename); } @@ -106,8 +105,8 @@ public static class ReadBackTexture2DExtensions public static void Save(this ReadBackTexture2D texture, Stream stream, ImageFormat format) where T : unmanaged { - Guard.IsNotNull(texture); - Guard.IsNotNull(stream); + default(ArgumentNullException).ThrowIfNull(texture); + default(ArgumentNullException).ThrowIfNull(stream); WICHelper.Instance.SaveTexture(texture.View, stream, format); } @@ -122,8 +121,8 @@ public static class ReadBackTexture2DExtensions public static void Save(this ReadBackTexture2D texture, IBufferWriter writer, ImageFormat format) where T : unmanaged { - Guard.IsNotNull(texture); - Guard.IsNotNull(writer); + default(ArgumentNullException).ThrowIfNull(texture); + default(ArgumentNullException).ThrowIfNull(writer); WICHelper.Instance.SaveTexture(texture.View, writer, format); } diff --git a/src/ComputeSharp/Graphics/Extensions/ReadBackTexture3DExtensions.cs b/src/ComputeSharp/Graphics/Extensions/ReadBackTexture3DExtensions.cs index ab07892a..9c10faf0 100644 --- a/src/ComputeSharp/Graphics/Extensions/ReadBackTexture3DExtensions.cs +++ b/src/ComputeSharp/Graphics/Extensions/ReadBackTexture3DExtensions.cs @@ -1,4 +1,4 @@ -using CommunityToolkit.Diagnostics; +using System; using ComputeSharp.Resources; namespace ComputeSharp; @@ -17,8 +17,8 @@ public static class ReadBackTexture3DExtensions public static void CopyFrom(this ReadBackTexture3D destination, Texture3D source) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); source.CopyTo(destination, 0, 0, 0, 0, 0, 0, source.Width, source.Height, source.Depth); } @@ -38,8 +38,8 @@ public static class ReadBackTexture3DExtensions public static void CopyFrom(this ReadBackTexture3D destination, Texture3D source, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int width, int height, int depth) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); source.CopyTo(destination, sourceOffsetX, sourceOffsetY, sourceOffsetZ, 0, 0, 0, width, height, depth); } @@ -62,8 +62,8 @@ public static class ReadBackTexture3DExtensions public static void CopyFrom(this ReadBackTexture3D destination, Texture3D source, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int destinationOffsetX, int destinationOffsetY, int destinationOffsetZ, int width, int height, int depth) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); source.CopyTo(destination, sourceOffsetX, sourceOffsetY, sourceOffsetZ, destinationOffsetX, destinationOffsetY, destinationOffsetZ, width, height, depth); } diff --git a/src/ComputeSharp/Graphics/Extensions/ReadWriteTexture1DExtensions.cs b/src/ComputeSharp/Graphics/Extensions/ReadWriteTexture1DExtensions.cs index 565cdb04..bd75f279 100644 --- a/src/ComputeSharp/Graphics/Extensions/ReadWriteTexture1DExtensions.cs +++ b/src/ComputeSharp/Graphics/Extensions/ReadWriteTexture1DExtensions.cs @@ -1,5 +1,4 @@ using System; -using CommunityToolkit.Diagnostics; namespace ComputeSharp; @@ -29,7 +28,7 @@ public static class ReadWriteTexture1DExtensions /// Thrown if the current instance is not in a readonly state. public static IReadOnlyTexture1D AsReadOnly(this ReadWriteTexture1D texture) { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); return texture.AsReadOnly(); } @@ -55,7 +54,7 @@ public static class ReadWriteTexture1DExtensions /// Thrown if the current instance is not in a readonly state. public static IReadOnlyTexture1D AsReadOnly(this ReadWriteTexture1D texture) { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); return texture.AsReadOnly(); } @@ -81,7 +80,7 @@ public static class ReadWriteTexture1DExtensions /// Thrown if the current instance is not in a readonly state. public static IReadOnlyTexture1D AsReadOnly(this ReadWriteTexture1D texture) { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); return texture.AsReadOnly(); } @@ -107,7 +106,7 @@ public static class ReadWriteTexture1DExtensions /// Thrown if the current instance is not in a readonly state. public static IReadOnlyTexture1D AsReadOnly(this ReadWriteTexture1D texture) { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); return texture.AsReadOnly(); } @@ -137,7 +136,7 @@ public static class ReadWriteTexture1DExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); return texture.AsReadOnly(); } diff --git a/src/ComputeSharp/Graphics/Extensions/ReadWriteTexture2DExtensions.cs b/src/ComputeSharp/Graphics/Extensions/ReadWriteTexture2DExtensions.cs index efa1f2da..163e88d3 100644 --- a/src/ComputeSharp/Graphics/Extensions/ReadWriteTexture2DExtensions.cs +++ b/src/ComputeSharp/Graphics/Extensions/ReadWriteTexture2DExtensions.cs @@ -1,5 +1,4 @@ using System; -using CommunityToolkit.Diagnostics; namespace ComputeSharp; @@ -29,7 +28,7 @@ public static class ReadWriteTexture2DExtensions /// Thrown if the current instance is not in a readonly state. public static IReadOnlyTexture2D AsReadOnly(this ReadWriteTexture2D texture) { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); return texture.AsReadOnly(); } @@ -55,7 +54,7 @@ public static class ReadWriteTexture2DExtensions /// Thrown if the current instance is not in a readonly state. public static IReadOnlyTexture2D AsReadOnly(this ReadWriteTexture2D texture) { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); return texture.AsReadOnly(); } @@ -81,7 +80,7 @@ public static class ReadWriteTexture2DExtensions /// Thrown if the current instance is not in a readonly state. public static IReadOnlyTexture2D AsReadOnly(this ReadWriteTexture2D texture) { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); return texture.AsReadOnly(); } @@ -107,7 +106,7 @@ public static class ReadWriteTexture2DExtensions /// Thrown if the current instance is not in a readonly state. public static IReadOnlyTexture2D AsReadOnly(this ReadWriteTexture2D texture) { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); return texture.AsReadOnly(); } @@ -137,7 +136,7 @@ public static class ReadWriteTexture2DExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); return texture.AsReadOnly(); } diff --git a/src/ComputeSharp/Graphics/Extensions/ReadWriteTexture3DExtensions.cs b/src/ComputeSharp/Graphics/Extensions/ReadWriteTexture3DExtensions.cs index bc0621ab..ca96756c 100644 --- a/src/ComputeSharp/Graphics/Extensions/ReadWriteTexture3DExtensions.cs +++ b/src/ComputeSharp/Graphics/Extensions/ReadWriteTexture3DExtensions.cs @@ -1,5 +1,4 @@ using System; -using CommunityToolkit.Diagnostics; namespace ComputeSharp; @@ -29,7 +28,7 @@ public static class ReadWriteTexture3DExtensions /// Thrown if the current instance is not in a readonly state. public static IReadOnlyTexture3D AsReadOnly(this ReadWriteTexture3D texture) { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); return texture.AsReadOnly(); } @@ -55,7 +54,7 @@ public static class ReadWriteTexture3DExtensions /// Thrown if the current instance is not in a readonly state. public static IReadOnlyTexture3D AsReadOnly(this ReadWriteTexture3D texture) { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); return texture.AsReadOnly(); } @@ -81,7 +80,7 @@ public static class ReadWriteTexture3DExtensions /// Thrown if the current instance is not in a readonly state. public static IReadOnlyTexture3D AsReadOnly(this ReadWriteTexture3D texture) { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); return texture.AsReadOnly(); } @@ -107,7 +106,7 @@ public static class ReadWriteTexture3DExtensions /// Thrown if the current instance is not in a readonly state. public static IReadOnlyTexture3D AsReadOnly(this ReadWriteTexture3D texture) { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); return texture.AsReadOnly(); } @@ -137,7 +136,7 @@ public static class ReadWriteTexture3DExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); return texture.AsReadOnly(); } diff --git a/src/ComputeSharp/Graphics/Extensions/StructuredBufferExtensions.cs b/src/ComputeSharp/Graphics/Extensions/StructuredBufferExtensions.cs index 087201a9..7a466caf 100644 --- a/src/ComputeSharp/Graphics/Extensions/StructuredBufferExtensions.cs +++ b/src/ComputeSharp/Graphics/Extensions/StructuredBufferExtensions.cs @@ -1,4 +1,4 @@ -using CommunityToolkit.Diagnostics; +using System; using ComputeSharp.Resources; namespace ComputeSharp; @@ -17,8 +17,8 @@ public static class StructuredBufferExtensions public static void CopyTo(this StructuredBuffer source, ReadBackBuffer destination) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); source.CopyTo(destination, 0, 0, source.Length); } @@ -35,8 +35,8 @@ public static class StructuredBufferExtensions public static void CopyTo(this StructuredBuffer source, ReadBackBuffer destination, int sourceOffset, int destinationOffset, int count) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); source.CopyTo(destination, sourceOffset, destinationOffset, count); } @@ -50,8 +50,8 @@ public static class StructuredBufferExtensions public static void CopyFrom(this StructuredBuffer destination, UploadBuffer source) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); source.CopyTo(destination, 0, 0, source.Length); } @@ -68,8 +68,8 @@ public static class StructuredBufferExtensions public static void CopyFrom(this StructuredBuffer destination, UploadBuffer source, int sourceOffset, int destinationOffset, int count) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); source.CopyTo(destination, sourceOffset, destinationOffset, count); } diff --git a/src/ComputeSharp/Graphics/Extensions/Texture1DExtensions.cs b/src/ComputeSharp/Graphics/Extensions/Texture1DExtensions.cs index 40e37268..c91bd4f5 100644 --- a/src/ComputeSharp/Graphics/Extensions/Texture1DExtensions.cs +++ b/src/ComputeSharp/Graphics/Extensions/Texture1DExtensions.cs @@ -19,7 +19,7 @@ public static class Texture1DExtensions public static T[] ToArray(this Texture1D source) where T : unmanaged { - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(source); T[] data = new T[source.Width]; @@ -39,7 +39,7 @@ public static class Texture1DExtensions public static unsafe T[] ToArray(this Texture1D source, int x, int width) where T : unmanaged { - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(source); Guard.IsGreaterThanOrEqualTo(width, 0); T[] data = new T[width]; @@ -61,8 +61,8 @@ public static class Texture1DExtensions public static void CopyTo(this Texture1D source, T[] destination) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); source.CopyTo(destination.AsSpan(), 0, source.Width); } @@ -78,8 +78,8 @@ public static class Texture1DExtensions public static void CopyTo(this Texture1D source, T[] destination, Range x) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); source.CopyTo(destination.AsSpan(), x); } @@ -96,8 +96,8 @@ public static class Texture1DExtensions public static void CopyTo(this Texture1D source, T[] destination, int sourceOffsetX, int width) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); source.CopyTo(destination.AsSpan(), sourceOffsetX, width); } @@ -112,8 +112,8 @@ public static class Texture1DExtensions public static void CopyTo(this Texture1D source, T[] destination, int destinationOffset) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); source.CopyTo(destination.AsSpan(destinationOffset), 0, source.Width); } @@ -130,8 +130,8 @@ public static class Texture1DExtensions public static void CopyTo(this Texture1D source, T[] destination, int destinationOffset, Range x) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); source.CopyTo(destination.AsSpan(destinationOffset), x); } @@ -149,8 +149,8 @@ public static class Texture1DExtensions public static void CopyTo(this Texture1D source, T[] destination, int destinationOffset, int sourceOffsetX, int width) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); source.CopyTo(destination.AsSpan(destinationOffset), sourceOffsetX, width); } @@ -165,7 +165,7 @@ public static class Texture1DExtensions public static void CopyTo(this Texture1D source, Span destination) where T : unmanaged { - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(source); source.CopyTo(destination, 0, source.Width); } @@ -181,7 +181,7 @@ public static class Texture1DExtensions public static void CopyTo(this Texture1D source, Span destination, Range x) where T : unmanaged { - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(source); (int offsetX, int width) = x.GetOffsetAndLength(source.Width); @@ -200,7 +200,7 @@ public static class Texture1DExtensions public static void CopyTo(this Texture1D source, Span destination, int sourceOffsetX, int width) where T : unmanaged { - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(source); source.CopyTo(ref MemoryMarshal.GetReference(destination), destination.Length, sourceOffsetX, width); } @@ -214,8 +214,8 @@ public static class Texture1DExtensions public static void CopyTo(this Texture1D source, Texture1D destination) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); source.CopyTo(destination, 0, 0, source.Width); } @@ -231,8 +231,8 @@ public static class Texture1DExtensions public static void CopyTo(this Texture1D source, Texture1D destination, int sourceOffsetX, int width) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); source.CopyTo(destination, sourceOffsetX, 0, width); } @@ -249,8 +249,8 @@ public static class Texture1DExtensions public static void CopyTo(this Texture1D source, Texture1D destination, int sourceOffsetX, int destinationOffsetX, int width) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); source.CopyTo(destination, sourceOffsetX, destinationOffsetX, width); } @@ -264,8 +264,8 @@ public static class Texture1DExtensions public static void CopyTo(this Texture1D source, ReadBackTexture1D destination) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); source.CopyTo(destination, 0, 0, source.Width); } @@ -281,8 +281,8 @@ public static class Texture1DExtensions public static void CopyTo(this Texture1D source, ReadBackTexture1D destination, int sourceOffsetX, int width) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); source.CopyTo(destination, sourceOffsetX, 0, width); } @@ -299,8 +299,8 @@ public static class Texture1DExtensions public static void CopyTo(this Texture1D source, ReadBackTexture1D destination, int sourceOffsetX, int destinationOffsetX, int width) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); source.CopyTo(destination, sourceOffsetX, destinationOffsetX, width); } @@ -314,8 +314,8 @@ public static class Texture1DExtensions public static void CopyFrom(this Texture1D destination, T[] source) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); destination.CopyFrom(source.AsSpan(), 0, destination.Width); } @@ -331,8 +331,8 @@ public static class Texture1DExtensions public static void CopyFrom(this Texture1D destination, T[] source, Range x) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); destination.CopyFrom(source.AsSpan(), x); } @@ -349,8 +349,8 @@ public static class Texture1DExtensions public static void CopyFrom(this Texture1D destination, T[] source, int destinationOffsetX, int width) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); destination.CopyFrom(source.AsSpan(), destinationOffsetX, width); } @@ -367,8 +367,8 @@ public static class Texture1DExtensions public static void CopyFrom(this Texture1D destination, T[] source, int sourceOffset, Range x) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); destination.CopyFrom(source.AsSpan(sourceOffset), x); } @@ -386,8 +386,8 @@ public static class Texture1DExtensions public static void CopyFrom(this Texture1D destination, T[] source, int sourceOffset, int destinationOffsetX, int width) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); destination.CopyFrom(source.AsSpan(sourceOffset), destinationOffsetX, width); } @@ -402,7 +402,7 @@ public static class Texture1DExtensions public static void CopyFrom(this Texture1D destination, ReadOnlySpan source) where T : unmanaged { - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(destination); destination.CopyFrom(source, 0, destination.Width); } @@ -418,7 +418,7 @@ public static class Texture1DExtensions public static void CopyFrom(this Texture1D destination, ReadOnlySpan source, Range x) where T : unmanaged { - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(destination); (int offsetX, int width) = x.GetOffsetAndLength(destination.Width); @@ -437,7 +437,7 @@ public static class Texture1DExtensions public static void CopyFrom(this Texture1D destination, ReadOnlySpan source, int destinationOffsetX, int width) where T : unmanaged { - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(destination); destination.CopyFrom(ref MemoryMarshal.GetReference(source), source.Length, destinationOffsetX, width); } @@ -451,8 +451,8 @@ public static class Texture1DExtensions public static void CopyFrom(this Texture1D destination, Texture1D source) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); destination.CopyFrom(source, 0, 0, source.Width); } @@ -468,8 +468,8 @@ public static class Texture1DExtensions public static void CopyFrom(this Texture1D destination, Texture1D source, int sourceOffsetX, int width) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); source.CopyTo(destination, sourceOffsetX, 0, width); } @@ -486,8 +486,8 @@ public static class Texture1DExtensions public static void CopyFrom(this Texture1D destination, Texture1D source, int sourceOffsetX, int destinationOffsetX, int width) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); source.CopyTo(destination, sourceOffsetX, destinationOffsetX, width); } @@ -501,8 +501,8 @@ public static class Texture1DExtensions public static void CopyFrom(this Texture1D destination, UploadTexture1D source) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); source.CopyTo(destination, 0, 0, source.Width); } @@ -518,8 +518,8 @@ public static class Texture1DExtensions public static void CopyFrom(this Texture1D destination, UploadTexture1D source, int sourceOffsetX, int width) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); destination.CopyFrom(source, sourceOffsetX, 0, width); } @@ -536,8 +536,8 @@ public static class Texture1DExtensions public static void CopyFrom(this Texture1D destination, UploadTexture1D source, int sourceOffsetX, int destinationOffsetX, int width) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); destination.CopyFrom(source, sourceOffsetX, destinationOffsetX, width); } diff --git a/src/ComputeSharp/Graphics/Extensions/Texture2DExtensions.cs b/src/ComputeSharp/Graphics/Extensions/Texture2DExtensions.cs index f3015fa5..56accba3 100644 --- a/src/ComputeSharp/Graphics/Extensions/Texture2DExtensions.cs +++ b/src/ComputeSharp/Graphics/Extensions/Texture2DExtensions.cs @@ -22,7 +22,7 @@ public static class Texture2DExtensions public static T[,] ToArray(this Texture2D source) where T : unmanaged { - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(source); T[,] data = new T[source.Height, source.Width]; @@ -44,7 +44,7 @@ public static class Texture2DExtensions public static unsafe T[,] ToArray(this Texture2D source, int x, int y, int width, int height) where T : unmanaged { - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(source); Guard.IsGreaterThanOrEqualTo(width, 0); Guard.IsGreaterThanOrEqualTo(height, 0); @@ -67,8 +67,8 @@ public static class Texture2DExtensions public static void CopyTo(this Texture2D source, T[,] destination) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); Guard.IsEqualTo(destination.GetLength(0), source.Height, nameof(destination)); Guard.IsEqualTo(destination.GetLength(1), source.Width, nameof(destination)); @@ -84,8 +84,8 @@ public static class Texture2DExtensions public static void CopyTo(this Texture2D source, T[] destination) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); source.CopyTo(destination.AsSpan(), 0, 0, source.Width, source.Height); } @@ -102,8 +102,8 @@ public static class Texture2DExtensions public static void CopyTo(this Texture2D source, T[] destination, Range x, Range y) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); source.CopyTo(destination.AsSpan(), x, y); } @@ -122,8 +122,8 @@ public static class Texture2DExtensions public static void CopyTo(this Texture2D source, T[] destination, int sourceOffsetX, int sourceOffsetY, int width, int height) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); source.CopyTo(destination.AsSpan(), sourceOffsetX, sourceOffsetY, width, height); } @@ -138,8 +138,8 @@ public static class Texture2DExtensions public static void CopyTo(this Texture2D source, T[] destination, int destinationOffset) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); source.CopyTo(destination.AsSpan(destinationOffset), 0, 0, source.Width, source.Height); } @@ -157,8 +157,8 @@ public static class Texture2DExtensions public static void CopyTo(this Texture2D source, T[] destination, int destinationOffset, Range x, Range y) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); source.CopyTo(destination.AsSpan(destinationOffset), x, y); } @@ -178,8 +178,8 @@ public static class Texture2DExtensions public static void CopyTo(this Texture2D source, T[] destination, int destinationOffset, int sourceOffsetX, int sourceOffsetY, int width, int height) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); source.CopyTo(destination.AsSpan(destinationOffset), sourceOffsetX, sourceOffsetY, width, height); } @@ -194,7 +194,7 @@ public static class Texture2DExtensions public static void CopyTo(this Texture2D source, Span destination) where T : unmanaged { - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(source); source.CopyTo(destination, 0, 0, source.Width, source.Height); } @@ -211,7 +211,7 @@ public static class Texture2DExtensions public static void CopyTo(this Texture2D source, Span destination, Range x, Range y) where T : unmanaged { - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(source); (int offsetX, int width) = x.GetOffsetAndLength(source.Width); (int offsetY, int height) = y.GetOffsetAndLength(source.Height); @@ -233,7 +233,7 @@ public static class Texture2DExtensions public static void CopyTo(this Texture2D source, Span destination, int sourceOffsetX, int sourceOffsetY, int width, int height) where T : unmanaged { - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(source); source.CopyTo(ref MemoryMarshal.GetReference(destination), destination.Length, sourceOffsetX, sourceOffsetY, width, height); } @@ -247,8 +247,8 @@ public static class Texture2DExtensions public static void CopyTo(this Texture2D source, Texture2D destination) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); source.CopyTo(destination, 0, 0, 0, 0, source.Width, source.Height); } @@ -266,8 +266,8 @@ public static class Texture2DExtensions public static void CopyTo(this Texture2D source, Texture2D destination, int sourceOffsetX, int sourceOffsetY, int width, int height) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); source.CopyTo(destination, sourceOffsetX, sourceOffsetY, 0, 0, width, height); } @@ -287,8 +287,8 @@ public static class Texture2DExtensions public static void CopyTo(this Texture2D source, Texture2D destination, int sourceOffsetX, int sourceOffsetY, int destinationOffsetX, int destinationOffsetY, int width, int height) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); source.CopyTo(destination, sourceOffsetX, sourceOffsetY, destinationOffsetX, destinationOffsetY, width, height); } @@ -302,8 +302,8 @@ public static class Texture2DExtensions public static void CopyTo(this Texture2D source, ReadBackTexture2D destination) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); source.CopyTo(destination, 0, 0, 0, 0, source.Width, source.Height); } @@ -321,8 +321,8 @@ public static class Texture2DExtensions public static void CopyTo(this Texture2D source, ReadBackTexture2D destination, int sourceOffsetX, int sourceOffsetY, int width, int height) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); source.CopyTo(destination, sourceOffsetX, sourceOffsetY, 0, 0, width, height); } @@ -342,8 +342,8 @@ public static class Texture2DExtensions public static void CopyTo(this Texture2D source, ReadBackTexture2D destination, int sourceOffsetX, int sourceOffsetY, int destinationOffsetX, int destinationOffsetY, int width, int height) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); source.CopyTo(destination, sourceOffsetX, sourceOffsetY, destinationOffsetX, destinationOffsetY, width, height); } @@ -357,8 +357,8 @@ public static class Texture2DExtensions public static unsafe void CopyFrom(this Texture2D destination, T[,] source) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); Guard.IsEqualTo(source.GetLength(0), destination.Height, nameof(source)); Guard.IsEqualTo(source.GetLength(1), destination.Width, nameof(source)); @@ -374,8 +374,8 @@ public static class Texture2DExtensions public static void CopyFrom(this Texture2D destination, T[] source) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); destination.CopyFrom(source.AsSpan(), 0, 0, destination.Width, destination.Height); } @@ -392,8 +392,8 @@ public static class Texture2DExtensions public static void CopyFrom(this Texture2D destination, T[] source, Range x, Range y) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); destination.CopyFrom(source.AsSpan(), x, y); } @@ -412,8 +412,8 @@ public static class Texture2DExtensions public static void CopyFrom(this Texture2D destination, T[] source, int destinationOffsetX, int destinationOffsetY, int width, int height) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); destination.CopyFrom(source.AsSpan(), destinationOffsetX, destinationOffsetY, width, height); } @@ -431,8 +431,8 @@ public static class Texture2DExtensions public static void CopyFrom(this Texture2D destination, T[] source, int sourceOffset, Range x, Range y) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); destination.CopyFrom(source.AsSpan(sourceOffset), x, y); } @@ -452,8 +452,8 @@ public static class Texture2DExtensions public static void CopyFrom(this Texture2D destination, T[] source, int sourceOffset, int destinationOffsetX, int destinationOffsetY, int width, int height) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); destination.CopyFrom(source.AsSpan(sourceOffset), destinationOffsetX, destinationOffsetY, width, height); } @@ -468,7 +468,7 @@ public static class Texture2DExtensions public static void CopyFrom(this Texture2D destination, ReadOnlySpan source) where T : unmanaged { - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(destination); destination.CopyFrom(source, 0, 0, destination.Width, destination.Height); } @@ -485,7 +485,7 @@ public static class Texture2DExtensions public static void CopyFrom(this Texture2D destination, ReadOnlySpan source, Range x, Range y) where T : unmanaged { - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(destination); (int offsetX, int width) = x.GetOffsetAndLength(destination.Width); (int offsetY, int height) = y.GetOffsetAndLength(destination.Height); @@ -507,7 +507,7 @@ public static class Texture2DExtensions public static void CopyFrom(this Texture2D destination, ReadOnlySpan source, int destinationOffsetX, int destinationOffsetY, int width, int height) where T : unmanaged { - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(destination); destination.CopyFrom(ref MemoryMarshal.GetReference(source), source.Length, destinationOffsetX, destinationOffsetY, width, height); } @@ -521,8 +521,8 @@ public static class Texture2DExtensions public static void CopyFrom(this Texture2D destination, Texture2D source) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); destination.CopyFrom(source, 0, 0, 0, 0, source.Width, source.Height); } @@ -540,8 +540,8 @@ public static class Texture2DExtensions public static void CopyFrom(this Texture2D destination, Texture2D source, int sourceOffsetX, int sourceOffsetY, int width, int height) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); source.CopyTo(destination, sourceOffsetX, sourceOffsetY, 0, 0, width, height); } @@ -561,8 +561,8 @@ public static class Texture2DExtensions public static void CopyFrom(this Texture2D destination, Texture2D source, int sourceOffsetX, int sourceOffsetY, int destinationOffsetX, int destinationOffsetY, int width, int height) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); source.CopyTo(destination, sourceOffsetX, sourceOffsetY, destinationOffsetX, destinationOffsetY, width, height); } @@ -576,8 +576,8 @@ public static class Texture2DExtensions public static void CopyFrom(this Texture2D destination, UploadTexture2D source) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); source.CopyTo(destination, 0, 0, 0, 0, source.Width, source.Height); } @@ -595,8 +595,8 @@ public static class Texture2DExtensions public static void CopyFrom(this Texture2D destination, UploadTexture2D source, int sourceOffsetX, int sourceOffsetY, int width, int height) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); destination.CopyFrom(source, sourceOffsetX, sourceOffsetY, 0, 0, width, height); } @@ -616,8 +616,8 @@ public static class Texture2DExtensions public static void CopyFrom(this Texture2D destination, UploadTexture2D source, int sourceOffsetX, int sourceOffsetY, int destinationOffsetX, int destinationOffsetY, int width, int height) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); destination.CopyFrom(source, sourceOffsetX, sourceOffsetY, destinationOffsetX, destinationOffsetY, width, height); } @@ -631,8 +631,8 @@ public static class Texture2DExtensions public static void Save(this Texture2D texture, string filename) where T : unmanaged { - Guard.IsNotNull(texture); - Guard.IsNotNull(filename); + default(ArgumentNullException).ThrowIfNull(texture); + default(ArgumentNullException).ThrowIfNull(filename); texture.Save(filename.AsSpan()); } @@ -646,7 +646,7 @@ public static class Texture2DExtensions public static void Save(this Texture2D texture, ReadOnlySpan filename) where T : unmanaged { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); using ReadBackTexture2D readback = texture.GraphicsDevice.AllocateReadBackTexture2D(texture.Width, texture.Height); @@ -665,8 +665,8 @@ public static class Texture2DExtensions public static void Save(this Texture2D texture, Stream stream, ImageFormat format) where T : unmanaged { - Guard.IsNotNull(texture); - Guard.IsNotNull(stream); + default(ArgumentNullException).ThrowIfNull(texture); + default(ArgumentNullException).ThrowIfNull(stream); using ReadBackTexture2D readback = texture.GraphicsDevice.AllocateReadBackTexture2D(texture.Width, texture.Height); @@ -685,8 +685,8 @@ public static class Texture2DExtensions public static void Save(this Texture2D texture, IBufferWriter writer, ImageFormat format) where T : unmanaged { - Guard.IsNotNull(texture); - Guard.IsNotNull(writer); + default(ArgumentNullException).ThrowIfNull(texture); + default(ArgumentNullException).ThrowIfNull(writer); using ReadBackTexture2D readback = texture.GraphicsDevice.AllocateReadBackTexture2D(texture.Width, texture.Height); diff --git a/src/ComputeSharp/Graphics/Extensions/Texture3DExtensions.cs b/src/ComputeSharp/Graphics/Extensions/Texture3DExtensions.cs index ade73640..db76bfee 100644 --- a/src/ComputeSharp/Graphics/Extensions/Texture3DExtensions.cs +++ b/src/ComputeSharp/Graphics/Extensions/Texture3DExtensions.cs @@ -24,7 +24,7 @@ public static class Texture3DExtensions public static T[,,] ToArray(this Texture3D source) where T : unmanaged { - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(source); T[,,] data = new T[source.Depth, source.Height, source.Width]; @@ -48,7 +48,7 @@ public static class Texture3DExtensions public static unsafe T[,,] ToArray(this Texture3D source, int x, int y, int z, int width, int height, int depth) where T : unmanaged { - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(source); Guard.IsGreaterThanOrEqualTo(width, 0); Guard.IsGreaterThanOrEqualTo(height, 0); Guard.IsGreaterThanOrEqualTo(depth, 0); @@ -76,8 +76,8 @@ public static class Texture3DExtensions public static void CopyTo(this Texture3D source, T[,,] destination) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); Guard.IsEqualTo(destination.GetLength(0), source.Depth, nameof(destination)); Guard.IsEqualTo(destination.GetLength(1), source.Height, nameof(destination)); Guard.IsEqualTo(destination.GetLength(2), source.Width, nameof(destination)); @@ -95,8 +95,8 @@ public static class Texture3DExtensions public static void CopyTo(this Texture3D source, T[] destination, int destinationOffset) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); source.CopyTo(destination.AsSpan(destinationOffset), 0, 0, 0, source.Width, source.Height, source.Depth); } @@ -115,8 +115,8 @@ public static class Texture3DExtensions public static void CopyTo(this Texture3D source, T[] destination, int destinationOffset, Range x, Range y, Range z) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); source.CopyTo(destination.AsSpan(destinationOffset), x, y, z); } @@ -138,8 +138,8 @@ public static class Texture3DExtensions public static void CopyTo(this Texture3D source, T[] destination, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int destinationOffset, int width, int height, int depth) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); source.CopyTo(destination.AsSpan(destinationOffset), sourceOffsetX, sourceOffsetY, sourceOffsetZ, width, height, depth); } @@ -153,7 +153,7 @@ public static class Texture3DExtensions public static void CopyTo(this Texture3D source, Span destination) where T : unmanaged { - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(source); source.CopyTo(destination, 0, 0, 0, source.Width, source.Height, source.Depth); } @@ -171,7 +171,7 @@ public static class Texture3DExtensions public static void CopyTo(this Texture3D source, Span destination, Range x, Range y, Range z) where T : unmanaged { - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(source); (int offsetX, int width) = x.GetOffsetAndLength(source.Width); (int offsetY, int height) = y.GetOffsetAndLength(source.Height); @@ -196,7 +196,7 @@ public static class Texture3DExtensions public static void CopyTo(this Texture3D source, Span destination, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int width, int height, int depth) where T : unmanaged { - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(source); source.CopyTo(ref MemoryMarshal.GetReference(destination), destination.Length, sourceOffsetX, sourceOffsetY, sourceOffsetZ, width, height, depth); } @@ -210,8 +210,8 @@ public static class Texture3DExtensions public static void CopyTo(this Texture3D source, Texture3D destination) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); source.CopyTo(destination, 0, 0, 0, 0, 0, 0, source.Width, source.Height, source.Depth); } @@ -231,8 +231,8 @@ public static class Texture3DExtensions public static void CopyTo(this Texture3D source, Texture3D destination, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int width, int height, int depth) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); source.CopyTo(destination, sourceOffsetX, sourceOffsetY, sourceOffsetZ, 0, 0, 0, width, height, depth); } @@ -255,8 +255,8 @@ public static class Texture3DExtensions public static void CopyTo(this Texture3D source, Texture3D destination, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int destinationOffsetX, int destinationOffsetY, int destinationOffsetZ, int width, int height, int depth) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); source.CopyTo(destination, sourceOffsetX, sourceOffsetY, sourceOffsetZ, destinationOffsetX, destinationOffsetY, destinationOffsetZ, width, height, depth); } @@ -270,8 +270,8 @@ public static class Texture3DExtensions public static void CopyTo(this Texture3D source, ReadBackTexture3D destination) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); source.CopyTo(destination, 0, 0, 0, 0, 0, 0, source.Width, source.Height, source.Depth); } @@ -291,8 +291,8 @@ public static class Texture3DExtensions public static void CopyTo(this Texture3D source, ReadBackTexture3D destination, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int width, int height, int depth) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); source.CopyTo(destination, sourceOffsetX, sourceOffsetY, sourceOffsetZ, 0, 0, 0, width, height, depth); } @@ -315,8 +315,8 @@ public static class Texture3DExtensions public static void CopyTo(this Texture3D source, ReadBackTexture3D destination, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int destinationOffsetX, int destinationOffsetY, int destinationOffsetZ, int width, int height, int depth) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); source.CopyTo(destination, sourceOffsetX, sourceOffsetY, sourceOffsetZ, destinationOffsetX, destinationOffsetY, destinationOffsetZ, width, height, depth); } @@ -334,8 +334,8 @@ public static class Texture3DExtensions public static void CopyFrom(this Texture3D destination, T[,,] source) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); Guard.IsEqualTo(source.GetLength(0), destination.Depth, nameof(source)); Guard.IsEqualTo(source.GetLength(1), destination.Height, nameof(source)); Guard.IsEqualTo(source.GetLength(2), destination.Width, nameof(source)); @@ -352,8 +352,8 @@ public static class Texture3DExtensions public static void CopyFrom(this Texture3D destination, T[] source) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); destination.CopyFrom(source.AsSpan(), 0, 0, 0, destination.Width, destination.Height, destination.Depth); } @@ -371,8 +371,8 @@ public static class Texture3DExtensions public static void CopyFrom(this Texture3D destination, T[] source, Range x, Range y, Range z) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); destination.CopyFrom(source.AsSpan(), x, y, z); } @@ -393,8 +393,8 @@ public static class Texture3DExtensions public static void CopyFrom(this Texture3D destination, T[] source, int destinationOffsetX, int destinationOffsetY, int destinationOffsetZ, int width, int height, int depth) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); destination.CopyFrom(source.AsSpan(), destinationOffsetX, destinationOffsetY, destinationOffsetZ, width, height, depth); } @@ -413,8 +413,8 @@ public static class Texture3DExtensions public static void CopyFrom(this Texture3D destination, T[] source, int sourceOffset, Range x, Range y, Range z) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); destination.CopyFrom(source.AsSpan(sourceOffset), x, y, z); } @@ -436,8 +436,8 @@ public static class Texture3DExtensions public static void CopyFrom(this Texture3D destination, T[] source, int sourceOffset, int destinationOffsetX, int destinationOffsetY, int destinationOffsetZ, int width, int height, int depth) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); destination.CopyFrom(source.AsSpan(sourceOffset), destinationOffsetX, destinationOffsetY, destinationOffsetZ, width, height, depth); } @@ -452,7 +452,7 @@ public static class Texture3DExtensions public static void CopyFrom(this Texture3D destination, ReadOnlySpan source) where T : unmanaged { - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(destination); destination.CopyFrom(source, 0, 0, 0, destination.Width, destination.Height, destination.Depth); } @@ -470,7 +470,7 @@ public static class Texture3DExtensions public static void CopyFrom(this Texture3D destination, ReadOnlySpan source, Range x, Range y, Range z) where T : unmanaged { - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(destination); (int offsetX, int width) = x.GetOffsetAndLength(destination.Width); (int offsetY, int height) = y.GetOffsetAndLength(destination.Height); @@ -495,7 +495,7 @@ public static class Texture3DExtensions public static void CopyFrom(this Texture3D destination, ReadOnlySpan source, int destinationOffsetX, int destinationOffsetY, int destinationOffsetZ, int width, int height, int depth) where T : unmanaged { - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(destination); destination.CopyFrom(ref MemoryMarshal.GetReference(source), source.Length, destinationOffsetX, destinationOffsetY, destinationOffsetZ, width, height, depth); } @@ -509,8 +509,8 @@ public static class Texture3DExtensions public static void CopyFrom(this Texture3D destination, Texture3D source) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); source.CopyTo(destination, 0, 0, 0, 0, 0, 0, source.Width, source.Height, source.Depth); } @@ -530,8 +530,8 @@ public static class Texture3DExtensions public static void CopyFrom(this Texture3D destination, Texture3D source, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int width, int height, int depth) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); source.CopyTo(destination, sourceOffsetX, sourceOffsetY, sourceOffsetZ, 0, 0, 0, width, height, depth); } @@ -554,8 +554,8 @@ public static class Texture3DExtensions public static void CopyFrom(this Texture3D destination, Texture3D source, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int destinationOffsetX, int destinationOffsetY, int destinationOffsetZ, int width, int height, int depth) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); source.CopyTo(destination, sourceOffsetX, sourceOffsetY, sourceOffsetZ, destinationOffsetX, destinationOffsetY, destinationOffsetZ, width, height, depth); } @@ -569,8 +569,8 @@ public static class Texture3DExtensions public static void CopyFrom(this Texture3D destination, UploadTexture3D source) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); destination.CopyFrom(source, 0, 0, 0, 0, 0, 0, source.Width, source.Height, source.Depth); } @@ -590,8 +590,8 @@ public static class Texture3DExtensions public static void CopyFrom(this Texture3D destination, UploadTexture3D source, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int width, int height, int depth) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); destination.CopyFrom(source, sourceOffsetX, sourceOffsetY, sourceOffsetZ, 0, 0, 0, width, height, depth); } @@ -614,8 +614,8 @@ public static class Texture3DExtensions public static void CopyFrom(this Texture3D destination, UploadTexture3D source, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int destinationOffsetX, int destinationOffsetY, int destinationOffsetZ, int width, int height, int depth) where T : unmanaged { - Guard.IsNotNull(destination); - Guard.IsNotNull(source); + default(ArgumentNullException).ThrowIfNull(destination); + default(ArgumentNullException).ThrowIfNull(source); destination.CopyFrom(source, sourceOffsetX, sourceOffsetY, sourceOffsetZ, destinationOffsetX, destinationOffsetY, destinationOffsetZ, width, height, depth); } diff --git a/src/ComputeSharp/Graphics/Extensions/UploadBufferExtensions.cs b/src/ComputeSharp/Graphics/Extensions/UploadBufferExtensions.cs index 35de31cc..f1fccb95 100644 --- a/src/ComputeSharp/Graphics/Extensions/UploadBufferExtensions.cs +++ b/src/ComputeSharp/Graphics/Extensions/UploadBufferExtensions.cs @@ -1,4 +1,4 @@ -using CommunityToolkit.Diagnostics; +using System; using ComputeSharp.Resources; namespace ComputeSharp; @@ -17,8 +17,8 @@ public static class UploadBufferExtensions public static void CopyTo(this UploadBuffer source, StructuredBuffer destination) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); destination.CopyFrom(source, 0, 0, source.Length); } @@ -35,8 +35,8 @@ public static class UploadBufferExtensions public static void CopyTo(this UploadBuffer source, StructuredBuffer destination, int sourceOffset, int destinationOffset, int count) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); destination.CopyFrom(source, sourceOffset, destinationOffset, count); } diff --git a/src/ComputeSharp/Graphics/Extensions/UploadTexture1DExtensions.cs b/src/ComputeSharp/Graphics/Extensions/UploadTexture1DExtensions.cs index ef1d9844..9a0104b8 100644 --- a/src/ComputeSharp/Graphics/Extensions/UploadTexture1DExtensions.cs +++ b/src/ComputeSharp/Graphics/Extensions/UploadTexture1DExtensions.cs @@ -1,4 +1,4 @@ -using CommunityToolkit.Diagnostics; +using System; using ComputeSharp.Resources; namespace ComputeSharp; @@ -17,8 +17,8 @@ public static class UploadTexture1DExtensions public static void CopyTo(this UploadTexture1D source, Texture1D destination) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); destination.CopyFrom(source, 0, 0, source.Width); } @@ -34,8 +34,8 @@ public static class UploadTexture1DExtensions public static void CopyTo(this UploadTexture1D source, Texture1D destination, int sourceOffsetX, int width) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); destination.CopyFrom(source, sourceOffsetX, 0, width); } @@ -52,8 +52,8 @@ public static class UploadTexture1DExtensions public static void CopyTo(this UploadTexture1D source, Texture1D destination, int sourceOffsetX, int destinationOffsetX, int width) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); destination.CopyFrom(source, sourceOffsetX, destinationOffsetX, width); } diff --git a/src/ComputeSharp/Graphics/Extensions/UploadTexture2DExtensions.cs b/src/ComputeSharp/Graphics/Extensions/UploadTexture2DExtensions.cs index ac2a4273..7e8531ed 100644 --- a/src/ComputeSharp/Graphics/Extensions/UploadTexture2DExtensions.cs +++ b/src/ComputeSharp/Graphics/Extensions/UploadTexture2DExtensions.cs @@ -1,6 +1,5 @@ using System; using System.IO; -using CommunityToolkit.Diagnostics; using ComputeSharp.Graphics.Helpers; using ComputeSharp.Resources; @@ -20,8 +19,8 @@ public static class UploadTexture2DExtensions public static void CopyTo(this UploadTexture2D source, Texture2D destination) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); destination.CopyFrom(source, 0, 0, 0, 0, source.Width, source.Height); } @@ -39,8 +38,8 @@ public static class UploadTexture2DExtensions public static void CopyTo(this UploadTexture2D source, Texture2D destination, int sourceOffsetX, int sourceOffsetY, int width, int height) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); destination.CopyFrom(source, sourceOffsetX, sourceOffsetY, 0, 0, width, height); } @@ -60,8 +59,8 @@ public static class UploadTexture2DExtensions public static void CopyTo(this UploadTexture2D source, Texture2D destination, int sourceOffsetX, int sourceOffsetY, int destinationOffsetX, int destinationOffsetY, int width, int height) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); destination.CopyFrom(source, sourceOffsetX, sourceOffsetY, destinationOffsetX, destinationOffsetY, width, height); } @@ -75,8 +74,8 @@ public static class UploadTexture2DExtensions public static void Load(this UploadTexture2D texture, string filename) where T : unmanaged { - Guard.IsNotNull(texture); - Guard.IsNotNull(filename); + default(ArgumentNullException).ThrowIfNull(texture); + default(ArgumentNullException).ThrowIfNull(filename); texture.Load(filename.AsSpan()); } @@ -90,7 +89,7 @@ public static class UploadTexture2DExtensions public static void Load(this UploadTexture2D texture, ReadOnlySpan filename) where T : unmanaged { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); WICHelper.Instance.LoadTexture(texture.View, filename); } @@ -105,7 +104,7 @@ public static class UploadTexture2DExtensions public static void Load(this UploadTexture2D texture, ReadOnlySpan span) where T : unmanaged { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); WICHelper.Instance.LoadTexture(texture.View, span); } @@ -119,8 +118,8 @@ public static class UploadTexture2DExtensions public static void Load(this UploadTexture2D texture, Stream stream) where T : unmanaged { - Guard.IsNotNull(texture); - Guard.IsNotNull(stream); + default(ArgumentNullException).ThrowIfNull(texture); + default(ArgumentNullException).ThrowIfNull(stream); WICHelper.Instance.LoadTexture(texture.View, stream); } diff --git a/src/ComputeSharp/Graphics/Extensions/UploadTexture3DExtensions.cs b/src/ComputeSharp/Graphics/Extensions/UploadTexture3DExtensions.cs index 6590c16e..fcc41a6b 100644 --- a/src/ComputeSharp/Graphics/Extensions/UploadTexture3DExtensions.cs +++ b/src/ComputeSharp/Graphics/Extensions/UploadTexture3DExtensions.cs @@ -1,4 +1,4 @@ -using CommunityToolkit.Diagnostics; +using System; using ComputeSharp.Resources; namespace ComputeSharp; @@ -17,8 +17,8 @@ public static class UploadTexture3DExtensions public static void CopyTo(this UploadTexture3D source, Texture3D destination) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); destination.CopyFrom(source, 0, 0, 0, 0, 0, 0, source.Width, source.Height, source.Depth); } @@ -38,8 +38,8 @@ public static class UploadTexture3DExtensions public static void CopyTo(this UploadTexture3D source, Texture3D destination, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int width, int height, int depth) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); destination.CopyFrom(source, sourceOffsetX, sourceOffsetY, sourceOffsetZ, 0, 0, 0, width, height, depth); } @@ -62,8 +62,8 @@ public static class UploadTexture3DExtensions public static void CopyTo(this UploadTexture3D source, Texture3D destination, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int destinationOffsetX, int destinationOffsetY, int destinationOffsetZ, int width, int height, int depth) where T : unmanaged { - Guard.IsNotNull(source); - Guard.IsNotNull(destination); + default(ArgumentNullException).ThrowIfNull(source); + default(ArgumentNullException).ThrowIfNull(destination); destination.CopyFrom(source, sourceOffsetX, sourceOffsetY, sourceOffsetZ, destinationOffsetX, destinationOffsetY, destinationOffsetZ, width, height, depth); } diff --git a/src/ComputeSharp/Graphics/GraphicsDevice.GetDevice.cs b/src/ComputeSharp/Graphics/GraphicsDevice.GetDevice.cs index a4fe798e..5d9a5c6b 100644 --- a/src/ComputeSharp/Graphics/GraphicsDevice.GetDevice.cs +++ b/src/ComputeSharp/Graphics/GraphicsDevice.GetDevice.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using CommunityToolkit.Diagnostics; using ComputeSharp.Graphics.Helpers; namespace ComputeSharp; @@ -71,7 +70,7 @@ partial class GraphicsDevice /// public static IEnumerable QueryDevices(Predicate predicate) { - Guard.IsNotNull(predicate); + default(ArgumentNullException).ThrowIfNull(predicate); return new DeviceHelper.DeviceQuery(predicate); } diff --git a/src/ComputeSharp/Graphics/Helpers/__Internals/GraphicsResourceHelper.cs b/src/ComputeSharp/Graphics/Helpers/__Internals/GraphicsResourceHelper.cs index 1a090f20..8ecc696b 100644 --- a/src/ComputeSharp/Graphics/Helpers/__Internals/GraphicsResourceHelper.cs +++ b/src/ComputeSharp/Graphics/Helpers/__Internals/GraphicsResourceHelper.cs @@ -65,7 +65,7 @@ public static class GraphicsResourceHelper public static unsafe ulong ValidateAndGetGpuDescriptorHandle(Buffer buffer, GraphicsDevice device) where T : unmanaged { - Guard.IsNotNull(buffer); + default(ArgumentNullException).ThrowIfNull(buffer); using ReferenceTracker.Lease _0 = buffer.GetReferenceTracker().GetLease(); @@ -87,7 +87,7 @@ public static class GraphicsResourceHelper public static unsafe ulong ValidateAndGetGpuDescriptorHandle(ReadOnlyTexture1D texture, GraphicsDevice device) where T : unmanaged { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); using ReferenceTracker.Lease _0 = texture.GetReferenceTracker().GetLease(); @@ -109,7 +109,7 @@ public static class GraphicsResourceHelper public static unsafe ulong ValidateAndGetGpuDescriptorHandle(ReadWriteTexture1D texture, GraphicsDevice device) where T : unmanaged { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); using ReferenceTracker.Lease _0 = texture.GetReferenceTracker().GetLease(); @@ -131,7 +131,7 @@ public static class GraphicsResourceHelper public static unsafe ulong ValidateAndGetGpuDescriptorHandle(IReadOnlyTexture1D texture, GraphicsDevice device) where T : unmanaged { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); if (texture is IGraphicsResource resource) { @@ -154,7 +154,7 @@ public static class GraphicsResourceHelper public static unsafe ulong ValidateAndGetGpuDescriptorHandle(IReadOnlyNormalizedTexture1D texture, GraphicsDevice device) where TPixel : unmanaged { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); if (texture is IGraphicsResource resource) { @@ -177,7 +177,7 @@ public static class GraphicsResourceHelper public static unsafe ulong ValidateAndGetGpuDescriptorHandle(IReadWriteNormalizedTexture1D texture, GraphicsDevice device) where TPixel : unmanaged { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); if (texture is IGraphicsResource resource) { @@ -200,7 +200,7 @@ public static class GraphicsResourceHelper public static unsafe ulong ValidateAndGetGpuDescriptorHandle(ReadOnlyTexture2D texture, GraphicsDevice device) where T : unmanaged { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); using ReferenceTracker.Lease _0 = texture.GetReferenceTracker().GetLease(); @@ -222,7 +222,7 @@ public static class GraphicsResourceHelper public static unsafe ulong ValidateAndGetGpuDescriptorHandle(ReadWriteTexture2D texture, GraphicsDevice device) where T : unmanaged { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); using ReferenceTracker.Lease _0 = texture.GetReferenceTracker().GetLease(); @@ -244,7 +244,7 @@ public static class GraphicsResourceHelper public static unsafe ulong ValidateAndGetGpuDescriptorHandle(IReadOnlyTexture2D texture, GraphicsDevice device) where T : unmanaged { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); if (texture is IGraphicsResource resource) { @@ -267,7 +267,7 @@ public static class GraphicsResourceHelper public static unsafe ulong ValidateAndGetGpuDescriptorHandle(IReadOnlyNormalizedTexture2D texture, GraphicsDevice device) where TPixel : unmanaged { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); if (texture is IGraphicsResource resource) { @@ -290,7 +290,7 @@ public static class GraphicsResourceHelper public static unsafe ulong ValidateAndGetGpuDescriptorHandle(IReadWriteNormalizedTexture2D texture, GraphicsDevice device) where TPixel : unmanaged { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); if (texture is IGraphicsResource resource) { @@ -313,7 +313,7 @@ public static class GraphicsResourceHelper public static unsafe ulong ValidateAndGetGpuDescriptorHandle(ReadOnlyTexture3D texture, GraphicsDevice device) where T : unmanaged { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); using ReferenceTracker.Lease _0 = texture.GetReferenceTracker().GetLease(); @@ -335,7 +335,7 @@ public static class GraphicsResourceHelper public static unsafe ulong ValidateAndGetGpuDescriptorHandle(ReadWriteTexture3D texture, GraphicsDevice device) where T : unmanaged { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); using ReferenceTracker.Lease _0 = texture.GetReferenceTracker().GetLease(); @@ -357,7 +357,7 @@ public static class GraphicsResourceHelper public static unsafe ulong ValidateAndGetGpuDescriptorHandle(IReadOnlyTexture3D texture, GraphicsDevice device) where T : unmanaged { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); if (texture is IGraphicsResource resource) { @@ -380,7 +380,7 @@ public static class GraphicsResourceHelper public static unsafe ulong ValidateAndGetGpuDescriptorHandle(IReadOnlyNormalizedTexture3D texture, GraphicsDevice device) where TPixel : unmanaged { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); if (texture is IGraphicsResource resource) { @@ -403,7 +403,7 @@ public static class GraphicsResourceHelper public static unsafe ulong ValidateAndGetGpuDescriptorHandle(IReadWriteNormalizedTexture3D texture, GraphicsDevice device) where TPixel : unmanaged { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); if (texture is IGraphicsResource resource) { diff --git a/src/ComputeSharp/Shaders/Extensions/ComputeContextExtensions.cs b/src/ComputeSharp/Shaders/Extensions/ComputeContextExtensions.cs index 395f78fe..a3ce97a0 100644 --- a/src/ComputeSharp/Shaders/Extensions/ComputeContextExtensions.cs +++ b/src/ComputeSharp/Shaders/Extensions/ComputeContextExtensions.cs @@ -1,5 +1,5 @@ +using System; using System.Runtime.CompilerServices; -using CommunityToolkit.Diagnostics; using ComputeSharp.__Internals; using ComputeSharp.Graphics.Helpers; using ComputeSharp.Interop; @@ -23,7 +23,7 @@ public static class ComputeContextExtensions public static unsafe void Barrier(this in ComputeContext context, ReadWriteBuffer buffer) where T : unmanaged { - Guard.IsNotNull(buffer); + default(ArgumentNullException).ThrowIfNull(buffer); using ReferenceTracker.Lease lease = default; @@ -39,7 +39,7 @@ public static class ComputeContextExtensions public static unsafe void Barrier(this in ComputeContext context, ReadWriteTexture1D texture) where T : unmanaged { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); using ReferenceTracker.Lease lease = default; @@ -55,7 +55,7 @@ public static class ComputeContextExtensions public static unsafe void Barrier(this in ComputeContext context, ReadWriteTexture2D texture) where T : unmanaged { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); using ReferenceTracker.Lease lease = default; @@ -71,7 +71,7 @@ public static class ComputeContextExtensions public static unsafe void Barrier(this in ComputeContext context, ReadWriteTexture3D texture) where T : unmanaged { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); using ReferenceTracker.Lease lease = default; @@ -89,7 +89,7 @@ public static class ComputeContextExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); using ReferenceTracker.Lease lease = default; @@ -107,7 +107,7 @@ public static class ComputeContextExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); using ReferenceTracker.Lease lease = default; @@ -125,7 +125,7 @@ public static class ComputeContextExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); using ReferenceTracker.Lease lease = default; @@ -141,7 +141,7 @@ public static class ComputeContextExtensions public static unsafe void Barrier(this in ComputeContext context, IReadWriteNormalizedTexture1D texture) where TPixel : unmanaged { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); using ReferenceTracker.Lease lease = default; @@ -157,7 +157,7 @@ public static class ComputeContextExtensions public static unsafe void Barrier(this in ComputeContext context, IReadWriteNormalizedTexture2D texture) where TPixel : unmanaged { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); using ReferenceTracker.Lease lease = default; @@ -173,7 +173,7 @@ public static class ComputeContextExtensions public static unsafe void Barrier(this in ComputeContext context, IReadWriteNormalizedTexture3D texture) where TPixel : unmanaged { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); using ReferenceTracker.Lease lease = default; @@ -189,7 +189,7 @@ public static class ComputeContextExtensions public static unsafe void Clear(this in ComputeContext context, ReadWriteBuffer buffer) where T : unmanaged { - Guard.IsNotNull(buffer); + default(ArgumentNullException).ThrowIfNull(buffer); (D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = buffer.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice); @@ -205,7 +205,7 @@ public static class ComputeContextExtensions public static unsafe void Clear(this in ComputeContext context, ReadWriteTexture1D texture) where T : unmanaged { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); (D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = texture.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out bool isNormalized); @@ -221,7 +221,7 @@ public static class ComputeContextExtensions public static unsafe void Clear(this in ComputeContext context, ReadWriteTexture2D texture) where T : unmanaged { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); (D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = texture.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out bool isNormalized); @@ -237,7 +237,7 @@ public static class ComputeContextExtensions public static unsafe void Clear(this in ComputeContext context, ReadWriteTexture3D texture) where T : unmanaged { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); (D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = texture.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out bool isNormalized); @@ -255,7 +255,7 @@ public static class ComputeContextExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); (D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = texture.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _); @@ -273,7 +273,7 @@ public static class ComputeContextExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); (D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = texture.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _); @@ -291,7 +291,7 @@ public static class ComputeContextExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); (D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = texture.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _); @@ -307,7 +307,7 @@ public static class ComputeContextExtensions public static unsafe void Clear(this in ComputeContext context, IReadWriteNormalizedTexture1D texture) where TPixel : unmanaged { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); (D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = ((GraphicsResourceHelper.IGraphicsResource)texture).ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _); @@ -325,7 +325,7 @@ public static class ComputeContextExtensions public static unsafe void Clear(this in ComputeContext context, IReadWriteNormalizedTexture2D texture) where TPixel : unmanaged { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); (D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = ((GraphicsResourceHelper.IGraphicsResource)texture).ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _); @@ -343,7 +343,7 @@ public static class ComputeContextExtensions public static unsafe void Clear(this in ComputeContext context, IReadWriteNormalizedTexture3D texture) where TPixel : unmanaged { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); (D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = ((GraphicsResourceHelper.IGraphicsResource)texture).ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _); @@ -364,7 +364,7 @@ public static class ComputeContextExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); (D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = texture.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _); @@ -383,7 +383,7 @@ public static class ComputeContextExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); (D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = texture.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _); @@ -402,7 +402,7 @@ public static class ComputeContextExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); (D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = texture.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _); @@ -419,7 +419,7 @@ public static class ComputeContextExtensions public static unsafe void Fill(this in ComputeContext context, IReadWriteNormalizedTexture1D texture, TPixel value) where TPixel : unmanaged { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); (D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = ((GraphicsResourceHelper.IGraphicsResource)texture).ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _); @@ -442,7 +442,7 @@ public static class ComputeContextExtensions public static unsafe void Fill(this in ComputeContext context, IReadWriteNormalizedTexture2D texture, TPixel value) where TPixel : unmanaged { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); (D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = ((GraphicsResourceHelper.IGraphicsResource)texture).ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _); @@ -465,7 +465,7 @@ public static class ComputeContextExtensions public static unsafe void Fill(this in ComputeContext context, IReadWriteNormalizedTexture3D texture, TPixel value) where TPixel : unmanaged { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); (D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = ((GraphicsResourceHelper.IGraphicsResource)texture).ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _); @@ -549,7 +549,7 @@ public static class ComputeContextExtensions where T : struct, IPixelShader where TPixel : unmanaged { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); context.Run(texture, ref Unsafe.AsRef(default(T))); } @@ -566,7 +566,7 @@ public static class ComputeContextExtensions where T : struct, IPixelShader where TPixel : unmanaged { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); context.Run(texture, ref Unsafe.AsRef(in shader)); } @@ -579,7 +579,7 @@ public static class ComputeContextExtensions /// The state to transition the input resource to. public static unsafe void Transition(this in ComputeContext context, ReadWriteTexture1D texture, ResourceState resourceState) { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); using ReferenceTracker.Lease lease = default; @@ -596,7 +596,7 @@ public static class ComputeContextExtensions /// The state to transition the input resource to. public static unsafe void Transition(this in ComputeContext context, ReadWriteTexture1D texture, ResourceState resourceState) { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); using ReferenceTracker.Lease lease = default; @@ -613,7 +613,7 @@ public static class ComputeContextExtensions /// The state to transition the input resource to. public static unsafe void Transition(this in ComputeContext context, ReadWriteTexture1D texture, ResourceState resourceState) { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); using ReferenceTracker.Lease lease = default; @@ -630,7 +630,7 @@ public static class ComputeContextExtensions /// The state to transition the input resource to. public static unsafe void Transition(this in ComputeContext context, ReadWriteTexture1D texture, ResourceState resourceState) { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); using ReferenceTracker.Lease lease = default; @@ -651,7 +651,7 @@ public static class ComputeContextExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); using ReferenceTracker.Lease lease = default; @@ -668,7 +668,7 @@ public static class ComputeContextExtensions /// The state to transition the input resource to. public static unsafe void Transition(this in ComputeContext context, ReadWriteTexture2D texture, ResourceState resourceState) { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); using ReferenceTracker.Lease lease = default; @@ -685,7 +685,7 @@ public static class ComputeContextExtensions /// The state to transition the input resource to. public static unsafe void Transition(this in ComputeContext context, ReadWriteTexture2D texture, ResourceState resourceState) { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); using ReferenceTracker.Lease lease = default; @@ -702,7 +702,7 @@ public static class ComputeContextExtensions /// The state to transition the input resource to. public static unsafe void Transition(this in ComputeContext context, ReadWriteTexture2D texture, ResourceState resourceState) { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); using ReferenceTracker.Lease lease = default; @@ -719,7 +719,7 @@ public static class ComputeContextExtensions /// The state to transition the input resource to. public static unsafe void Transition(this in ComputeContext context, ReadWriteTexture2D texture, ResourceState resourceState) { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); using ReferenceTracker.Lease lease = default; @@ -740,7 +740,7 @@ public static class ComputeContextExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); using ReferenceTracker.Lease lease = default; @@ -757,7 +757,7 @@ public static class ComputeContextExtensions /// The state to transition the input resource to. public static unsafe void Transition(this in ComputeContext context, ReadWriteTexture3D texture, ResourceState resourceState) { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); using ReferenceTracker.Lease lease = default; @@ -774,7 +774,7 @@ public static class ComputeContextExtensions /// The state to transition the input resource to. public static unsafe void Transition(this in ComputeContext context, ReadWriteTexture3D texture, ResourceState resourceState) { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); using ReferenceTracker.Lease lease = default; @@ -791,7 +791,7 @@ public static class ComputeContextExtensions /// The state to transition the input resource to. public static unsafe void Transition(this in ComputeContext context, ReadWriteTexture3D texture, ResourceState resourceState) { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); using ReferenceTracker.Lease lease = default; @@ -808,7 +808,7 @@ public static class ComputeContextExtensions /// The state to transition the input resource to. public static unsafe void Transition(this in ComputeContext context, ReadWriteTexture3D texture, ResourceState resourceState) { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); using ReferenceTracker.Lease lease = default; @@ -829,7 +829,7 @@ public static class ComputeContextExtensions where T : unmanaged, IPixel where TPixel : unmanaged { - Guard.IsNotNull(texture); + default(ArgumentNullException).ThrowIfNull(texture); using ReferenceTracker.Lease lease = default;