Beispiel #1
0
        internal override async Task <CodeAction> GetFixAsync(
            ImmutableDictionary <Project, ImmutableArray <Diagnostic> > projectsAndDiagnosticsToFixMap,
            FixAllState fixAllState, CancellationToken cancellationToken)
        {
            if (projectsAndDiagnosticsToFixMap != null && projectsAndDiagnosticsToFixMap.Any())
            {
                FixAllLogger.LogDiagnosticsStats(projectsAndDiagnosticsToFixMap);

                var fixesBag = new ConcurrentBag <CodeAction>();

                using (Logger.LogBlock(FunctionId.CodeFixes_FixAllOccurrencesComputation_Fixes, cancellationToken))
                {
                    var projects = projectsAndDiagnosticsToFixMap.Keys;
                    var tasks    = projects.Select(p => AddProjectFixesAsync(p, projectsAndDiagnosticsToFixMap[p], fixesBag.Add, fixAllState, cancellationToken))
                                   .ToArray();
                    await Task.WhenAll(tasks).ConfigureAwait(false);
                }

                if (fixesBag.Any())
                {
                    using (Logger.LogBlock(FunctionId.CodeFixes_FixAllOccurrencesComputation_Merge, cancellationToken))
                    {
                        FixAllLogger.LogFixesToMergeStats(fixesBag);
                        return(await TryGetMergedFixAsync(fixesBag, fixAllState, cancellationToken).ConfigureAwait(false));
                    }
                }
            }

            return(null);
        }
Beispiel #2
0
        internal override async Task <CodeAction> GetFixAsync(
            ImmutableDictionary <Document, ImmutableArray <Diagnostic> > documentsAndDiagnosticsToFixMap,
            FixAllState fixAllState, CancellationToken cancellationToken)
        {
            if (documentsAndDiagnosticsToFixMap != null && documentsAndDiagnosticsToFixMap.Any())
            {
                FixAllLogger.LogDiagnosticsStats(documentsAndDiagnosticsToFixMap);

                var fixesBag = new ConcurrentBag <(Diagnostic diagnostic, CodeAction action)>();

                using (Logger.LogBlock(FunctionId.CodeFixes_FixAllOccurrencesComputation_Fixes, cancellationToken))
                {
                    cancellationToken.ThrowIfCancellationRequested();

                    var documents = documentsAndDiagnosticsToFixMap.Keys;
                    var tasks     = documents.Select(d => AddDocumentFixesAsync(
                                                         d, documentsAndDiagnosticsToFixMap[d], fixesBag, fixAllState, cancellationToken)).ToArray();
                    await Task.WhenAll(tasks).ConfigureAwait(false);
                }

                if (fixesBag.Count > 0)
                {
                    using (Logger.LogBlock(FunctionId.CodeFixes_FixAllOccurrencesComputation_Merge, cancellationToken))
                    {
                        FixAllLogger.LogFixesToMergeStats(fixesBag.Count);
                        return(await TryGetMergedFixAsync(
                                   fixesBag.ToImmutableArray(), fixAllState, cancellationToken).ConfigureAwait(false));
                    }
                }
            }

            return(null);
        }
                    > GetDocumentDiagnosticsToFixWorkerAsync(FixAllContext fixAllContext)
                {
                    if (
                        fixAllContext.State.DiagnosticProvider
                        is FixAllState.FixMultipleDiagnosticProvider fixMultipleDiagnosticProvider
                        )
                    {
                        return(fixMultipleDiagnosticProvider.DocumentDiagnosticsMap);
                    }

                    using (
                        Logger.LogBlock(
                            FunctionId.CodeFixes_FixAllOccurrencesComputation_Document_Diagnostics,
                            FixAllLogger.CreateCorrelationLogMessage(
                                fixAllContext.State.CorrelationId
                                ),
                            fixAllContext.CancellationToken
                            )
                        )
                    {
                        return(await FixAllContextHelper
                               .GetDocumentDiagnosticsToFixAsync(fixAllContext)
                               .ConfigureAwait(false));
                    }
                }
