Just by opening Roslyn, please be patient.
I would like to update the use directives at the top of my class to include an additional element, for example:
using System; public class Foo { }
It should become:
using System; using Custom.Bar; public class Foo { }
I see that I can override SyntaxRewriter , and I did this to process the method level code, but I donβt see an override that could give me access to these directives?
Thanks.
Edit:
I found this property, but I do not know how to change it.
var tree = document.GetSyntaxTree().GetRoot() as SyntaxNode; var compilationUnitSyntax = (CompilationUnitSyntax) (tree); if (compilationUnitSyntax != null) compilationUnitSyntax.Usings.Add();
Unfortunately, UsingDirectiveSyntax is internal, since I can add it !: D
source share