Skip warnings for shader types with no fields

このコミットが含まれているのは:
Sergio Pedri committed 2023-11-24 00:32:27 +01:00
1 親 709197ee43
コミット 43b79bdf4b
9ファイル変更
+46 -16

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

+1 -1
ファイルの表示
@@ -10,7 +10,7 @@
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)Diagnostics\Analyzers\NotAccessibleFieldTypeInGeneratedShaderDescriptorAttributeTargetAnalyzerBase.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Diagnostics\Analyzers\NotReadonlyShaderTypeAnalyzerBase.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Diagnostics\Analyzers\NotReadOnlyShaderTypeWithFieldsAnalyzerBase.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Diagnostics\Analyzers\NotAccessibleGeneratedShaderDescriptorAttributeTargetAnalyzerBase.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Diagnostics\Analyzers\MissingAllowUnsafeBlocksCompilationOptionAnalyzerBase.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Diagnostics\DiagnosticDescriptors.cs" />
@@ -11,7 +11,7 @@ namespace ComputeSharp.SourceGeneration.Diagnostics;
/// </summary>
/// <param name="diagnosticDescriptor">The <see cref="DiagnosticDescriptor"/> instance to use.</param>
/// <param name="shaderInterfaceTypeFullyQualifiedMetadataNames">The fully qualified metadata names of all candidate shader interface types.</param>
public abstract class NotReadonlyShaderTypeAnalyzerBase(
public abstract class NotReadOnlyShaderTypeWithFieldsAnalyzerBase(
DiagnosticDescriptor diagnosticDescriptor,
ImmutableArray<string> shaderInterfaceTypeFullyQualifiedMetadataNames) : DiagnosticAnalyzer
{
@@ -40,6 +40,13 @@ public abstract class NotReadonlyShaderTypeAnalyzerBase(
return;
}
// In order to trigger the analyzer, we must have at least one field.
// If not (eg. shaders that just return a constant color), no need.
if (!typeSymbol.GetMembers().Any(static m => m is IFieldSymbol { IsStatic: false, IsConst: false, IsFixedSizeBuffer: false }))
{
return;
}
// Emit a diagnostic if the type is a shader type
if (IsShaderType(typeSymbol, typeSymbols))
{