Add InvalidGroupSharedFieldDeclarationAnalyzer

Also move the diagnostics there from the source generator
このコミットが含まれているのは:
Sergio Pedri committed 2023-11-24 11:51:17 +01:00
1 親 73f30af5eb
コミット a6c4b05e43
7ファイル変更
+156 -102

検索条件に一致するファイルはありません

-67
ファイルの表示
@@ -58,73 +58,6 @@ public class DiagnosticsTests
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0001", "CMPS0047");
}
[TestMethod]
public void InvalidGroupSharedFieldType()
{
const string source = """
using ComputeSharp;
namespace MyFancyApp.Sample;
[GeneratedComputeShaderDescriptor]
public partial struct MyShader : IComputeShader
{
public ReadWriteBuffer<float> buffer;
[GroupShared]
public static string text;
public void Execute() { }
}
""";
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0002", "CMPS0047");
}
[TestMethod]
public void InvalidGroupSharedFieldElementType()
{
const string source = """
using ComputeSharp;
namespace MyFancyApp.Sample;
[GeneratedComputeShaderDescriptor]
public partial struct MyShader : IComputeShader
{
public ReadWriteBuffer<float> buffer;
[GroupShared]
public static string[] text;
public void Execute() { }
}
""";
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0003", "CMPS0047");
}
[TestMethod]
public void InvalidGroupSharedFieldDeclaration()
{
const string source = """
using ComputeSharp;
namespace MyFancyApp.Sample;
[GeneratedComputeShaderDescriptor]
public partial struct MyShader : IComputeShader
{
[GroupShared]
public ReadWriteBuffer<float> buffer;
public void Execute() { }
}
""";
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0004", "CMPS0047");
}
[TestMethod]
public void MissingShaderResources()
{
+84
ファイルの表示
@@ -169,4 +169,88 @@ public class Test_Analyzers
await CSharpAnalyzerWithLanguageVersionTest<InvalidGloballyCoherentFieldDeclarationAnalyzer>.VerifyAnalyzerAsync(source);
}
[TestMethod]
public async Task GroupSharedAttribute_NotWithinShaderType()
{
const string source = """
using ComputeSharp;
namespace MyFancyApp.Sample;
internal partial struct MyType
{
[{|CMPS0004:GroupShared|}]
public static int[] numbers;
}
""";
await CSharpAnalyzerWithLanguageVersionTest<InvalidGroupSharedFieldDeclarationAnalyzer>.VerifyAnalyzerAsync(source);
}
[TestMethod]
public async Task GroupSharedAttribute_IncorrectType()
{
const string source = """
using ComputeSharp;
namespace MyFancyApp.Sample;
internal partial struct MyType : IComputeShader
{
[{|CMPS0004:GroupShared|}]
public static ReadWriteBuffer<int> numbers;
public void Execute()
{
}
}
""";
await CSharpAnalyzerWithLanguageVersionTest<InvalidGroupSharedFieldDeclarationAnalyzer>.VerifyAnalyzerAsync(source);
}
[TestMethod]
public async Task GroupSharedAttribute_InstanceField()
{
const string source = """
using ComputeSharp;
namespace MyFancyApp.Sample;
internal partial struct MyType : IComputeShader
{
[{|CMPS0004:GroupShared|}]
public int[] numbers;
public void Execute()
{
}
}
""";
await CSharpAnalyzerWithLanguageVersionTest<InvalidGroupSharedFieldDeclarationAnalyzer>.VerifyAnalyzerAsync(source);
}
[TestMethod]
public async Task GroupSharedAttribute_ValidField_DoesNotWarn()
{
const string source = """
using ComputeSharp;
namespace MyFancyApp.Sample;
internal partial struct MyType : IComputeShader
{
[GroupShared]
public static int[] numbers;
public void Execute()
{
}
}
""";
await CSharpAnalyzerWithLanguageVersionTest<InvalidGroupSharedFieldDeclarationAnalyzer>.VerifyAnalyzerAsync(source);
}
}
+1
ファイルの表示
@@ -896,6 +896,7 @@ public class Test_D2DPixelShaderSourceGenerator
await CSharpAnalyzerWithLanguageVersionTest<InvalidComputeContextCopyAnalyzer>.VerifyAnalyzerAsync(source);
await CSharpAnalyzerWithLanguageVersionTest<InvalidGeneratedComputeShaderDescriptorAttributeTargetAnalyzer>.VerifyAnalyzerAsync(source);
await CSharpAnalyzerWithLanguageVersionTest<InvalidGloballyCoherentFieldDeclarationAnalyzer>.VerifyAnalyzerAsync(source);
await CSharpAnalyzerWithLanguageVersionTest<InvalidGroupSharedFieldDeclarationAnalyzer>.VerifyAnalyzerAsync(source);
await CSharpAnalyzerWithLanguageVersionTest<MissingAllowUnsafeBlocksCompilationOptionAnalyzer>.VerifyAnalyzerAsync(source);
await CSharpAnalyzerWithLanguageVersionTest<MissingComputeShaderDescriptorOnComputeShaderAnalyzer>.VerifyAnalyzerAsync(source);
await CSharpAnalyzerWithLanguageVersionTest<NotAccessibleFieldTypeInGeneratedShaderDescriptorAttributeTargetAnalyzer>.VerifyAnalyzerAsync(source);