Skip to content

Commit

Permalink
Apply source suppressions
Browse files Browse the repository at this point in the history
  • Loading branch information
jjonescz committed Feb 20, 2023
1 parent e34f9b1 commit 8ca43c1
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/Compilers/Core/Portable/SourceGeneration/GeneratorDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -372,14 +372,20 @@ private static GeneratorState SetGeneratorException(Compilation compilation, Com

private static ImmutableArray<Diagnostic> FilterDiagnostics(Compilation compilation, ImmutableArray<Diagnostic> generatorDiagnostics, DiagnosticBag? driverDiagnostics, CancellationToken cancellationToken)
{
if (driverDiagnostics is null && generatorDiagnostics.IsEmpty)
{
return generatorDiagnostics;
}

var suppressMessageState = new SuppressMessageAttributeState(compilation);
ArrayBuilder<Diagnostic> filteredDiagnostics = ArrayBuilder<Diagnostic>.GetInstance();
foreach (var diag in generatorDiagnostics)
{
var filtered = compilation.Options.FilterDiagnostic(diag, cancellationToken);
if (filtered is object)
if (compilation.Options.FilterDiagnostic(diag, cancellationToken) is { } filtered &&
suppressMessageState.ApplySourceSuppressions(filtered) is { } effective)
{
filteredDiagnostics.Add(filtered);
driverDiagnostics?.Add(filtered);
filteredDiagnostics.Add(effective);
driverDiagnostics?.Add(effective);
}
}
return filteredDiagnostics.ToImmutableAndFree();
Expand Down

0 comments on commit 8ca43c1

Please sign in to comment.