Getting an IWorkspaceDiscoveryService
-
Sunday, December 18, 2011 4:32 AM
Hi,
I'd like to access the currently active workspace for a loaded solution. I found this thread, which was helpful, but seems to be missing something I can't quite figure out.
"To actually retrieve the current IWorkspace within a Roslyn extension you should use an IWorkspaceDiscoveryService". A few examples are given, but it's not clear to me where that IWorkspaceDiscoveryService is coming from. How do I get a reference to an implementation of IWorkspaceDiscoveryService?
Thanks!
All Replies
-
Monday, December 19, 2011 8:27 PMOwner
You should be able to "MEF-Import" IWorkspaceDiscoveryService from within your VS extension. I had posted example code to demostrate MEF-Importing of some other Roslyn services on this thread - you should be able to follow similar steps to MEF-Import IWorkspaceDiscoveryService...While MEF-Importing is probably the easiest way to get at IWorkspaceDiscoveryService, there are also other ways to do this from within a VS extension. The "Syntax Visualizer Tool Window" sample extension that ships with the CTP has some code that demonstrates an alternate way to do this. You can take a look at the code for a property named WorkspaceDiscoveryService in the file SyntaxVisualizerContainer.xaml.cs...
Note that the IWorkspaceDiscoveryService will only be available inside instances of VS that are running under the Roslyn "rootsuffix" - this thread has some details / discussion around this.
Hope this helps! Let me know if you have further questions.
Shyam Namboodiripad | Software Development Engineer in Test | Roslyn Compilers Team- Edited by Shyam NamboodiripadMicrosoft Employee, Owner Monday, December 19, 2011 8:49 PM
- Proposed As Answer by Shyam NamboodiripadMicrosoft Employee, Owner Tuesday, January 03, 2012 10:08 PM
- Marked As Answer by billchi_msOwner Thursday, January 19, 2012 2:22 AM
-
Tuesday, December 20, 2011 2:02 AM
Thanks Shyam. I'll explore the options you mentioned.

