Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cohost diagnostics support #10882

Merged
merged 14 commits into from
Sep 18, 2024
Merged

Conversation

davidwengier
Copy link
Contributor

@davidwengier davidwengier commented Sep 13, 2024

Fixes #10696
Fixes #10769
Fixes #10874
Needs Roslyn change: dotnet/roslyn#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 #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.

…m over to OOP

Wanted to validate my Roslyn code would work first, before moving our services around, in case the order of this work seems backwards to usual :)
Also switch from Roslyn LSP types to VS LSP types so we can call the shared code
Writing the code: Easy
Writing the test: Easy
Getting the MEF stuff to work: I've lost even more hair
… and create a fixture so we can still share an instance
Also delete all of the if-def-ed out and redundant code as a result. If we need to do any caching of things, lets just use xunit features and not odd static stuff with custom test attributes etc.
Copy link
Member

@DustinCampbell DustinCampbell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I very much appreciate the test insfrastructure improvements!

Comment on lines +20 to +21
using LspDiagnostic = Microsoft.VisualStudio.LanguageServer.Protocol.Diagnostic;
using LspDiagnosticSeverity = Microsoft.VisualStudio.LanguageServer.Protocol.DiagnosticSeverity;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we'll always have conflicts with Microsoft.CodeAnalysis.Diagnostic, does it make sense to add these to our global usings?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't currently have any global usings to speak of in this project, but I've made a note on #10682

namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost;

[CollectionDefinition(Name)]
public class HtmlFormattingCollection : ICollectionFixture<HtmlFormattingFixture>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC, the last time I added a collection fixture, I ended up using a shared project to avoid copying and pasting code since xUnit insists that these be defined in the test assembly.

@davidwengier davidwengier requested a review from a team as a code owner September 17, 2024 21:54
@davidwengier davidwengier merged commit 4b3e409 into dotnet:main Sep 18, 2024
12 checks passed
@davidwengier davidwengier deleted the CohostDiagnostics branch September 18, 2024 04:11
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Sep 18, 2024
@phil-allen-msft phil-allen-msft modified the milestones: Next, 17.12 P3 Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants