From ca5b69fdcf43b28bf86ca12430b98540f3a54a8f Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Fri, 2 Sep 2022 14:56:27 +0200 Subject: [PATCH] Use ForAttributeWithMetadataName in AutoConstructorGenerator Fix comment --- .../AutoConstructorGenerator.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/ComputeSharp.Core.SourceGenerators/AutoConstructorGenerator.cs b/src/ComputeSharp.Core.SourceGenerators/AutoConstructorGenerator.cs index 81f28367..e39bebeb 100644 --- a/src/ComputeSharp.Core.SourceGenerators/AutoConstructorGenerator.cs +++ b/src/ComputeSharp.Core.SourceGenerators/AutoConstructorGenerator.cs @@ -23,11 +23,10 @@ public sealed class AutoConstructorGenerator : IIncrementalGenerator // Get all declared struct symbols with the [AutoConstructor] attribute IncrementalValuesProvider structDeclarations = context.SyntaxProvider - .CreateSyntaxProvider( + .ForAttributeWithMetadataName( + "ComputeSharp.AutoConstructorAttribute", static (node, token) => node is StructDeclarationSyntax structDeclaration, - static (context, token) => (INamedTypeSymbol?)context.SemanticModel.GetDeclaredSymbol(context.Node, token)) - .Where(static symbol => symbol is not null && - symbol.GetAttributes().Any(static a => a.AttributeClass?.ToDisplayString() == typeof(AutoConstructorAttribute).FullName))!; + static (context, token) => (INamedTypeSymbol)context.TargetSymbol); // Get the type hierarchy and fields info IncrementalValuesProvider<(HierarchyInfo Left, ConstructorInfo Right)> constructorInfo =