I am trying to get a reference to currently loaded workspace, without success. As per documentation (part in bold) I should be able to get a reference to it.
The Workspace APIs are found in the Roslyn.Services namespace, and they are available if you include the following using directive:
using Roslyn.Services;
The workspace you use will typically be provided directly by the host environment (such as the Visual Studio IDE). However, you can work with a workspace outside of a host environment by constructing your own IWorkspace instance.
You can construct a workspace by loading a solution file.
IWorkspace workspace = Workspace.LoadSolution(@"HelloWorld.sln"); ISolution solution = workspace.CurrentSolution;
I tried following in unit test but workspace is null.
IWorkspace workspace = Workspace.PrimaryWorkspace;
ISolution solution = workspace.CurrentSolution;
I dont want to load solution, I want to work within currently loaded solution. How is it done? I am using Visual Studio 2012.
Edit:
Tried using switch /rootSuffx Roslyn as suggested in answer and VS throws an error that it is invalid switch. Changed it to /rootSuffix Roslyn, and VS starts but workspace is still null.