Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to get method SyntaxTree.ParseFile in new nuget of Roslyn?

I have installed nuget for Roslyn with Install-Package Microsoft.CodeAnalysis -Pre but i'm still unable to get the method SyntaxTree.ParseFile as I want to pass code in a .cs file

Any clue about why is it so ? How can I pass file here?

like image 301
Neo Avatar asked Dec 14 '22 13:12

Neo


1 Answers

The API simply changed a little bit, one way to do it is :

var path = @"C:\...\SomeFile.cs";
using(var stream = File.OpenRead(path))
{
    var syntaxTree = CSharpSyntaxTree.ParseText(SourceText.From(stream), path: path);
}
like image 112
Julien Roncaglia Avatar answered May 01 '23 18:05

Julien Roncaglia