dotnet / razor

Compiler and tooling experience for Razor ASP.NET Core apps in Visual Studio, Visual Studio for Mac, and VS Code.
https://asp.net
MIT License
493 stars 191 forks source link

Cohost diagnostics support #10882

Closed davidwengier closed 1 week ago

davidwengier commented 2 weeks ago

Fixes https://github.com/dotnet/razor/issues/10696 Fixes https://github.com/dotnet/razor/issues/10769 Fixes https://github.com/dotnet/razor/issues/10874 Needs Roslyn change: https://github.com/dotnet/roslyn/pull/75102

The actual code change was quite straight foward. The test code was a bigger pain. Previously in cohosting tests we had two MEF composition, one for Razor and one for Roslyn. Since Roslyn diagnostics can only run, or at least start, in devenv, we now need three MEF compositions - Roslyn devenv, Roslyn OOP and razor OOP - and two workspaces - Roslyn devenv and Roslyn OOP - and our previous MEF infrastructure really didn't handle this well, as evidenced by the fact that this PR also fixes https://github.com/dotnet/razor/issues/10874

Now our MEF infra is simpler: We still cache catalogs etc. statically the save time, but we create an ExportProvider as needed and expect consumers to dispose of it like any other IDisposable, though there is also here a test fixture to share the editor composition in the formatting tests so we don't pay a huge penalty in terms of test run time.

Commit-at-a-time if you want to read the story from beginning to end, but it should be reasonably okay to just review as a whole too.