public async override Task RegisterCodeFixesAsync(CodeFixContext context) { var diagnostics = context.Diagnostics.WhereAsArray(_suppressionFixProvider.CanBeSuppressed); var suppressionFixes = await _suppressionFixProvider.GetSuppressionsAsync(context.Document, context.Span, diagnostics, context.CancellationToken).ConfigureAwait(false); if (suppressionFixes != null) { foreach (var suppressionFix in suppressionFixes) { context.RegisterCodeFix(suppressionFix.Action, suppressionFix.Diagnostics); } } }
public async override Task RegisterCodeFixesAsync(CodeFixContext context) { var diagnostics = context.Diagnostics.Where(_suppressionFixProvider.CanBeSuppressedOrUnsuppressed); var documentDiagnostics = diagnostics.Where(d => d.Location.IsInSource).ToImmutableArray(); if (!documentDiagnostics.IsEmpty) { var suppressionFixes = await _suppressionFixProvider.GetSuppressionsAsync(context.Document, context.Span, diagnostics, context.CancellationToken).ConfigureAwait(false); RegisterSuppressionFixes(context, suppressionFixes); } var projectDiagnostics = diagnostics.Where(d => !d.Location.IsInSource).ToImmutableArray(); if (!projectDiagnostics.IsEmpty) { var suppressionFixes = await _suppressionFixProvider.GetSuppressionsAsync(context.Project, diagnostics, context.CancellationToken).ConfigureAwait(false); RegisterSuppressionFixes(context, suppressionFixes); } }