diff --git a/tests/ComputeSharp.D2D1.Tests.SourceGenerators/ComputeSharp.D2D1.Tests.SourceGenerators.csproj b/tests/ComputeSharp.D2D1.Tests.SourceGenerators/ComputeSharp.D2D1.Tests.SourceGenerators.csproj
index 4bec77f9..2b3a0b74 100644
--- a/tests/ComputeSharp.D2D1.Tests.SourceGenerators/ComputeSharp.D2D1.Tests.SourceGenerators.csproj
+++ b/tests/ComputeSharp.D2D1.Tests.SourceGenerators/ComputeSharp.D2D1.Tests.SourceGenerators.csproj
@@ -5,6 +5,7 @@
https://api.nuget.org/v3/index.json;
https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json;
+ $(DefineConstants);D2D1_TESTS
@@ -23,4 +24,8 @@
+
+
+
+
diff --git a/tests/ComputeSharp.D2D1.Tests.SourceGenerators/Test_InvalidD2D1CompileOptionsEnableLinkingOnShaderTypeAnalyzer.cs b/tests/ComputeSharp.D2D1.Tests.SourceGenerators/Test_InvalidD2D1CompileOptionsEnableLinkingOnShaderTypeAnalyzer.cs
new file mode 100644
index 00000000..6cd4b336
--- /dev/null
+++ b/tests/ComputeSharp.D2D1.Tests.SourceGenerators/Test_InvalidD2D1CompileOptionsEnableLinkingOnShaderTypeAnalyzer.cs
@@ -0,0 +1,117 @@
+using System.Threading.Tasks;
+using ComputeSharp.D2D1.SourceGenerators;
+using ComputeSharp.Tests.SourceGenerators.Helpers;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace ComputeSharp.D2D1.Tests.SourceGenerators;
+
+[TestClass]
+public class Test_InvalidD2D1CompileOptionsEnableLinkingOnShaderTypeAnalyzer
+{
+ [TestMethod]
+ public async Task NoCompileOptionsDoesNotWarn()
+ {
+ const string source = """
+ using ComputeSharp;
+ using ComputeSharp.D2D1;
+
+ public partial class Foo
+ {
+ [D2DInputCount(0)]
+ private partial struct MyShader : ID2D1PixelShader
+ {
+ public Float4 Execute() => 0;
+ }
+ }
+ """;
+
+ await CSharpAnalyzerWithLanguageVersionTest.VerifyAnalyzerAsync(source);
+ }
+
+ [TestMethod]
+ public async Task ValidCompileOptionsDoesNotWarn()
+ {
+ const string source = """
+ using ComputeSharp;
+ using ComputeSharp.D2D1;
+
+ public partial class Foo
+ {
+ [D2DInputCount(0)]
+ [D2DCompileOptions(D2D1CompileOptions.PackMatrixRowMajor)]
+ private partial struct MyShader : ID2D1PixelShader
+ {
+ public Float4 Execute() => 0;
+ }
+ }
+ """;
+
+ await CSharpAnalyzerWithLanguageVersionTest.VerifyAnalyzerAsync(source);
+ }
+
+ [TestMethod]
+ public async Task EnableLinkingWithNoInputCountDoesNotWarn()
+ {
+ const string source = """
+ using ComputeSharp;
+ using ComputeSharp.D2D1;
+
+ public partial class Foo
+ {
+ [D2DInputComplex(0)]
+ [D2DCompileOptions(D2D1CompileOptions.EnableLinking)]
+ private partial struct MyShader : ID2D1PixelShader
+ {
+ public Float4 Execute() => 0;
+ }
+ }
+ """;
+
+ await CSharpAnalyzerWithLanguageVersionTest.VerifyAnalyzerAsync(source);
+ }
+
+ [TestMethod]
+ public async Task EnableLinkingWithImplicitComplexInputWarns()
+ {
+ const string source = """
+ using ComputeSharp;
+ using ComputeSharp.D2D1;
+
+ public partial class Foo
+ {
+ [D2DInputCount(2)]
+ [D2DInputSimple(1)]
+ [{|CMPSD2D0069:D2DCompileOptions(D2D1CompileOptions.Default | D2D1CompileOptions.EnableLinking)|}]
+ private partial struct MyShader : ID2D1PixelShader
+ {
+ public Float4 Execute() => 0;
+ }
+ }
+ """;
+
+ await CSharpAnalyzerWithLanguageVersionTest.VerifyAnalyzerAsync(source);
+ }
+
+ [TestMethod]
+ public async Task EnableLinkingWithExplicitComplexInputWarns()
+ {
+ const string source = """
+ using ComputeSharp;
+ using ComputeSharp.D2D1;
+
+ public partial class Foo
+ {
+ [D2DInputCount(2)]
+ [D2DInputSimple(0)]
+ [D2DInputComplex(1)]
+ [{|CMPSD2D0069:D2DCompileOptions(D2D1CompileOptions.Default | D2D1CompileOptions.EnableLinking)|}]
+ private partial struct MyShader : ID2D1PixelShader
+ {
+ public Float4 Execute() => 0;
+ }
+ }
+ """;
+
+ await CSharpAnalyzerWithLanguageVersionTest.VerifyAnalyzerAsync(source);
+ }
+}
\ No newline at end of file
diff --git a/tests/ComputeSharp.Tests.SourceGenerators/Helpers/CSharpAnalyzerWithLanguageVersionTest{TAnalyzer}.cs b/tests/ComputeSharp.Tests.SourceGenerators/Helpers/CSharpAnalyzerWithLanguageVersionTest{TAnalyzer}.cs
index 44e3afb6..a19d3799 100644
--- a/tests/ComputeSharp.Tests.SourceGenerators/Helpers/CSharpAnalyzerWithLanguageVersionTest{TAnalyzer}.cs
+++ b/tests/ComputeSharp.Tests.SourceGenerators/Helpers/CSharpAnalyzerWithLanguageVersionTest{TAnalyzer}.cs
@@ -1,5 +1,9 @@
extern alias Core;
+#if D2D1_TESTS
+extern alias D2D1;
+#else
extern alias D3D12;
+#endif
using System.Threading;
using System.Threading.Tasks;
@@ -48,7 +52,11 @@ internal sealed class CSharpAnalyzerWithLanguageVersionTest : CSharpA
test.TestState.ReferenceAssemblies = ReferenceAssemblies.Net.Net80;
test.TestState.AdditionalReferences.Add(MetadataReference.CreateFromFile(typeof(Core::ComputeSharp.Hlsl).Assembly.Location));
+#if D2D1_TESTS
+ test.TestState.AdditionalReferences.Add(MetadataReference.CreateFromFile(typeof(D2D1::ComputeSharp.D2D1.ID2D1PixelShader).Assembly.Location));
+#else
test.TestState.AdditionalReferences.Add(MetadataReference.CreateFromFile(typeof(D3D12::ComputeSharp.IComputeShader).Assembly.Location));
+#endif
return test.RunAsync(CancellationToken.None);
}