diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml
index cae3f955..fa5d9def 100644
--- a/.github/workflows/dotnet.yml
+++ b/.github/workflows/dotnet.yml
@@ -122,12 +122,13 @@ jobs:
- name: Run ComputeSharp.D2D1.Tests.AssemblyLevelAttributes
run: dotnet test tests\ComputeSharp.D2D1.Tests.AssemblyLevelAttributes\ComputeSharp.D2D1.Tests.AssemblyLevelAttributes.csproj -c Release -f ${{matrix.framework}} -v n -l "console;verbosity=detailed"
- # Run all UWP tests (separately, as they need VS Test)
- run-tests-uwp:
+ # Run all Win2D tests (separately, as they need VS Test)
+ run-tests-win2d:
needs: [build-solution]
strategy:
matrix:
configuration: [Debug, Release]
+ framework: [uwp, wasdk]
runs-on: windows-2022
steps:
- name: Git checkout
@@ -136,17 +137,34 @@ jobs:
uses: microsoft/setup-msbuild@v1.1
# Build the D2D1 UWP unit tests (need to restore and build separately for it to build correctly)
- - name: Build ComputeSharp.D2D1.Uwp.Tests
+ - if: matrix.framework == 'uwp'
+ name: Build ComputeSharp.D2D1.Uwp.Tests
run: >
msbuild tests\ComputeSharp.D2D1.Uwp.Tests\ComputeSharp.D2D1.Uwp.Tests.csproj -t:restore /p:Configuration=${{matrix.configuration}} /p:Platform=x64;
msbuild tests\ComputeSharp.D2D1.Uwp.Tests\ComputeSharp.D2D1.Uwp.Tests.csproj -t:build /p:Configuration=${{matrix.configuration}} /p:Platform=x64
# Run the D2D1 UWP unit tests with VS Test (need to use vswhere to find the VS Test runner)
- - name: Run ComputeSharp.D2D1.Uwp.Tests
+ - if: matrix.framework == 'uwp'
+ name: Run ComputeSharp.D2D1.Uwp.Tests
run: >
$vs_path = vswhere -latest -products * -requires Microsoft.VisualStudio.Workload.ManagedDesktop -requiresAny -property installationPath;
$vstest_path = join-path $vs_path 'Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe';
& $vstest_path /Platform:x64 /framework:frameworkuap10 tests\ComputeSharp.D2D1.Uwp.Tests\bin\x64\${{matrix.configuration}}\ComputeSharp.D2D1.Uwp.Tests.build.appxrecipe
+
+ # Build the D2D1 WinAppSDK unit tests (this also needs two steps, or the entry point won't be generated)
+ - if: matrix.framework == 'wasdk'
+ name: Build ComputeSharp.D2D1.WinUI.Tests
+ run: >
+ msbuild tests\ComputeSharp.D2D1.WinUI.Tests\ComputeSharp.D2D1.WinUI.Tests.csproj -t:restore /p:Configuration=${{matrix.configuration}} /p:Platform=x64;
+ msbuild tests\ComputeSharp.D2D1.WinUI.Tests\ComputeSharp.D2D1.WinUI.Tests.csproj -t:build /p:Configuration=${{matrix.configuration}} /p:Platform=x64
+
+ # Run the D2D1 WinAppSDK unit tests with VS Test again
+ - if: matrix.framework == 'wasdk'
+ name: Run ComputeSharp.D2D1.WinUI.Tests
+ run: >
+ $vs_path = vswhere -latest -products * -requires Microsoft.VisualStudio.Workload.ManagedDesktop -requiresAny -property installationPath;
+ $vstest_path = join-path $vs_path 'Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe';
+ & $vstest_path /Platform:x64 tests\ComputeSharp.D2D1.WinUI.Tests\bin\x64\${{matrix.configuration}}\net6.0-windows10.0.22621.0\win10-x64\ComputeSharp.D2D1.WinUI.Tests.build.appxrecipe
# Run all the local samples to ensure they build and run with no errors
run-samples:
@@ -281,7 +299,7 @@ jobs:
# Publish the packages to GitHub packages
publish-nightlies-github:
- needs: [run-tests, run-tests-uwp, run-samples, run-samples-aot, verify-packages]
+ needs: [run-tests, run-tests-win2d, run-samples, run-samples-aot, verify-packages]
runs-on: windows-2022
if: ${{github.event_name == 'push'}}
steps:
@@ -293,7 +311,7 @@ jobs:
# Publish the packages to Azure DevOps
publish-nightlies-azure-devops:
- needs: [run-tests, run-tests-uwp, run-samples, run-samples-aot, verify-packages]
+ needs: [run-tests, run-tests-win2d, run-samples, run-samples-aot, verify-packages]
runs-on: windows-2022
if: ${{github.event_name == 'push'}}
steps:
diff --git a/ComputeSharp.sln b/ComputeSharp.sln
index b39cce02..0ad476a6 100644
--- a/ComputeSharp.sln
+++ b/ComputeSharp.sln
@@ -154,6 +154,8 @@ Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "ComputeSharp.D2D1.UI.Tests"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComputeSharp.D2D1.Uwp.Tests", "tests\ComputeSharp.D2D1.Uwp.Tests\ComputeSharp.D2D1.Uwp.Tests.csproj", "{4D4BB2F6-5653-4DB5-A8DD-90D58D8FE4D3}"
EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputeSharp.D2D1.WinUI.Tests", "tests\ComputeSharp.D2D1.WinUI.Tests\ComputeSharp.D2D1.WinUI.Tests.csproj", "{73C32D0F-64DB-4674-84E9-8FCC41228474}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
@@ -430,6 +432,18 @@ Global
{4D4BB2F6-5653-4DB5-A8DD-90D58D8FE4D3}.Release|x64.ActiveCfg = Release|x64
{4D4BB2F6-5653-4DB5-A8DD-90D58D8FE4D3}.Release|x64.Build.0 = Release|x64
{4D4BB2F6-5653-4DB5-A8DD-90D58D8FE4D3}.Release|x64.Deploy.0 = Release|x64
+ {73C32D0F-64DB-4674-84E9-8FCC41228474}.Debug|ARM64.ActiveCfg = Debug|ARM64
+ {73C32D0F-64DB-4674-84E9-8FCC41228474}.Debug|ARM64.Build.0 = Debug|ARM64
+ {73C32D0F-64DB-4674-84E9-8FCC41228474}.Debug|ARM64.Deploy.0 = Debug|ARM64
+ {73C32D0F-64DB-4674-84E9-8FCC41228474}.Debug|x64.ActiveCfg = Debug|x64
+ {73C32D0F-64DB-4674-84E9-8FCC41228474}.Debug|x64.Build.0 = Debug|x64
+ {73C32D0F-64DB-4674-84E9-8FCC41228474}.Debug|x64.Deploy.0 = Debug|x64
+ {73C32D0F-64DB-4674-84E9-8FCC41228474}.Release|ARM64.ActiveCfg = Release|ARM64
+ {73C32D0F-64DB-4674-84E9-8FCC41228474}.Release|ARM64.Build.0 = Release|ARM64
+ {73C32D0F-64DB-4674-84E9-8FCC41228474}.Release|ARM64.Deploy.0 = Release|ARM64
+ {73C32D0F-64DB-4674-84E9-8FCC41228474}.Release|x64.ActiveCfg = Release|x64
+ {73C32D0F-64DB-4674-84E9-8FCC41228474}.Release|x64.Build.0 = Release|x64
+ {73C32D0F-64DB-4674-84E9-8FCC41228474}.Release|x64.Deploy.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -469,6 +483,7 @@ Global
{9EA5AE9D-C39A-4F43-B03E-0A848EA2558A} = {0ED8F632-5E17-46BE-8CC3-B14A82D4AEB1}
{346AEB10-A4EA-427E-8578-F60915DB3053} = {F8EFBB27-4EE2-4463-A75B-7EFDFB55D0F7}
{4D4BB2F6-5653-4DB5-A8DD-90D58D8FE4D3} = {F8EFBB27-4EE2-4463-A75B-7EFDFB55D0F7}
+ {73C32D0F-64DB-4674-84E9-8FCC41228474} = {F8EFBB27-4EE2-4463-A75B-7EFDFB55D0F7}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4664C5E3-0340-4E22-BCFD-98AAEDF5F2DC}
@@ -490,6 +505,8 @@ Global
src\TerraFX.Interop.Windows.D2D1\TerraFX.Interop.Windows.D2D1.projitems*{4d7d9ba8-a821-4b1c-9ee2-cbcf5849906e}*SharedItemsImports = 5
src\TerraFX.Interop.Windows\TerraFX.Interop.Windows.projitems*{514ff00e-bbf0-4d55-a47c-eeeb6208adce}*SharedItemsImports = 13
src\ComputeSharp.SourceGeneration\ComputeSharp.SourceGeneration.projitems*{51d5a422-d3a5-4c4d-8a6d-a048940bf279}*SharedItemsImports = 13
+ samples\ComputeSharp.SwapChain.Shaders.D2D1.Shared\ComputeSharp.SwapChain.Shaders.D2D1.Shared.projitems*{73c32d0f-64db-4674-84e9-8fcc41228474}*SharedItemsImports = 5
+ tests\ComputeSharp.D2D1.UI.Tests\ComputeSharp.D2D1.UI.Tests.projitems*{73c32d0f-64db-4674-84e9-8fcc41228474}*SharedItemsImports = 5
samples\ComputeSharp.SwapChain.Core.Shared\ComputeSharp.SwapChain.Core.Shared.projitems*{751bb05b-563d-4b3a-94c6-15e2d79d35ea}*SharedItemsImports = 13
src\ComputeSharp.NetStandard\ComputeSharp.NetStandard.projitems*{764bc0f5-0c5e-49ad-abaa-e3874c0f3286}*SharedItemsImports = 5
src\TerraFX.Interop.Windows.Dynamic\TerraFX.Interop.Windows.Dynamic.projitems*{76c66257-fdaa-47ab-85e7-ef757eab10c0}*SharedItemsImports = 5
diff --git a/tests/ComputeSharp.D2D1.UI.Tests/CanvasEffectTests.cs b/tests/ComputeSharp.D2D1.UI.Tests/CanvasEffectTests.cs
index 21a57cb2..1f293ee2 100644
--- a/tests/ComputeSharp.D2D1.UI.Tests/CanvasEffectTests.cs
+++ b/tests/ComputeSharp.D2D1.UI.Tests/CanvasEffectTests.cs
@@ -1,4 +1,8 @@
+#if WINDOWS_UWP
using ComputeSharp.D2D1.Uwp;
+#else
+using ComputeSharp.D2D1.WinUI;
+#endif
using Microsoft.Graphics.Canvas;
using Microsoft.VisualStudio.TestTools.UnitTesting;
diff --git a/tests/ComputeSharp.D2D1.UI.Tests/Helpers/Win2DHelper.cs b/tests/ComputeSharp.D2D1.UI.Tests/Helpers/Win2DHelper.cs
index 653fbfbd..f26153fc 100644
--- a/tests/ComputeSharp.D2D1.UI.Tests/Helpers/Win2DHelper.cs
+++ b/tests/ComputeSharp.D2D1.UI.Tests/Helpers/Win2DHelper.cs
@@ -1,9 +1,15 @@
using System;
using System.Runtime.InteropServices;
+#if WINDOWS_UWP
using System.Runtime.InteropServices.WindowsRuntime;
+#endif
using Microsoft.Graphics.Canvas;
using TerraFX.Interop.DirectX;
using TerraFX.Interop.Windows;
+#if !WINDOWS_UWP
+using WinRT;
+using WinRT.Interop;
+#endif
#nullable enable
@@ -22,11 +28,17 @@ internal static class Win2DHelper
/// The resulting managed wrapper for .
public static unsafe object GetOrCreate(ID2D1Image* d2D1Image, CanvasDevice? canvasDevice = null)
{
- IActivationFactory activationFactory = WindowsRuntimeMarshal.GetActivationFactory(typeof(CanvasDevice));
-
using ComPtr activationFactoryUnknown = default;
+#if WINDOWS_UWP
+ IActivationFactory activationFactory = WindowsRuntimeMarshal.GetActivationFactory(typeof(CanvasDevice));
+
activationFactoryUnknown.Attach((IUnknown*)Marshal.GetIUnknownForObject(activationFactory));
+#else
+ ICanvasFactoryNative activationFactory = CanvasDevice.As();
+
+ activationFactoryUnknown.Attach((IUnknown*)MarshalInterface.FromManaged(activationFactory));
+#endif
using ComPtr canvasFactoryNativeUnknown = default;
@@ -41,7 +53,11 @@ internal static class Win2DHelper
if (canvasDevice is not null)
{
+#if WINDOWS_UWP
canvasDeviceUnknown.Attach((IUnknown*)Marshal.GetIUnknownForObject(canvasDevice));
+#else
+ canvasDeviceUnknown.Attach((IUnknown*)MarshalInspectable.FromManaged(canvasDevice));
+#endif
}
using ComPtr canvasDeviceInterfaceUnknown = default;
@@ -67,7 +83,11 @@ internal static class Win2DHelper
Marshal.ThrowExceptionForHR(hresult);
// Get or create a managed object for the native object
+#if WINDOWS_UWP
return Marshal.GetObjectForIUnknown((IntPtr)wrapperUnknown.Get());
+#else
+ return MarshalInspectable