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

感情迁移 提交于 2019-12-06 04:51:50

问题


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?


回答1:


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);
}


来源:https://stackoverflow.com/questions/31175881/unable-to-get-method-syntaxtree-parsefile-in-new-nuget-of-roslyn

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!