Beispiel #4
0
        private async Task <CodeAction> GetFixAsync(
            ImmutableDictionary <Document, ImmutableArray <Diagnostic> > documentsAndDiagnosticsToFixMap,
            FixAllState fixAllState, CancellationToken cancellationToken)
        {
            if (documentsAndDiagnosticsToFixMap?.Any() == true)
            {
                FixAllLogger.LogDiagnosticsStats(fixAllState.CorrelationId, documentsAndDiagnosticsToFixMap);

                var diagnosticsAndCodeActions = await GetDiagnosticsAndCodeActionsAsync(
                    documentsAndDiagnosticsToFixMap, fixAllState, cancellationToken).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 virtual async Task <CodeAction> GetFixAsync(
            ImmutableDictionary <Document, ImmutableArray <Diagnostic> > documentsAndDiagnosticsToFixMap,
            FixAllContext fixAllContext)
        {
            if (documentsAndDiagnosticsToFixMap != null && documentsAndDiagnosticsToFixMap.Any())
            {
                FixAllLogger.LogDiagnosticsStats(documentsAndDiagnosticsToFixMap);

                var fixesBag = new ConcurrentBag <CodeAction>();

                using (Logger.LogBlock(FunctionId.CodeFixes_FixAllOccurrencesComputation_Fixes, fixAllContext.CancellationToken))
                {
                    fixAllContext.CancellationToken.ThrowIfCancellationRequested();

                    var documents = documentsAndDiagnosticsToFixMap.Keys;
                    var tasks     = documents.Select(d => AddDocumentFixesAsync(d, documentsAndDiagnosticsToFixMap[d], fixesBag.Add, fixAllContext))
                                    .ToArray();
                    await Task.WhenAll(tasks).ConfigureAwait(false);
                }

                if (fixesBag.Any())
                {
                    using (Logger.LogBlock(FunctionId.CodeFixes_FixAllOccurrencesComputation_Merge, fixAllContext.CancellationToken))
                    {
                        FixAllLogger.LogFixesToMergeStats(fixesBag);
                        return(await TryGetMergedFixAsync(fixesBag, fixAllContext).ConfigureAwait(false));
                    }
                }
            }

            return(null);
        }
Beispiel #6
0
        private async Task <ImmutableArray <(Diagnostic diagnostic, CodeAction action)> > GetDiagnosticsAndCodeActionsAsync(
            ImmutableDictionary <Document, ImmutableArray <Diagnostic> > documentsAndDiagnosticsToFixMap,
            FixAllState fixAllState, CancellationToken cancellationToken)
        {
            var fixesBag = new ConcurrentBag <(Diagnostic diagnostic, CodeAction action)>();

            using (Logger.LogBlock(
                       FunctionId.CodeFixes_FixAllOccurrencesComputation_Document_Fixes,
                       FixAllLogger.CreateCorrelationLogMessage(fixAllState.CorrelationId),
                       cancellationToken))
            {
                cancellationToken.ThrowIfCancellationRequested();

                var tasks = new List <Task>();

                foreach (var kvp in documentsAndDiagnosticsToFixMap)
                {
                    var document         = kvp.Key;
                    var diagnosticsToFix = kvp.Value;
                    Debug.Assert(!diagnosticsToFix.IsDefaultOrEmpty);
                    if (!diagnosticsToFix.IsDefaultOrEmpty)
                    {
                        tasks.Add(AddDocumentFixesAsync(
                                      document, diagnosticsToFix, fixesBag, fixAllState, cancellationToken));
                    }
                }

                await Task.WhenAll(tasks).ConfigureAwait(false);
            }

            return(fixesBag.ToImmutableArray());
        }
Beispiel #7
0
        internal sealed override Task <Solution> GetChangedSolutionAsync(
            IProgressTracker progressTracker,
            CancellationToken cancellationToken
            )
        {
            cancellationToken.ThrowIfCancellationRequested();
            FixAllLogger.LogState(
                FixAllState,
                IsInternalCodeFixProvider(FixAllState.CodeFixProvider)
                );

            var service =
                FixAllState.Project.Solution.Workspace.Services.GetService <IFixAllGetFixesService>();

            var fixAllContext = new FixAllContext(FixAllState, progressTracker, cancellationToken);

            if (progressTracker != null)
            {
                progressTracker.Description = FixAllContextHelper.GetDefaultFixAllTitle(
                    fixAllContext
                    );
            }

            return(service.GetFixAllChangedSolutionAsync(fixAllContext));
        }
Beispiel #8
0
        internal override Task <ImmutableArray <CodeActionOperation> > ComputeOperationsAsync(
            IProgressTracker progressTracker,
            CancellationToken cancellationToken
            )
        {
            cancellationToken.ThrowIfCancellationRequested();
            FixAllLogger.LogState(
                FixAllState,
                IsInternalCodeFixProvider(FixAllState.CodeFixProvider)
                );

            var service =
                FixAllState.Project.Solution.Workspace.Services.GetService <IFixAllGetFixesService>();

            var fixAllContext = new FixAllContext(FixAllState, progressTracker, cancellationToken);

            if (progressTracker != null)
            {
                progressTracker.Description = FixAllContextHelper.GetDefaultFixAllTitle(
                    fixAllContext
                    );
            }

            return(service.GetFixAllOperationsAsync(fixAllContext, _showPreviewChangesDialog));
        }
Beispiel #9
0
        protected override async Task <IEnumerable <CodeActionOperation> > ComputeOperationsAsync(CancellationToken cancellationToken)
        {
            FixAllLogger.LogContext(_fixAllContext, IsInternalCodeFixProvider(_fixAllContext.CodeFixProvider));

            var service = _fixAllContext.Project.Solution.Workspace.Services.GetService <IFixAllGetFixesService>();

            return(await service.GetFixAllOperationsAsync(_fixAllProvider, _fixAllContext).ConfigureAwait(false));
        }
Beispiel #10
0
        protected async override Task <Solution> GetChangedSolutionAsync(CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();
            FixAllLogger.LogContext(_fixAllContext, IsInternalCodeFixProvider(_fixAllContext.CodeFixProvider));

            var service = _fixAllContext.Project.Solution.Workspace.Services.GetService <IFixAllGetFixesService>();

            // Use the new cancellation token instead of the stale one present inside _fixAllContext.
            return(await service.GetFixAllChangedSolutionAsync(_fixAllProvider, _fixAllContext.WithCancellationToken(cancellationToken), FixAllWaitDialogAndPreviewChangesTitle, ComputingFixAllWaitDialogMessage).ConfigureAwait(false));
        }
Beispiel #11
0
        protected override async Task <IEnumerable <CodeActionOperation> > ComputeOperationsAsync(CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();
            FixAllLogger.LogContext(_fixAllContext, IsInternalCodeFixProvider(_fixAllContext.CodeFixProvider));

            var service = _fixAllContext.Project.Solution.Workspace.Services.GetService <IFixAllGetFixesService>();

            // Use the new cancellation token instead of the stale one present inside _fixAllContext.
            return(await service.GetFixAllOperationsAsync(_fixAllProvider, _fixAllContext.WithCancellationToken(cancellationToken)).ConfigureAwait(false));
        }
Beispiel #12
0
        protected async override Task <Solution> GetChangedSolutionAsync(CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();
            FixAllLogger.LogState(_fixAllState, IsInternalCodeFixProvider(_fixAllState.CodeFixProvider));

            var service = _fixAllState.Project.Solution.Workspace.Services.GetService <IFixAllGetFixesService>();

            // Use the new cancellation token instead of the stale one present inside _fixAllContext.
            return(await service.GetFixAllChangedSolutionAsync(
                       _fixAllState.CreateFixAllContext(cancellationToken)).ConfigureAwait(false));
        }
Beispiel #13
0
        internal override Task <ImmutableArray <CodeActionOperation> > ComputeOperationsAsync(
            IProgressTracker progressTracker, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();
            FixAllLogger.LogState(FixAllState, IsInternalCodeFixProvider(FixAllState.CodeFixProvider));

            var service = FixAllState.Project.Solution.Workspace.Services.GetService <IFixAllGetFixesService>();

            // Use the new cancellation token instead of the stale one present inside _fixAllContext.
            return(service.GetFixAllOperationsAsync(
                       new FixAllContext(FixAllState, progressTracker, cancellationToken),
                       _showPreviewChangesDialog));
        }
Beispiel #14
0
        internal override async Task <IEnumerable <CodeActionOperation> > ComputeOperationsAsync(
            IProgressTracker progressTracker, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();
            FixAllLogger.LogState(_fixAllState, IsInternalCodeFixProvider(_fixAllState.CodeFixProvider));

            var service = _fixAllState.Project.Solution.Workspace.Services.GetService <IFixAllGetFixesService>();

            // Use the new cancellation token instead of the stale one present inside _fixAllContext.
            return(await service.GetFixAllOperationsAsync(
                       _fixAllState.CreateFixAllContext(progressTracker, cancellationToken),
                       _showPreviewChangesDialog).ConfigureAwait(false));
        }
 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);
                }
            }
        private async Task <ImmutableArray <(Diagnostic diagnostic, CodeAction action)> > GetDiagnosticsAndCodeActionsAsync(
            ImmutableDictionary <Document, ImmutableArray <Diagnostic> > documentsAndDiagnosticsToFixMap,
            FixAllContext fixAllContext)
        {
            var cancellationToken = fixAllContext.CancellationToken;
            var fixAllState       = fixAllContext.State;
            var fixesBag          = new ConcurrentBag <(Diagnostic diagnostic, CodeAction action)>();

            using (Logger.LogBlock(
                       FunctionId.CodeFixes_FixAllOccurrencesComputation_Document_Fixes,
                       FixAllLogger.CreateCorrelationLogMessage(fixAllState.CorrelationId),
                       cancellationToken))
            {
                cancellationToken.ThrowIfCancellationRequested();

                var progressTracker = fixAllContext.GetProgressTracker();
                progressTracker.Description = WorkspaceExtensionsResources.Applying_fix_all;

                using var _1 = ArrayBuilder <Task> .GetInstance(out var tasks);

                using var _2 = ArrayBuilder <Document> .GetInstance(out var documentsToFix);

                // Determine the set of documents to actually fix.  We can also use this to update the progress bar with
                // the amount of remaining work to perform.  We'll update the progress bar as we compute each fix in
                // AddDocumentFixesAsync.
                foreach (var(document, diagnosticsToFix) in documentsAndDiagnosticsToFixMap)
                {
                    if (!diagnosticsToFix.IsDefaultOrEmpty)
                    {
                        documentsToFix.Add(document);
                    }
                }

                progressTracker.AddItems(documentsToFix.Count);

                foreach (var document in documentsToFix)
                {
                    var diagnosticsToFix = documentsAndDiagnosticsToFixMap[document];
                    tasks.Add(AddDocumentFixesAsync(
                                  document, diagnosticsToFix, fixesBag, fixAllState, progressTracker, cancellationToken));
                }

                await Task.WhenAll(tasks).ConfigureAwait(false);
            }

            return(fixesBag.ToImmutableArray());
        }
