5

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

The exception message is "The language 'C#' is not supported."

What am I missing to make this work?

Aethon Invictus
  • 275
  • 2
  • 9

1 Answers1

7

You need to add a reference to the C# Workspaces NuGet package.

This will copy the C# DLLs to your output, and let Roslyn's MEF scanner see the language services.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
  • I do have that package referenced; in fact, it is the only Roslyn package I pulled in to make sure that all of the dependencies lined. – Aethon Invictus Jun 02 '15 at 20:30
  • 1
    @AethonInvictus: Is `Microsoft.CodeAnalysis.CSharp.Workspaces.dll` in your output directory? Do you see it in Debug, Modules? – SLaks Jun 02 '15 at 21:05
  • There are three different assemblies: *.CSharp.dll, *.CSharp.Workspaces.dll, *.Workspaces.dll ( * = Microsoft.CodeAnalysis). As @SLaks recommended, Microsoft.CodeAnalysis.CSharp.Workspaces.dll was what I needed. – Drew Delano Dec 25 '16 at 01:23