internal virtual async Task <ImmutableDictionary <Document, ImmutableArray <Diagnostic> > > GetDocumentDiagnosticsToFixWorkerAsync( FixAllContext fixAllContext) { using (Logger.LogBlock( FunctionId.CodeFixes_FixAllOccurrencesComputation_Document_Diagnostics, FixAllLogger.CreateCorrelationLogMessage(fixAllContext.State.CorrelationId), fixAllContext.CancellationToken)) { return(await FixAllContextHelper.GetDocumentDiagnosticsToFixAsync( fixAllContext, fixAllContext.ProgressTracker, (document, cancellationToken) => document.IsGeneratedCode(cancellationToken)).ConfigureAwait(false)); } }
internal virtual async Task <ImmutableDictionary <Project, ImmutableArray <Diagnostic> > > GetProjectDiagnosticsToFixAsync( FixAllContext fixAllContext) { using (Logger.LogBlock( FunctionId.CodeFixes_FixAllOccurrencesComputation_Project_Diagnostics, FixAllLogger.CreateCorrelationLogMessage(fixAllContext.State.CorrelationId), fixAllContext.CancellationToken)) { var project = fixAllContext.Project; if (project != null) { switch (fixAllContext.Scope) { case FixAllScope.Project: var diagnostics = await fixAllContext.GetProjectDiagnosticsAsync(project).ConfigureAwait(false); var kvp = SpecializedCollections.SingletonEnumerable(KeyValuePairUtil.Create(project, diagnostics)); return(ImmutableDictionary.CreateRange(kvp)); case FixAllScope.Solution: var projectsAndDiagnostics = ImmutableDictionary.CreateBuilder <Project, ImmutableArray <Diagnostic> >(); var tasks = project.Solution.Projects.Select(async p => new { Project = p, Diagnostics = await fixAllContext.GetProjectDiagnosticsAsync(p).ConfigureAwait(false) }).ToArray(); await Task.WhenAll(tasks).ConfigureAwait(false); foreach (var task in tasks) { var projectAndDiagnostics = await task.ConfigureAwait(false); if (projectAndDiagnostics.Diagnostics.Any()) { projectsAndDiagnostics[projectAndDiagnostics.Project] = projectAndDiagnostics.Diagnostics; } } return(projectsAndDiagnostics.ToImmutable()); } } return(ImmutableDictionary <Project, ImmutableArray <Diagnostic> > .Empty); } }