File tree 1 file changed +5
-22
lines changed
sdk/eventgrid/Azure.Messaging.EventGrid/EventGridSourceGenerator/src
1 file changed +5
-22
lines changed Original file line number Diff line number Diff line change @@ -37,28 +37,11 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
37
37
transform : static ( ctx , cancellationToken ) =>
38
38
{
39
39
var semanticModel = ctx . SemanticModel ;
40
- var classDecl = ( ClassDeclarationSyntax ) ctx . Node ;
41
-
42
- // Get the symbol for the class declaration
43
- var symbol = semanticModel . GetDeclaredSymbol ( classDecl , cancellationToken ) ;
44
- if ( symbol == null )
45
- {
46
- return null ;
47
- }
48
-
49
- // Check if the symbol is in the SystemEvents namespace
50
- var containingNamespace = symbol . ContainingNamespace ;
51
- while ( containingNamespace != null )
52
- {
53
- if ( containingNamespace . Name == "SystemEvents" )
54
- {
55
- return classDecl ;
56
- }
57
- containingNamespace = containingNamespace . ContainingNamespace ;
58
- }
59
-
60
- // Not in the SystemEvents namespace
61
- return null ;
40
+ var classDeclaration = ( ClassDeclarationSyntax ) ctx . Node ;
41
+
42
+ var declaredSymbol = semanticModel . GetDeclaredSymbol ( classDeclaration , cancellationToken ) ;
43
+
44
+ return declaredSymbol ? . ContainingNamespace is { Name : "SystemEvents" } ? classDeclaration : null ;
62
45
} )
63
46
. Where ( static cls => cls != null ) ;
64
47
You can’t perform that action at this time.
0 commit comments