Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happened to `Solution.LoadStandAloneProject` in Roslyn's new version (Microsoft.CodeAnalysis)?

Tags:

c#

roslyn

Today Microsoft open-sourced a new version of Roslyn and since this release is the first one in about a year and a half, there are an unsurprisingly large number of migration issues. (Symbol -> ISymbol, and basically every non-interface to an interface are predominant) However, I used to use:

Solution.LoadStandAloneProject(projectFile);

To obtain a solution that was created from a .csproj file. (there were also static methods that consumed a .sln file in the same way)

However, the new version, Microsoft.CodeAnalysis does not have a Solution class that contains any static methods. What is the correct method to call in the new API to achieve this functionality?

like image 383
Kirk Woll Avatar asked Dec 26 '22 11:12

Kirk Woll


1 Answers

Kirill Osenkov provided the answer:

MSBuildWorkspace.Create().OpenSolutionAsync()

(I asked this question in all sincerity, but then Kirill provided this answer. Marking as CW since I'm just quoting him, but figured this might be useful to future visitors)

like image 166
2 revs Avatar answered May 23 '23 16:05

2 revs