Beispiel #18
0
                static async Task <ImmutableDictionary <Document, ImmutableArray <Diagnostic> > > GetDocumentDiagnosticsToFixWorkerAsync(FixAllContext fixAllContext)
                {
                    if (fixAllContext.State.DiagnosticProvider is FixAllState.FixMultipleDiagnosticProvider fixMultipleDiagnosticProvider)
                    {
                        return(fixMultipleDiagnosticProvider.DocumentDiagnosticsMap);
                    }

                    using (Logger.LogBlock(
                               FunctionId.CodeFixes_FixAllOccurrencesComputation_Document_Diagnostics,
                               FixAllLogger.CreateCorrelationLogMessage(fixAllContext.State.CorrelationId),
                               fixAllContext.CancellationToken))
                    {
                        return(await FixAllContextHelper.GetDocumentDiagnosticsToFixAsync(
                                   fixAllContext,
                                   fixAllContext.ProgressTracker,
                                   (d, c) => DocumentExtensions.IsGeneratedCode(d, c)).ConfigureAwait(false));
                    }
                }
        public virtual async Task <CodeAction> GetFixAsync(
            ImmutableDictionary <Document, ImmutableArray <Diagnostic> > documentsAndDiagnosticsToFixMap,
            FixAllContext fixAllContext)
        {
            if (documentsAndDiagnosticsToFixMap != null && documentsAndDiagnosticsToFixMap.Any())
            {
                FixAllLogger.LogDiagnosticsStats(documentsAndDiagnosticsToFixMap);

                var fixesBag = new ConcurrentBag <CodeAction>();

                using (Logger.LogBlock(FunctionId.CodeFixes_FixAllOccurrencesComputation_Fixes, fixAllContext.CancellationToken))
                {
                    fixAllContext.CancellationToken.ThrowIfCancellationRequested();

                    var documents = documentsAndDiagnosticsToFixMap.Keys.ToImmutableArray();
                    var options   = new ParallelOptions()
                    {
                        CancellationToken = fixAllContext.CancellationToken
                    };
                    Parallel.ForEach(documents, options, document =>
                    {
                        fixAllContext.CancellationToken.ThrowIfCancellationRequested();
                        AddDocumentFixesAsync(document, documentsAndDiagnosticsToFixMap[document], fixesBag.Add, fixAllContext).Wait(fixAllContext.CancellationToken);
                    });
                }

                if (fixesBag.Any())
                {
                    using (Logger.LogBlock(FunctionId.CodeFixes_FixAllOccurrencesComputation_Merge, fixAllContext.CancellationToken))
                    {
                        FixAllLogger.LogFixesToMergeStats(fixesBag);
                        return(await TryGetMergedFixAsync(fixesBag, fixAllContext).ConfigureAwait(false));
                    }
                }
            }

            return(null);
        }
        internal override async Task <CodeAction> GetFixAsync(
            ImmutableDictionary <Document, ImmutableArray <Diagnostic> > documentsAndDiagnosticsToFixMap,
            FixAllState fixAllState, CancellationToken cancellationToken)
        {
            if (documentsAndDiagnosticsToFixMap?.Any() == true)
            {
                FixAllLogger.LogDiagnosticsStats(documentsAndDiagnosticsToFixMap);

                var diagnosticsAndCodeActions = await GetDiagnosticsAndCodeActions(
                    documentsAndDiagnosticsToFixMap, fixAllState, cancellationToken).ConfigureAwait(false);

                if (diagnosticsAndCodeActions.Length > 0)
                {
                    using (Logger.LogBlock(FunctionId.CodeFixes_FixAllOccurrencesComputation_Merge, cancellationToken))
                    {
                        FixAllLogger.LogFixesToMergeStats(diagnosticsAndCodeActions.Length);
                        return(await TryGetMergedFixAsync(
                                   diagnosticsAndCodeActions, fixAllState, cancellationToken).ConfigureAwait(false));
                    }
                }
            }

            return(null);
        }
