Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Microsoft.CodeAnalysis;
- using Microsoft.CodeAnalysis.CSharp;
- using Microsoft.CodeAnalysis.Text;
- namespace ConsoleApplication2
- {
- class Program
- {
- static void Main(string[] args)
- {
- SourceText origSourceText = SourceText.From("class Test { }");
- SyntaxTree origSyntaxTree = SyntaxFactory.ParseSyntaxTree(origSourceText);
- TextChange textChange = new TextChange(new TextSpan(12, 0), "public void Test() {}");
- SourceText changedSourceText = origSourceText.WithChanges(textChange);
- SyntaxTree changedSyntaxTree = origSyntaxTree.WithChangedText(changedSourceText);
- string src = changedSyntaxTree.GetCompilationUnitRoot().NormalizeWhitespace().ToString();
- /*src
- class Test
- {
- public void Test()
- {
- }
- }
- */
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement