private async Task <Solution> GetSolutionFixesAsync(FixAllContext fixAllContext, ImmutableArray <Document> documents) { var documentDiagnosticsToFix = await FixAllContextHelper.GetDocumentDiagnosticsToFixAsync(fixAllContext).ConfigureAwait(false); Solution solution = fixAllContext.Solution; List <Task <SyntaxNode> > newDocuments = new List <Task <SyntaxNode> >(documents.Length); foreach (var document in documents) { ImmutableArray <Diagnostic> diagnostics; if (!documentDiagnosticsToFix.TryGetValue(document, out diagnostics)) { newDocuments.Add(document.GetSyntaxRootAsync(fixAllContext.CancellationToken)); continue; } newDocuments.Add(this.FixAllInDocumentAsync(fixAllContext, document, diagnostics)); } for (int i = 0; i < documents.Length; i++) { var newDocumentRoot = await newDocuments[i].ConfigureAwait(false); if (newDocumentRoot == null) { continue; } solution = solution.WithDocumentSyntaxRoot(documents[i].Id, newDocumentRoot); } return(solution); }
private async Task <Document> GetDocumentFixesAsync(FixAllContext fixAllContext) { var documentDiagnosticsToFix = await FixAllContextHelper.GetDocumentDiagnosticsToFixAsync(fixAllContext).ConfigureAwait(false); ImmutableArray <Diagnostic> diagnostics; if (!documentDiagnosticsToFix.TryGetValue(fixAllContext.Document, out diagnostics)) { return(fixAllContext.Document); } var newRoot = await this.FixAllInDocumentAsync(fixAllContext, fixAllContext.Document, diagnostics).ConfigureAwait(false); if (newRoot == null) { return(fixAllContext.Document); } return(fixAllContext.Document.WithSyntaxRoot(newRoot)); }