Beispiel #21
0
            internal virtual async Task <ImmutableDictionary <Document, ImmutableArray <Diagnostic> > > GetDocumentDiagnosticsToFixWorkerAsync(
                FixAllContext fixAllContext)
            {
                var cancellationToken = fixAllContext.CancellationToken;

                using (Logger.LogBlock(
                           FunctionId.CodeFixes_FixAllOccurrencesComputation_Document_Diagnostics,
                           FixAllLogger.CreateCorrelationLogMessage(fixAllContext.State.CorrelationId),
                           cancellationToken))
                {
                    var allDiagnostics = ImmutableArray <Diagnostic> .Empty;
                    var projectsToFix  = ImmutableArray <Project> .Empty;

                    var document = fixAllContext.Document;
                    var project  = fixAllContext.Project;

                    switch (fixAllContext.Scope)
                    {
                    case FixAllScope.Document:
                        if (document != null && !document.IsGeneratedCode(cancellationToken))
                        {
                            var documentDiagnostics = await fixAllContext.GetDocumentDiagnosticsAsync(document).ConfigureAwait(false);

                            var kvp = SpecializedCollections.SingletonEnumerable(KeyValuePair.Create(document, documentDiagnostics));
                            return(ImmutableDictionary.CreateRange(kvp));
                        }

                        break;

                    case FixAllScope.Project:
                        projectsToFix  = ImmutableArray.Create(project);
                        allDiagnostics = await fixAllContext.GetAllDiagnosticsAsync(project).ConfigureAwait(false);

                        break;

                    case FixAllScope.Solution:
                        projectsToFix = project.Solution.Projects
                                        .Where(p => p.Language == project.Language)
                                        .ToImmutableArray();

                        var progressTracker = fixAllContext.ProgressTracker;
                        progressTracker.AddItems(projectsToFix.Length);

                        var diagnostics = new ConcurrentBag <Diagnostic>();
                        var tasks       = new Task[projectsToFix.Length];
                        for (int i = 0; i < projectsToFix.Length; i++)
                        {
                            cancellationToken.ThrowIfCancellationRequested();
                            var projectToFix = projectsToFix[i];
                            tasks[i] = Task.Run(async() =>
                            {
                                var projectDiagnostics = await fixAllContext.GetAllDiagnosticsAsync(projectToFix).ConfigureAwait(false);
                                foreach (var diagnostic in projectDiagnostics)
                                {
                                    cancellationToken.ThrowIfCancellationRequested();
                                    diagnostics.Add(diagnostic);
                                }

                                progressTracker.ItemCompleted();
                            }, cancellationToken);
                        }

                        await Task.WhenAll(tasks).ConfigureAwait(false);

                        allDiagnostics = allDiagnostics.AddRange(diagnostics);
                        break;
                    }

                    if (allDiagnostics.IsEmpty)
                    {
                        return(ImmutableDictionary <Document, ImmutableArray <Diagnostic> > .Empty);
                    }

                    return(await GetDocumentDiagnosticsToFixAsync(
                               allDiagnostics, projectsToFix, fixAllContext.CancellationToken).ConfigureAwait(false));
                }
            }