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

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

@@ -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))
{