SyntaxTree not working when loading from stream

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

Hello,

Could you please try to use this code:

            DebugCodeEdit edit = new DebugCodeEdit();
            string fileName = @"C:\temp\file.cs";
            edit.FileName = fileName; // added code
            Alternet.Syntax.Parsers.Roslyn.RoslynParser lexer = edit.Lexer as Alternet.Syntax.Parsers.Roslyn.RoslynParser;
            using (var fs = new FileStream(fileName, FileMode.Open, FileAccess.Read))
            {
                using (var sr = new StreamReader(fs, Encoding.UTF8))
                {
                    string code = sr.ReadToEnd();
                    using (StringReader reader = new StringReader(code))
                    {
                        edit.LoadStream(reader);
                        lexer.Prepare(fileName, edit.Lines, Alternet.Syntax.PrepareReason.TextChanged); // added code
                        //lexer.Repository.AddDocument(fileName, code); // removed code
                    }
                }
            }
            lexer.ForceReparseText();
            Microsoft.CodeAnalysis.SyntaxTree tree;
            lexer.Repository.Document.TryGetSyntaxTree(out tree);

Regards,
Andrew

Thanks. I am getting the below error

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?)

Never mind. My fault. I am trying now

Calling Prepare is working! Thanks