Exemplo n.º 1
0
        private static async Task <Solution> GetDocumentFixesAsync(FixAllContext fixAllContext)
        {
            var documentDiagnosticsToFix = await FixAllContextHelper.GetDocumentDiagnosticsToFixAsync(fixAllContext).ConfigureAwait(false);

            ImmutableArray <Diagnostic> diagnostics;

            if (!documentDiagnosticsToFix.TryGetValue(fixAllContext.Document, out diagnostics))
            {
                return(fixAllContext.Document.Project.Solution);
            }

            return(await FixDocumentAsync(fixAllContext.Document.Project.Solution, fixAllContext.Document.Id, diagnostics, fixAllContext.CodeActionEquivalenceKey, fixAllContext.CancellationToken).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));
     }
 }
Exemplo n.º 3
0
        private static async Task <Solution> GetSolutionFixesAsync(FixAllContext fixAllContext, ImmutableArray <Document> documents)
        {
            var documentDiagnosticsToFix = await FixAllContextHelper.GetDocumentDiagnosticsToFixAsync(fixAllContext).ConfigureAwait(false);

            Solution solution = fixAllContext.Solution;

            foreach (var document in documents)
            {
                ImmutableArray <Diagnostic> diagnostics;
                if (!documentDiagnosticsToFix.TryGetValue(document, out diagnostics))
                {
                    continue;
                }

                solution = await FixDocumentAsync(solution, document.Id, diagnostics, fixAllContext.CodeActionEquivalenceKey, fixAllContext.CancellationToken).ConfigureAwait(false);
            }

            return(solution);
        }