private async static Task<SolutionWithDocs> GetSolutionWithDocsAsync(FixAllContext fixAllContext, Document document) { var docs = new List<DiagnosticsInDoc>(); var doc = await GetDiagnosticsInDocAsync(fixAllContext, document); docs.Add(doc); var newSolution = document.Project.Solution.WithDocumentSyntaxRoot(document.Id, doc.TrackedRoot); var sol = new SolutionWithDocs { Docs = docs, Solution = newSolution }; return sol; }
private async static Task<SolutionWithDocs> GetSolutionWithDocsAsync(FixAllContext fixAllContext, Solution solution) { var docs = new List<DiagnosticsInDoc>(); var sol = new SolutionWithDocs { Docs = docs, Solution = solution }; foreach (var pId in solution.Projects.Select(p => p.Id)) { var project = sol.Solution.GetProject(pId); var newSol = await GetSolutionWithDocsAsync(fixAllContext, project).ConfigureAwait(false); sol.Merge(newSol); } return sol; }
private async static Task <SolutionWithDocs> GetSolutionWithDocsAsync(FixAllContext fixAllContext, Document document) { var docs = new List <DiagnosticsInDoc>(); var doc = await GetDiagnosticsInDocAsync(fixAllContext, document); docs.Add(doc); var newSolution = document.Project.Solution.WithDocumentSyntaxRoot(document.Id, doc.TrackedRoot); var sol = new SolutionWithDocs { Docs = docs, Solution = newSolution }; return(sol); }
private async static Task<SolutionWithDocs> GetSolutionWithDocsAsync(FixAllContext fixAllContext, Project project) { var docs = new List<DiagnosticsInDoc>(); var newSolution = project.Solution; foreach (var document in project.Documents) { var doc = await GetDiagnosticsInDocAsync(fixAllContext, document); if (doc.Equals(DiagnosticsInDoc.Empty)) continue; docs.Add(doc); newSolution = newSolution.WithDocumentSyntaxRoot(document.Id, doc.TrackedRoot); } var sol = new SolutionWithDocs { Docs = docs, Solution = newSolution }; return sol; }
private async static Task<Solution> GetFixedSolutionAsync(FixAllContext fixAllContext, SolutionWithDocs sol) { var newSolution = sol.Solution; foreach (var doc in sol.Docs) { foreach (var node in doc.Nodes) { var document = newSolution.GetDocument(doc.DocumentId); var root = await document.GetSyntaxRootAsync(fixAllContext.CancellationToken).ConfigureAwait(false); var trackedNode = root.GetCurrentNode(node); var property = trackedNode.AncestorsAndSelf().OfType<PropertyDeclarationSyntax>().First(); newSolution = await SwitchToAutoPropCodeFixProvider.MakeAutoPropertyAsync(document, root, property, fixAllContext.CancellationToken); } } return newSolution; }
private async static Task <SolutionWithDocs> GetSolutionWithDocsAsync(FixAllContext fixAllContext, Solution solution) { var docs = new List <DiagnosticsInDoc>(); var sol = new SolutionWithDocs { Docs = docs, Solution = solution }; foreach (var pId in solution.Projects.Select(p => p.Id)) { var project = sol.Solution.GetProject(pId); var newSol = await GetSolutionWithDocsAsync(fixAllContext, project).ConfigureAwait(false); sol.Merge(newSol); } return(sol); }
private async static Task<Solution> GetFixedSolutionAsync(FixAllContext fixAllContext, SolutionWithDocs sol) { var newSolution = sol.Solution; foreach (var doc in sol.Docs) { foreach (var node in doc.Nodes) { var document = newSolution.GetDocument(doc.DocumentId); var root = await document.GetSyntaxRootAsync(fixAllContext.CancellationToken).ConfigureAwait(false); var trackedNode = root.GetCurrentNode(node); var parameter = trackedNode.AncestorsAndSelf().OfType<ParameterSyntax>().First(); var docResults = await UnusedParametersCodeFixProvider.RemoveParameterAsync(document, parameter, root, fixAllContext.CancellationToken); foreach (var docResult in docResults) newSolution = newSolution.WithDocumentSyntaxRoot(docResult.DocumentId, docResult.Root); } } return newSolution; }
private async static Task <SolutionWithDocs> GetSolutionWithDocsAsync(FixAllContext fixAllContext, Project project) { var docs = new List <DiagnosticsInDoc>(); var newSolution = project.Solution; foreach (var document in project.Documents) { var doc = await GetDiagnosticsInDocAsync(fixAllContext, document); if (doc.Equals(DiagnosticsInDoc.Empty)) { continue; } docs.Add(doc); newSolution = newSolution.WithDocumentSyntaxRoot(document.Id, doc.TrackedRoot); } var sol = new SolutionWithDocs { Docs = docs, Solution = newSolution }; return(sol); }
public void Merge(SolutionWithDocs sol) { Solution = sol.Solution; Docs.AddRange(sol.Docs); }
private async static Task <Solution> GetFixedSolutionAsync(FixAllContext fixAllContext, SolutionWithDocs sol) { var newSolution = sol.Solution; foreach (var doc in sol.Docs) { foreach (var node in doc.Nodes) { var document = newSolution.GetDocument(doc.DocumentId); var root = await document.GetSyntaxRootAsync(fixAllContext.CancellationToken).ConfigureAwait(false); var trackedNode = root.GetCurrentNode(node); var property = trackedNode.AncestorsAndSelf().OfType <PropertyDeclarationSyntax>().First(); newSolution = await SwitchToAutoPropCodeFixProvider.MakeAutoPropertyAsync(document, root, property, fixAllContext.CancellationToken); } } return(newSolution); }
private async static Task <Solution> GetFixedSolutionAsync(FixAllContext fixAllContext, SolutionWithDocs sol) { var newSolution = sol.Solution; foreach (var doc in sol.Docs) { foreach (var node in doc.Nodes) { var document = newSolution.GetDocument(doc.DocumentId); var root = await document.GetSyntaxRootAsync(fixAllContext.CancellationToken).ConfigureAwait(false); var trackedNode = root.GetCurrentNode(node); var parameter = trackedNode.AncestorsAndSelf().OfType <ParameterSyntax>().First(); var docResults = await UnusedParametersCodeFixProvider.RemoveParameterAsync(document, parameter, root, fixAllContext.CancellationToken); foreach (var docResult in docResults) { newSolution = newSolution.WithDocumentSyntaxRoot(docResult.DocumentId, docResult.Root); } } } return(newSolution); }