Added diagnostics for shader properties

このコミットが含まれているのは:
Sergio Pedri committed 2021-03-11 15:38:13 +01:00
1 親 e12169c11e
コミット 3147e8fade
4ファイル変更
+34 -32

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

+16
ファイルの表示
@@ -65,6 +65,9 @@ namespace ComputeSharp.SourceGenerators
// Only process compute shader types
if (!structDeclarationSymbol.Interfaces.Any(static interfaceSymbol => interfaceSymbol.Name == nameof(IComputeShader))) return;
// Properties are not supported
DetectAndReportPropertyDeclarations(context, structDeclarationSymbol);
// We need to sets to track all discovered custom types and static methods
HashSet<INamedTypeSymbol> discoveredTypes = new(SymbolEqualityComparer.Default);
Dictionary<IMethodSymbol, MethodDeclarationSyntax> staticMethods = new(SymbolEqualityComparer.Default);
@@ -405,6 +408,19 @@ namespace ComputeSharp.SourceGenerators
.ToFullString();
}
}
/// <summary>
/// Finds and reports all declared properties in a shader.
/// </summary>
/// <param name="context">The current generator context in use.</param>
/// <param name="structDeclarationSymbol">The input <see cref="INamedTypeSymbol"/> instance to process.</param>
private static void DetectAndReportPropertyDeclarations(GeneratorExecutionContext context, INamedTypeSymbol structDeclarationSymbol)
{
foreach (var propertySymbol in structDeclarationSymbol.GetMembers().OfType<IPropertySymbol>())
{
context.ReportDiagnostic(DiagnosticDescriptors.PropertyDeclaration, propertySymbol);
}
}
}
}