private async Task <CodeAction?> GetFixAsync( ImmutableDictionary <Document, ImmutableArray <Diagnostic> > documentsAndDiagnosticsToFixMap, FixAllContext fixAllContext) { var cancellationToken = fixAllContext.CancellationToken; if (documentsAndDiagnosticsToFixMap?.Any() == true) { var progressTracker = fixAllContext.GetProgressTracker(); progressTracker.Description = fixAllContext.GetDefaultFixAllTitle(); var fixAllState = fixAllContext.State; FixAllLogger.LogDiagnosticsStats(fixAllState.CorrelationId, documentsAndDiagnosticsToFixMap); var diagnosticsAndCodeActions = await GetDiagnosticsAndCodeActionsAsync(documentsAndDiagnosticsToFixMap, fixAllContext).ConfigureAwait(false); if (diagnosticsAndCodeActions.Length > 0) { var functionId = FunctionId.CodeFixes_FixAllOccurrencesComputation_Document_Merge; using (Logger.LogBlock(functionId, FixAllLogger.CreateCorrelationLogMessage(fixAllState.CorrelationId), cancellationToken)) { FixAllLogger.LogFixesToMergeStats(functionId, fixAllState.CorrelationId, diagnosticsAndCodeActions.Length); return(await TryGetMergedFixAsync( diagnosticsAndCodeActions, fixAllState, cancellationToken).ConfigureAwait(false)); } } } return(null); }
public override async Task <CodeAction?> GetFixAsync(FixAllContext fixAllContext) { var diagnostics = fixAllContext.Scope switch { FixAllScope.Document when fixAllContext.Document is not null => await fixAllContext.GetDocumentDiagnosticsAsync(fixAllContext.Document).ConfigureAwait(false), FixAllScope.Project => await fixAllContext.GetAllDiagnosticsAsync(fixAllContext.Project).ConfigureAwait(false), FixAllScope.Solution => await GetSolutionDiagnosticsAsync(fixAllContext).ConfigureAwait(false), _ => default }; if (diagnostics.IsDefaultOrEmpty) { return(null); } var title = fixAllContext.GetDefaultFixAllTitle(); return(CodeAction.Create( title, cancellationToken => FixAllByDocumentAsync( fixAllContext.Project.Solution, diagnostics, fixAllContext.GetProgressTracker(), #if CODE_STYLE CodeActionOptions.DefaultProvider, #else fixAllContext.State.CodeActionOptionsProvider, #endif cancellationToken), title));