From 50d6f211d33bba7df2c8bd3ffdd899a2aeb89113 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Wed, 6 Dec 2023 03:04:28 +0100 Subject: [PATCH] Remove unnecessary symbol in [GroupShared] analyzer --- .../InvalidGroupSharedFieldDeclarationAnalyzer.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/ComputeSharp.SourceGenerators/Diagnostics/Analyzers/InvalidGroupSharedFieldDeclarationAnalyzer.cs b/src/ComputeSharp.SourceGenerators/Diagnostics/Analyzers/InvalidGroupSharedFieldDeclarationAnalyzer.cs index 571ea8d3..c9f1faeb 100644 --- a/src/ComputeSharp.SourceGenerators/Diagnostics/Analyzers/InvalidGroupSharedFieldDeclarationAnalyzer.cs +++ b/src/ComputeSharp.SourceGenerators/Diagnostics/Analyzers/InvalidGroupSharedFieldDeclarationAnalyzer.cs @@ -23,10 +23,9 @@ public sealed class InvalidGroupSharedFieldDeclarationAnalyzer : DiagnosticAnaly context.RegisterCompilationStartAction(static context => { - // Get the IComputeShader, IComputeShader, ReadWriteBuffer and [GloballyCoherent] symbols + // Get the IComputeShader, IComputeShader and [GloballyCoherent] symbols if (context.Compilation.GetTypeByMetadataName("ComputeSharp.IComputeShader") is not { } computeShaderSymbol || context.Compilation.GetTypeByMetadataName("ComputeSharp.IComputeShader`1") is not { } pixelShaderSymbol || - context.Compilation.GetTypeByMetadataName("ComputeSharp.ReadWriteBuffer`1") is not { } readWriteBufferSymbol || context.Compilation.GetTypeByMetadataName("ComputeSharp.GroupSharedAttribute") is not { } groupSharedAttribute) { return; @@ -45,9 +44,8 @@ public sealed class InvalidGroupSharedFieldDeclarationAnalyzer : DiagnosticAnaly return; } - // Emit a diagnostic if the field is not valid (either static, not of ReadWriteBuffer type, or not within a compute shader type) - if (!fieldSymbol.IsStatic || - fieldSymbol.Type is not IArrayTypeSymbol { ElementType.IsUnmanagedType: true } || + // Emit a diagnostic if the field is not valid (it must be static, of an array type with an unmanaged element type, and within a compute shader type) + if (fieldSymbol is not { IsStatic: true, Type: IArrayTypeSymbol { ElementType.IsUnmanagedType: true } } || !MissingComputeShaderDescriptorOnComputeShaderAnalyzer.IsComputeShaderType(typeSymbol, computeShaderSymbol, pixelShaderSymbol)) { context.ReportDiagnostic(Diagnostic.Create(