diff --git a/tests/ComputeSharp.D2D1.Tests.SourceGenerators/Test_Analyzers.cs b/tests/ComputeSharp.D2D1.Tests.SourceGenerators/Test_Analyzers.cs index c5744a83..3ba72361 100644 --- a/tests/ComputeSharp.D2D1.Tests.SourceGenerators/Test_Analyzers.cs +++ b/tests/ComputeSharp.D2D1.Tests.SourceGenerators/Test_Analyzers.cs @@ -196,4 +196,70 @@ public class Test_Analyzers await CSharpAnalyzerWithLanguageVersionTest.VerifyAnalyzerAsync(source); } + + [TestMethod] + public async Task ShaderWithNoPrecompiledBytecode_WithNoD2DEnableRuntimeCompilation_Warns() + { + const string source = """ + using ComputeSharp; + using ComputeSharp.D2D1; + + [D2DInputCount(0)] + [D2DGeneratedPixelShaderDescriptor] + internal partial struct {|CMPSD2D0076:MyType|} : ID2D1PixelShader + { + public Float4 Execute() + { + return 0; + } + } + """; + + await CSharpAnalyzerWithLanguageVersionTest.VerifyAnalyzerAsync(source); + } + + [TestMethod] + public async Task ShaderWithNoPrecompiledBytecode_WithD2DEnableRuntimeCompilation_OnType_DoesNotWarn() + { + const string source = """ + using ComputeSharp; + using ComputeSharp.D2D1; + + [D2DInputCount(0)] + [D2DGeneratedPixelShaderDescriptor] + [D2DEnableRuntimeCompilation] + internal partial struct MyType : ID2D1PixelShader + { + public Float4 Execute() + { + return 0; + } + } + """; + + await CSharpAnalyzerWithLanguageVersionTest.VerifyAnalyzerAsync(source); + } + + [TestMethod] + public async Task ShaderWithNoPrecompiledBytecode_WithD2DEnableRuntimeCompilation_OnAssembly_DoesNotWarn() + { + const string source = """ + using ComputeSharp; + using ComputeSharp.D2D1; + + [assembly: D2DEnableRuntimeCompilation] + + [D2DInputCount(0)] + [D2DGeneratedPixelShaderDescriptor] + internal partial struct MyType : ID2D1PixelShader + { + public Float4 Execute() + { + return 0; + } + } + """; + + await CSharpAnalyzerWithLanguageVersionTest.VerifyAnalyzerAsync(source); + } } \ No newline at end of file diff --git a/tests/ComputeSharp.D2D1.Tests.SourceGenerators/Test_D2DPixelShaderSourceGenerator.cs b/tests/ComputeSharp.D2D1.Tests.SourceGenerators/Test_D2DPixelShaderSourceGenerator.cs index 6d4a81c8..7877840c 100644 --- a/tests/ComputeSharp.D2D1.Tests.SourceGenerators/Test_D2DPixelShaderSourceGenerator.cs +++ b/tests/ComputeSharp.D2D1.Tests.SourceGenerators/Test_D2DPixelShaderSourceGenerator.cs @@ -30,6 +30,8 @@ public class Test_D2DPixelShaderSourceGenerator using float3 = global::ComputeSharp.Float3; using float4 = global::ComputeSharp.Float4; + [assembly: D2DEnableRuntimeCompilation] + namespace MyNamespace; [D2DInputCount(0)] @@ -679,6 +681,8 @@ public class Test_D2DPixelShaderSourceGenerator using float3 = global::ComputeSharp.Float3; using float4 = global::ComputeSharp.Float4; + [assembly: D2DEnableRuntimeCompilation] + namespace MyNamespace; [D2DEffectId("B30E1384-DEE1-4200-9312-321521DF3B00")] @@ -985,6 +989,8 @@ public class Test_D2DPixelShaderSourceGenerator using float3 = global::ComputeSharp.Float3; using float4 = global::ComputeSharp.Float4; + [assembly: D2DEnableRuntimeCompilation] + namespace MyNamespace; [D2DInputCount(0)] @@ -1280,6 +1286,8 @@ public class Test_D2DPixelShaderSourceGenerator using ComputeSharp.D2D1; using float4 = global::ComputeSharp.Float4; + [assembly: D2DEnableRuntimeCompilation] + namespace MyNamespace; [D2DInputCount(2)] @@ -1566,6 +1574,8 @@ public class Test_D2DPixelShaderSourceGenerator using int2 = global::ComputeSharp.Int2; using float4 = global::ComputeSharp.Float4; + [assembly: D2DEnableRuntimeCompilation] + namespace MyNamespace; [D2DInputCount(0)] @@ -1802,6 +1812,7 @@ public class Test_D2DPixelShaderSourceGenerator private static async Task VerifyGeneratedDiagnosticsAsync(string source, (string Filename, string Source) result) { // Also validate all analyzers + await CSharpAnalyzerWithLanguageVersionTest.VerifyAnalyzerAsync(source); await CSharpAnalyzerWithLanguageVersionTest.VerifyAnalyzerAsync(source); await CSharpAnalyzerWithLanguageVersionTest.VerifyAnalyzerAsync(source); await CSharpAnalyzerWithLanguageVersionTest.VerifyAnalyzerAsync(source);