From a Visual Studio 2015 CTP5 package, how do I get the current Roslyn workspace?
I looked at
How to get reference to 'Roslyn' Workspace object from IVsSolution?
and
Roslyn: How to get a reference to Workspace from currently loaded solution?
but I still can't make it work:
Workspace.CurrentWorkspace does not exist anymore
I have tried importing the VisualStudioWorkspace but it is still null:
public sealed class VSPackage1Package : Package
{
....
[Import]
public VisualStudioWorkspace Workspace { get; set; }
....
protected override void Initialize()
{
// Workspace is null here...
Is there a sample somewhere?
I don't see any definition of VisualStudioWorkspace (or the Microsoft.VisualStudio.LanguageServices assembly)
It's there, double check you're looking in the right place.
[Import]s only work if the class you're working in itself is MEF exported. If it's not (like a Package in your case), just write:
var componentModel = (IComponentModel)GetService(typeof(SComponentModel));
var workspace = componentModel.GetService<VisualStudioWorkspace>();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With