Skip to content

Commit

Permalink
Making it a little bit more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
Colin Wilmans committed Aug 7, 2024
1 parent 61bcacb commit 18fc53f
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Immutable;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;

namespace AutomaticInterface;

Expand All @@ -18,10 +19,9 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
var classes = context
.SyntaxProvider.ForAttributeWithMetadataName(
$"AutomaticInterface.{DefaultAttributeName}Attribute",
(_, _) => true,
(node, _) => node is ClassDeclarationSyntax,
(context, _) => (ITypeSymbol)context.TargetSymbol
)
.Where(type => type is not null)
.Collect();

context.RegisterSourceOutput(classes, GenerateCode);
Expand Down

0 comments on commit 18fc53f

Please sign in to comment.