private async Task <Solution> GetSolutionFixesAsync(FixAllContext fixAllContext, ImmutableArray <Document> documents) { var documentDiagnosticsToFix = await FixAllContextHelper.GetDocumentDiagnosticsToFixAsync(fixAllContext, progressTrackerOpt : null, (document, cancellationToken) => false).ConfigureAwait(false); var solution = fixAllContext.Solution; var newDocuments = new List <Task <SyntaxNode> >(documents.Length); foreach (var document in documents) { if (!documentDiagnosticsToFix.TryGetValue(document, out var diagnostics)) { newDocuments.Add(document.GetSyntaxRootAsync(fixAllContext.CancellationToken)); continue; } newDocuments.Add(FixAllInDocumentAsync(fixAllContext, document, diagnostics)); } for (var 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, progressTrackerOpt : null).ConfigureAwait(false); if (!documentDiagnosticsToFix.TryGetValue(fixAllContext.Document, out var diagnostics)) { return(fixAllContext.Document); } var newRoot = await FixAllInDocumentAsync(fixAllContext, fixAllContext.Document, diagnostics).ConfigureAwait(false); if (newRoot == null) { return(fixAllContext.Document); } return(fixAllContext.Document.WithSyntaxRoot(newRoot)); }
private async Task <Solution> GetSolutionFixesAsync(FixAllContext fixAllContext, ImmutableArray <Document> documents) { var documentDiagnosticsToFix = await FixAllContextHelper.GetDocumentDiagnosticsToFixAsync(fixAllContext, progressTrackerOpt : null).ConfigureAwait(false); using var _ = PooledDictionary <DocumentId, Task <SyntaxNode?> > .GetInstance(out var documentIdToNewNode); foreach (var document in documents) { // Don't bother examining any documents that aren't in the list of docs that // actually have diagnostics. if (!documentDiagnosticsToFix.TryGetValue(document, out var diagnostics)) { continue; } documentIdToNewNode.Add(document.Id, FixAllInDocumentAsync(fixAllContext, document, diagnostics)); } // Allow the processing of all the documents to happen concurrently. await Task.WhenAll(documentIdToNewNode.Values).ConfigureAwait(false); var solution = fixAllContext.Solution; foreach (var(docId, syntaxNodeTask) in documentIdToNewNode) { var newDocumentRoot = await syntaxNodeTask.ConfigureAwait(false); if (newDocumentRoot == null) { continue; } solution = solution.WithDocumentSyntaxRoot(docId, newDocumentRoot); } return(solution); }