I want to view all the documents in each project in this solution using Roslyn.
This is the code I have now:
var msWorkspace = MSBuildWorkspace.Create(); var solution = await msWorkspace.OpenSolutionAsync(solutionPath); foreach (var project in solution.Projects) { foreach (var document in project.Documents) { if (document.SourceCodeKind != SourceCodeKind.Regular) continue; var doc = document; foreach (var rewriter in rewriters) { doc = await rewriter.Rewrite(doc); } if (doc != document) { Console.WriteLine("changed {0}",doc.Name);
The problem here is that since Roslyn is pretty much unchanged. After the first "msWorkspace.TryApplyChanges" the solution and the document are now replaced with new versions.
So, the next iteration will still go over the old versions. Is there any way to do this in Roslin's idiomatic style? Or do I need to resort to some kind of hacking? T / t>
source share