Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var workspace = MSBuildWorkspace.Create();
- var project = workspace.OpenProjectAsync(@"path\to\.csproj").Result;
- var documents = project.DocumentIds;
- foreach (var documentId in documents)
- {
- var document = project.GetDocument(documentId);
- var root = document.GetSyntaxRootAsync().Result
- var rewrite = new MyRewrite();
- root = rewrite.Visit(root);
- var newDocument = document.WithSyntaxRoot(root);
- var compilation = newDocument.Project.GetCompilationAsync().Result;
- // When I look at the sementatic model here it contains my changes.
- var sementaticModel =
- compilation.GetSemanticModel(newDocument.GetSyntaxTreeAsync().Result);
- // But when I inspect this dll with dotPeek it's still the old code without changes.
- compilation.Emit("new/dll/path");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement