diff --git a/tests/ComputeSharp.Tests.SourceGenerators/DiagnosticsTests.cs b/tests/ComputeSharp.Tests.SourceGenerators/DiagnosticsTests.cs index f956aeea..0092a1ae 100644 --- a/tests/ComputeSharp.Tests.SourceGenerators/DiagnosticsTests.cs +++ b/tests/ComputeSharp.Tests.SourceGenerators/DiagnosticsTests.cs @@ -1399,6 +1399,76 @@ public class DiagnosticsTests VerifyGeneratedDiagnostics(source, "CMPS0047"); } + [TestMethod] + public void EmbeddedBytecodeWithDynamicShader() + { + string source = @" + using System; + using ComputeSharp; + + namespace ComputeSharp + { + public interface IComputeShader { } + public class ReadWriteBuffer { } + public class EmbeddedBytecodeAttribute : Attribute { } + } + + namespace MyFancyApp.Sample + { + [EmbeddedBytecode] + public struct MyShader : IComputeShader + { + public ReadWriteBuffer buffer; + public Action action; + + public void Execute() + { + } + } + }"; + + VerifyGeneratedDiagnostics(source, "CMPS0048"); + } + + [TestMethod] + [DataRow(-1, 1, 1)] + [DataRow(1, -1, 1)] + [DataRow(1, 1, -1)] + [DataRow(1050, 1, 1)] + [DataRow(1, 1050, 1)] + [DataRow(1, 1, 70)] + public void InvalidEmbeddedBytecodeThreadIds(int threadsX, int threadsY, int threadsZ) + { + string source = $@" + using System; + using ComputeSharp; + + namespace ComputeSharp + {{ + public interface IComputeShader {{ }} + public class ReadWriteBuffer {{ }} + public class EmbeddedBytecodeAttribute : Attribute + {{ + public EmbeddedBytecodeAttribute(int threadsX, int threadsY, int threadsZ) {{ }} + }} + }} + + namespace MyFancyApp.Sample + {{ + [EmbeddedBytecode({threadsX}, {threadsY}, {threadsZ})] + public struct MyShader : IComputeShader + {{ + public ReadWriteBuffer buffer; + + public void Execute() + {{ + }} + }} + }}"; + + VerifyGeneratedDiagnostics(source, "CMPS0049"); + } + /// /// Verifies the output of a source generator. ///