From 052bf969c775345344fda49f7b4b1e1e5d6faa11 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Mon, 23 Nov 2020 12:46:44 +0100 Subject: [PATCH] Switched to ThrowHelper from Microsoft.Toolkit --- .../ComputeSharp.Core.csproj | 1 + .../Extensions/HResultExtensions.cs | 2 +- src/ComputeSharp.Core/Helpers/ThrowHelper.cs | 93 ------------------- .../Extensions/ID3D12DeviceExtensions.cs | 2 +- src/ComputeSharp.Graphics/GraphicsDevice.cs | 2 +- .../Helpers/DeviceHelper.cs | 2 +- .../Extensions/ILGeneratorExtensions.cs | 2 +- .../Extensions/SyntaxNodeExtensions.cs | 2 +- .../Translation/MethodDecompiler.cs | 2 +- .../Translation/Models/ReadableMember.cs | 2 +- .../Translation/ShaderLoader{T}.IL.cs | 2 +- .../Translation/ShaderLoader{T}.cs | 2 +- src/ComputeSharp/ComputeSharp.nuspec | 3 +- 13 files changed, 13 insertions(+), 104 deletions(-) delete mode 100644 src/ComputeSharp.Core/Helpers/ThrowHelper.cs diff --git a/src/ComputeSharp.Core/ComputeSharp.Core.csproj b/src/ComputeSharp.Core/ComputeSharp.Core.csproj index ff33bf1a..eb0e9816 100644 --- a/src/ComputeSharp.Core/ComputeSharp.Core.csproj +++ b/src/ComputeSharp.Core/ComputeSharp.Core.csproj @@ -6,6 +6,7 @@ + diff --git a/src/ComputeSharp.Core/Extensions/HResultExtensions.cs b/src/ComputeSharp.Core/Extensions/HResultExtensions.cs index 6909de09..f085dccc 100644 --- a/src/ComputeSharp.Core/Extensions/HResultExtensions.cs +++ b/src/ComputeSharp.Core/Extensions/HResultExtensions.cs @@ -1,7 +1,7 @@ using System.ComponentModel; using System.Diagnostics; using System.Runtime.CompilerServices; -using ComputeSharp.Core.Helpers; +using Microsoft.Toolkit.Diagnostics; using HRESULT = System.Int32; namespace ComputeSharp.Core.Extensions diff --git a/src/ComputeSharp.Core/Helpers/ThrowHelper.cs b/src/ComputeSharp.Core/Helpers/ThrowHelper.cs deleted file mode 100644 index 15586d1a..00000000 --- a/src/ComputeSharp.Core/Helpers/ThrowHelper.cs +++ /dev/null @@ -1,93 +0,0 @@ -using System; -using System.ComponentModel; -using System.Diagnostics.CodeAnalysis; - -namespace ComputeSharp.Core.Helpers -{ - /// - /// Helper methods to efficiently throw exceptions. - /// - internal static partial class ThrowHelper - { - /// - /// Throws a new . - /// - /// Thrown with no parameters. - [DoesNotReturn] - public static void ThrowArgumentException() - { - throw new ArgumentException(); - } - - /// - /// Throws a new . - /// - /// The message to include in the exception. - /// Thrown with the specified parameter. - [DoesNotReturn] - public static void ThrowArgumentException(string message) - { - throw new ArgumentException(message); - } - - /// - /// Throws a new . - /// - /// The message to include in the exception. - /// Thrown with the specified parameter. - [DoesNotReturn] - public static void ThrowInvalidOperationException(string message) - { - throw new InvalidOperationException(message); - } - - /// - /// Throws a new . - /// - /// The Win32 error code associated with this exception. - /// Thrown with the specified parameter. - [DoesNotReturn] - public static void ThrowWin32Exception(int error) - { - throw new Win32Exception(error); - } - - /// - /// Throws a new . - /// - /// The type of expected result. - /// Thrown with no parameters. - /// This method always throws, so it actually never returns a value. - [DoesNotReturn] - public static T ThrowArgumentException() - { - throw new ArgumentException(); - } - - /// - /// Throws a new . - /// - /// The type of expected result. - /// The message to include in the exception. - /// Thrown with the specified parameter. - /// This method always throws, so it actually never returns a value. - [DoesNotReturn] - public static T ThrowArgumentException(string message) - { - throw new ArgumentException(message); - } - - /// - /// Throws a new . - /// - /// The type of expected result. - /// The message to include in the exception. - /// Thrown with the specified parameter. - /// This method always throws, so it actually never returns a value. - [DoesNotReturn] - public static T ThrowNotSupportedException(string message) - { - throw new NotSupportedException(message); - } - } -} \ No newline at end of file diff --git a/src/ComputeSharp.Graphics/Extensions/ID3D12DeviceExtensions.cs b/src/ComputeSharp.Graphics/Extensions/ID3D12DeviceExtensions.cs index 79a26748..101d8f3b 100644 --- a/src/ComputeSharp.Graphics/Extensions/ID3D12DeviceExtensions.cs +++ b/src/ComputeSharp.Graphics/Extensions/ID3D12DeviceExtensions.cs @@ -1,8 +1,8 @@ using System; using System.Diagnostics.Contracts; using ComputeSharp.Core.Extensions; -using ComputeSharp.Core.Helpers; using ComputeSharp.Graphics.Buffers.Enums; +using Microsoft.Toolkit.Diagnostics; using TerraFX.Interop; using static TerraFX.Interop.D3D12_COMMAND_QUEUE_FLAGS; using static TerraFX.Interop.D3D12_COMMAND_QUEUE_PRIORITY; diff --git a/src/ComputeSharp.Graphics/GraphicsDevice.cs b/src/ComputeSharp.Graphics/GraphicsDevice.cs index 1c7ae3c4..b474d7c2 100644 --- a/src/ComputeSharp.Graphics/GraphicsDevice.cs +++ b/src/ComputeSharp.Graphics/GraphicsDevice.cs @@ -1,11 +1,11 @@ using System.Diagnostics; using System.Runtime.CompilerServices; using ComputeSharp.Core.Extensions; -using ComputeSharp.Core.Helpers; using ComputeSharp.Core.Interop; using ComputeSharp.Graphics.Commands; using ComputeSharp.Graphics.Extensions; using ComputeSharp.Graphics.Helpers; +using Microsoft.Toolkit.Diagnostics; using TerraFX.Interop; using static TerraFX.Interop.D3D12_COMMAND_LIST_TYPE; using static TerraFX.Interop.D3D12_FEATURE; diff --git a/src/ComputeSharp.Graphics/Helpers/DeviceHelper.cs b/src/ComputeSharp.Graphics/Helpers/DeviceHelper.cs index 23842348..2f9dbb7e 100644 --- a/src/ComputeSharp.Graphics/Helpers/DeviceHelper.cs +++ b/src/ComputeSharp.Graphics/Helpers/DeviceHelper.cs @@ -2,7 +2,7 @@ using System.Diagnostics; using System.Diagnostics.Contracts; using ComputeSharp.Core.Extensions; -using ComputeSharp.Core.Helpers; +using Microsoft.Toolkit.Diagnostics; using TerraFX.Interop; using FX = TerraFX.Interop.Windows; using HRESULT = System.Int32; diff --git a/src/ComputeSharp.Shaders/Extensions/ILGeneratorExtensions.cs b/src/ComputeSharp.Shaders/Extensions/ILGeneratorExtensions.cs index 755da5da..e30e6719 100644 --- a/src/ComputeSharp.Shaders/Extensions/ILGeneratorExtensions.cs +++ b/src/ComputeSharp.Shaders/Extensions/ILGeneratorExtensions.cs @@ -1,6 +1,6 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using ComputeSharp.Core.Helpers; +using Microsoft.Toolkit.Diagnostics; namespace System.Reflection.Emit { diff --git a/src/ComputeSharp.Shaders/Extensions/SyntaxNodeExtensions.cs b/src/ComputeSharp.Shaders/Extensions/SyntaxNodeExtensions.cs index 74582357..d2fe0ce7 100644 --- a/src/ComputeSharp.Shaders/Extensions/SyntaxNodeExtensions.cs +++ b/src/ComputeSharp.Shaders/Extensions/SyntaxNodeExtensions.cs @@ -4,9 +4,9 @@ using System.Globalization; using System.Linq; using System.Reflection; using ComputeSharp; -using ComputeSharp.Core.Helpers; using ComputeSharp.Shaders.Mappings; using ComputeSharp.Shaders.Translation.Models; +using Microsoft.Toolkit.Diagnostics; namespace Microsoft.CodeAnalysis.CSharp.Syntax { diff --git a/src/ComputeSharp.Shaders/Translation/MethodDecompiler.cs b/src/ComputeSharp.Shaders/Translation/MethodDecompiler.cs index 08a65e53..7f49623c 100644 --- a/src/ComputeSharp.Shaders/Translation/MethodDecompiler.cs +++ b/src/ComputeSharp.Shaders/Translation/MethodDecompiler.cs @@ -7,7 +7,6 @@ using System.Linq; using System.Reflection; using System.Reflection.Metadata; using System.Text.RegularExpressions; -using ComputeSharp.Core.Helpers; using ComputeSharp.Shaders.Mappings; using ComputeSharp.Shaders.Translation.Enums; using ICSharpCode.Decompiler; @@ -16,6 +15,7 @@ using ICSharpCode.Decompiler.Metadata; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; +using Microsoft.Toolkit.Diagnostics; namespace ComputeSharp.Shaders.Translation { diff --git a/src/ComputeSharp.Shaders/Translation/Models/ReadableMember.cs b/src/ComputeSharp.Shaders/Translation/Models/ReadableMember.cs index af84ef4b..21b9afd9 100644 --- a/src/ComputeSharp.Shaders/Translation/Models/ReadableMember.cs +++ b/src/ComputeSharp.Shaders/Translation/Models/ReadableMember.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Diagnostics.Contracts; using System.Reflection; -using ComputeSharp.Core.Helpers; +using Microsoft.Toolkit.Diagnostics; namespace ComputeSharp.Shaders.Translation.Models { diff --git a/src/ComputeSharp.Shaders/Translation/ShaderLoader{T}.IL.cs b/src/ComputeSharp.Shaders/Translation/ShaderLoader{T}.IL.cs index cc2b52fe..61a6a8a3 100644 --- a/src/ComputeSharp.Shaders/Translation/ShaderLoader{T}.IL.cs +++ b/src/ComputeSharp.Shaders/Translation/ShaderLoader{T}.IL.cs @@ -5,12 +5,12 @@ using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using ComputeSharp.Core.Helpers; using ComputeSharp.Core.Interop; using ComputeSharp.Graphics; using ComputeSharp.Graphics.Buffers.Abstract; using ComputeSharp.Shaders.Mappings; using ComputeSharp.Shaders.Translation.Models; +using Microsoft.Toolkit.Diagnostics; using TerraFX.Interop; namespace ComputeSharp.Shaders.Translation diff --git a/src/ComputeSharp.Shaders/Translation/ShaderLoader{T}.cs b/src/ComputeSharp.Shaders/Translation/ShaderLoader{T}.cs index 785e156d..5332f7f9 100644 --- a/src/ComputeSharp.Shaders/Translation/ShaderLoader{T}.cs +++ b/src/ComputeSharp.Shaders/Translation/ShaderLoader{T}.cs @@ -5,7 +5,6 @@ using System.Linq; using System.Reflection; using System.Runtime.InteropServices; using System.Text.RegularExpressions; -using ComputeSharp.Core.Helpers; using ComputeSharp.Graphics.Extensions; using ComputeSharp.Shaders.Mappings; using ComputeSharp.Shaders.Renderer.Models.Fields; @@ -15,6 +14,7 @@ using ComputeSharp.Shaders.Translation.Enums; using ComputeSharp.Shaders.Translation.Models; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Syntax; +using Microsoft.Toolkit.Diagnostics; using TerraFX.Interop; using static TerraFX.Interop.D3D12_DESCRIPTOR_RANGE_TYPE; using ParameterInfo = ComputeSharp.Shaders.Renderer.Models.Functions.ParameterInfo; diff --git a/src/ComputeSharp/ComputeSharp.nuspec b/src/ComputeSharp/ComputeSharp.nuspec index 5dbb15d9..46218663 100644 --- a/src/ComputeSharp/ComputeSharp.nuspec +++ b/src/ComputeSharp/ComputeSharp.nuspec @@ -16,10 +16,11 @@ dotnet net netcore netstandard csharp library graphics shader hlsl compute gpu - + +