Is there some way to add a specific statement at the end of a method in a .cs file with Roslyn?
var code = new StreamReader(@"C:\Users\PersonalUser\Documents\Visual Studio 2015\Projects\SampleToAnalyze\SampleToAnalyze\ClassChild.cs").ReadToEnd();
SyntaxTree tree = CSharpSyntaxTree.ParseText(code);
var root = tree.GetRoot();
var compilation = CSharpCompilation.Create("MyCompilation", new[] { tree },
new[] { MetadataReference.CreateFromFile(typeof(object).Assembly.Location) });
var model = compilation.GetSemanticModel(tree);
MethodDeclarationSyntax myMethod= tree.GetRoot().DescendantNodes()
.OfType<MethodDeclarationSyntax>().Last();
StatementSyntax myStatement= SyntaxFactory.ParseStatement(@"Console.WriteLine();");
I want to insert "myStatement" at the end of method "myMethod".