Move MultipleShaderTypesImplemented to analyzer

このコミットが含まれているのは:
Sergio Pedri committed 2023-11-29 23:17:33 +01:00
1 親 7a630204ef
コミット 86bc68e4dd
4ファイル変更
+24 -26

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

-6
ファイルの表示
@@ -58,12 +58,6 @@ partial class ComputeShaderDescriptorGenerator
Dictionary<IMethodSymbol, MethodDeclarationSyntax> instanceMethods = new(SymbolEqualityComparer.Default);
Dictionary<IFieldSymbol, string> constantDefinitions = new(SymbolEqualityComparer.Default);
// A given type can only represent a single shader type
if (structDeclarationSymbol.AllInterfaces.Count(static interfaceSymbol => interfaceSymbol is { Name: nameof(IComputeShader) } or { IsGenericType: true, Name: nameof(IComputeShader<byte>) }) > 1)
{
diagnostics.Add(MultipleShaderTypesImplemented, structDeclarationSymbol, structDeclarationSymbol);
}
// Explore the syntax tree and extract the processed info
SemanticModelProvider semanticModelProvider = new(compilation);
INamedTypeSymbol? pixelShaderSymbol = structDeclarationSymbol.AllInterfaces.FirstOrDefault(static interfaceSymbol => interfaceSymbol is { IsGenericType: true, Name: nameof(IComputeShader<byte>) });
-20
ファイルの表示
@@ -1116,26 +1116,6 @@ public class DiagnosticsTests
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0041", "CMPS0047");
}
[TestMethod]
public void MultipleShaderTypes()
{
const string source = """
using ComputeSharp;
namespace MyFancyApp.Sample;
[GeneratedComputeShaderDescriptor]
public partial struct MyShader : IComputeShader, IComputeShader<float4>
{
public void Execute()
{
}
}
""";
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0042", "CMPS0047");
}
[TestMethod]
[DataRow(-1, 1, 1)]
[DataRow(1, -1, 1)]
+23
ファイルの表示
@@ -391,4 +391,27 @@ public class Test_Analyzers
await CSharpAnalyzerWithLanguageVersionTest<InvalidGeneratedComputeShaderDescriptorAttributeTargetAnalyzer>.VerifyAnalyzerAsync(source);
}
[TestMethod]
public async Task MultipleComputeShaderInterfacesOnShader_TwoInterfaces()
{
const string source = """
using ComputeSharp;
[GeneratedComputeShaderDescriptor]
internal partial struct {|CMPS0042:MyType|} : IComputeShader, IComputeShader<Float4>
{
public void Execute()
{
}
Float4 IComputeShader<Float4>.Execute()
{
return 0;
}
}
""";
await CSharpAnalyzerWithLanguageVersionTest<MultipleComputeShaderInterfacesOnShaderTypeAnalyzer>.VerifyAnalyzerAsync(source);
}
}
+1
ファイルの表示
@@ -899,6 +899,7 @@ public class Test_D2DPixelShaderSourceGenerator
await CSharpAnalyzerWithLanguageVersionTest<InvalidGroupSharedFieldDeclarationAnalyzer>.VerifyAnalyzerAsync(source);
await CSharpAnalyzerWithLanguageVersionTest<MissingAllowUnsafeBlocksCompilationOptionAnalyzer>.VerifyAnalyzerAsync(source);
await CSharpAnalyzerWithLanguageVersionTest<MissingComputeShaderDescriptorOnComputeShaderAnalyzer>.VerifyAnalyzerAsync(source);
await CSharpAnalyzerWithLanguageVersionTest<MultipleComputeShaderInterfacesOnShaderTypeAnalyzer>.VerifyAnalyzerAsync(source);
await CSharpAnalyzerWithLanguageVersionTest<NotAccessibleFieldTypeInGeneratedShaderDescriptorAttributeTargetAnalyzer>.VerifyAnalyzerAsync(source);
await CSharpAnalyzerWithLanguageVersionTest<NotAccessibleGeneratedComputeShaderDescriptorAttributeTargetAnalyzer>.VerifyAnalyzerAsync(source);
await CSharpAnalyzerWithLanguageVersionTest<NotReadOnlyComputeShaderTypeWithFieldsAnalyzer>.VerifyAnalyzerAsync(source);