I am trying to get the syntax tree but it not working when loading the code from a stream instead of a file. See the Example below. Any idea?
Thanks
/ / WORKINGI get a valid SyntaxTree
DebugCodeEdit edit = new DebugCodeEdit ();
edit.LoadFile(@“c:\temp\file.cs”);
RoslynParser lexer = edit.Lexer as RoslynParser;
lexer.ForceReparseText();
Microsoft.CodeAnalysis.SyntaxTree tree;
parser.Repository.Document.TryGetSyntaxTree(out tree); << WORKING
// NOT WORKING - I don’t get a valid SyntaxTree
DebugCodeEdit edit = new DebugCodeEdit ();
using (var fs = new FileStream@“c:\temp\file.cs”, FileMode.Open, FileAccess.Read))
{
using (var sr = new StreamReader(fs, Encoding.UTF8))
{
string code = sr.ReadToEnd();
using (StringReader reader = new StringReader(code))
{
debugCodeEdit.LoadStream(reader);
lexer.Repository.AddDocument(fileName, code);
}
}
}
RoslynParser lexer = edit.Lexer as RoslynParser;
lexer.ForceReparseText();
Microsoft.CodeAnalysis.SyntaxTree tree;
parser.Repository.Document.TryGetSyntaxTree(out tree); << NOT WORKING
Error|CS1061|‘IScriptEdit’ does not contain a definition for ‘Lines’ and no accessible extension method ‘Lines’ accepting a first argument of type ‘IScriptEdit’ could be found (are you missing a using directive or an assembly reference?)