I would like to start using NRefactory 5 to parse CSharp files to do refactoring. But the documentation is not enough. So I tried and failed: I started with the following code to find out if I can get the AstNode
tree from the cs file.
I would expect that parsing works out for me some nodes, but no. Can anybody help me?
TextReader reader = File.OpenText(fname); CompilationUnit compilationUnit; CSharpParser parser = new CSharpParser(); compilationUnit = parser.Parse(reader, fname); AstNode node = compilationUnit.GetNextNode(); System.Collections.Generic.IEnumerable<AstNode> desc = compilationUnit.Descendants; foreach (AstNode jo in desc) { System.Console.WriteLine("At least something here"); }
source share