using System.ComponentModel; using System.Diagnostics; #if NETCOREAPP3_1_OR_GREATER using System.Diagnostics.CodeAnalysis; #endif using System.Runtime.CompilerServices; #pragma warning disable IDE0065 namespace ComputeSharp.D2D1.Tests.Extensions; using HRESULT = Win32.HResult; /// /// Helper methods to efficiently throw exceptions. /// /// Trimmed down version of the same file in ComputeSharp. [DebuggerStepThrough] internal static class HRESULTExtensions { /// /// Throws a if represents an error. /// /// The input to check. /// Thrown if represents an error. [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Assert(this HRESULT result) { if ((int)result < 0) { ThrowWin32Exception(result); } } /// /// Throws a if represents an error. /// /// The input to check. /// Thrown if represents an error. [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Assert(this int result) { if (result < 0) { ThrowWin32Exception(result); } } /// /// Throws a . /// /// The input return code. #if NETCOREAPP3_1_OR_GREATER [DoesNotReturn] #endif private static void ThrowWin32Exception(int result) { throw new Win32Exception(result); } }