From 17527764b914d3985887f99fcc6c08bb354820e7 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Thu, 19 Oct 2023 14:01:03 +0200 Subject: [PATCH] Add unit test for new analyzer --- .../AnalyzerTests.cs | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/tests/ComputeSharp.Tests.SourceGenerators/AnalyzerTests.cs b/tests/ComputeSharp.Tests.SourceGenerators/AnalyzerTests.cs index 6861d648..ec84415e 100644 --- a/tests/ComputeSharp.Tests.SourceGenerators/AnalyzerTests.cs +++ b/tests/ComputeSharp.Tests.SourceGenerators/AnalyzerTests.cs @@ -10,7 +10,7 @@ namespace ComputeSharp.Tests.SourceGenerators; public class AnalyzerTests { [TestMethod] - public async Task InvalidShaderField() + public async Task NotAccessibleNestedShaderType() { const string source = """ using ComputeSharp; @@ -33,4 +33,35 @@ public class AnalyzerTests await CSharpAnalyzerWithLanguageVersionTest.VerifyAnalyzerAsync(source); } + + [TestMethod] + public async Task NotAccessibleShaderFieldType() + { + const string source = """ + using ComputeSharp; + + namespace MyFancyApp.Sample; + + public partial class Foo + { + [{|CMPS0056:GeneratedComputeShaderDescriptor|}] + private partial struct MyShader : IComputeShader + { + public ReadWriteBuffer buffer; + public Bar bar; + + public void Execute() + { + } + } + + private struct Bar + { + public int X; + } + } + """; + + await CSharpAnalyzerWithLanguageVersionTest.VerifyAnalyzerAsync(source); + } } \ No newline at end of file