使用"的AdHocWorkspace结果;语言'C#'是不支持"
问题描述:
使用VS2015 Microsoft.CodeAnalysis.CSharp.Workspaces的RC2,该代码会抛出异常:
Using the RC2 of Microsoft.CodeAnalysis.CSharp.Workspaces in VS2015, this code throws an exception:
var tree = CSharpSyntaxTree.ParseText(...);
var workspace = new AdhocWorkspace();
var newRoot = Simplifier.Expand(tree.GetRoot(),
compilation.GetSemanticModel(tree, false),
workspace,
n => true,
true,
CancellationToken.None);
异常消息为语言C#不支持。
The exception message is "The language 'C#' is not supported."
我在想什么,使这项工作?
What am I missing to make this work?
答
您需要添加一个参考 C#工作区的NuGet包。
这将在C#DLL文件复制到你的输出,让罗斯林的MEF扫描仪显示的语言服务。
This will copy the C# DLLs to your output, and let Roslyn's MEF scanner see the language services.