diff --git a/src/ComputeSharp.D2D1.UI/PixelShaderEffect{T}.ICanvasEffectFactoryNative.cs b/src/ComputeSharp.D2D1.UI/PixelShaderEffect{T}.ICanvasEffectFactoryNative.cs index 073b4ae2..a894c2f2 100644 --- a/src/ComputeSharp.D2D1.UI/PixelShaderEffect{T}.ICanvasEffectFactoryNative.cs +++ b/src/ComputeSharp.D2D1.UI/PixelShaderEffect{T}.ICanvasEffectFactoryNative.cs @@ -124,7 +124,7 @@ unsafe partial class PixelShaderEffect { *wrapper = null; - return E.E_INVALIDARG; + return D2DERR.D2DERR_WRONG_FACTORY; } } diff --git a/src/TerraFX.Interop.Windows.D2D1/Windows/shared/winerror/D2DERR.cs b/src/TerraFX.Interop.Windows.D2D1/Windows/shared/winerror/D2DERR.cs index 542a9408..472a86b8 100644 --- a/src/TerraFX.Interop.Windows.D2D1/Windows/shared/winerror/D2DERR.cs +++ b/src/TerraFX.Interop.Windows.D2D1/Windows/shared/winerror/D2DERR.cs @@ -7,12 +7,15 @@ namespace TerraFX.Interop.DirectX; internal static partial class D2DERR { - [NativeTypeName("#define D2DERR_INSUFFICIENT_DEVICE_CAPABILITIES _HRESULT_TYPEDEF_(0x88990026L)")] - public const int D2DERR_INSUFFICIENT_DEVICE_CAPABILITIES = unchecked((int)(0x88990026)); + [NativeTypeName("#define D2DERR_WRONG_FACTORY _HRESULT_TYPEDEF_(0x88990012L)")] + public const int D2DERR_WRONG_FACTORY = unchecked((int)(0x88990012)); [NativeTypeName("#define D2DERR_CYCLIC_GRAPH _HRESULT_TYPEDEF_(0x88990020L)")] public const int D2DERR_CYCLIC_GRAPH = unchecked((int)(0x88990020)); + [NativeTypeName("#define D2DERR_INSUFFICIENT_DEVICE_CAPABILITIES _HRESULT_TYPEDEF_(0x88990026L)")] + public const int D2DERR_INSUFFICIENT_DEVICE_CAPABILITIES = unchecked((int)(0x88990026)); + [NativeTypeName("#define D2DERR_EFFECT_IS_NOT_REGISTERED _HRESULT_TYPEDEF_(0x88990028L)")] public const int D2DERR_EFFECT_IS_NOT_REGISTERED = unchecked((int)(0x88990028)); } \ No newline at end of file diff --git a/tests/ComputeSharp.D2D1.UI.Tests/PixelShaderEffectTests.cs b/tests/ComputeSharp.D2D1.UI.Tests/PixelShaderEffectTests.cs index f02cbcd9..d1ca0216 100644 --- a/tests/ComputeSharp.D2D1.UI.Tests/PixelShaderEffectTests.cs +++ b/tests/ComputeSharp.D2D1.UI.Tests/PixelShaderEffectTests.cs @@ -428,7 +428,6 @@ public partial class PixelShaderEffectTests } [TestMethod] - [ExpectedException(typeof(ArgumentException))] public unsafe void Interop_WrapperFactoryDetectsMismatchedDevices() { using PixelShaderEffect effect = new(); @@ -443,7 +442,16 @@ public partial class PixelShaderEffectTests Win2DHelper.GetD2DImage(effect, canvasDevice2, d2D1Image2.GetAddressOf()); // The factory should detect we're passing an incompatible device for the resource - _ = Win2DHelper.GetOrCreate(d2D1Image1.Get(), canvasDevice2); + try + { + _ = Win2DHelper.GetOrCreate(d2D1Image1.Get(), canvasDevice2); + + Assert.Fail(); + } + catch (Exception e) + { + Assert.AreEqual(e.HResult, D2DERR.D2DERR_WRONG_FACTORY); + } } [D2DInputCount(0)]