Skip to content

Commit 3486723

Browse files
committed
Don't emit repeated diagnostics for same symbols
1 parent 408ac01 commit 3486723

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

CommunityToolkit.Mvvm.SourceGenerators/Diagnostics/Analyzers/UnsupportedCSharpLanguageVersionAnalyzer.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ public override void Initialize(AnalysisContext context)
8282
SymbolEqualityComparer.Default.Equals(attributeClass, attributeSymbol))
8383
{
8484
context.ReportDiagnostic(Diagnostic.Create(UnsupportedCSharpLanguageVersionError, context.Symbol.Locations.FirstOrDefault()));
85+
86+
// If we created a diagnostic for this symbol, we can stop. Even if there's multiple attributes, no need for repeated errors
87+
return;
8588
}
8689
}
8790
}, SymbolKind.Field, SymbolKind.NamedType, SymbolKind.Method);

0 commit comments

Comments
 (0)