Cohost diagnostics support#10882
Merged
davidwengier merged 14 commits intodotnet:mainfrom Sep 18, 2024
Merged
Conversation
…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 :)
… to workspaces layer
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.
This was referenced Sep 13, 2024
DustinCampbell
approved these changes
Sep 13, 2024
Member
DustinCampbell
left a comment
There was a problem hiding this comment.
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; |
Member
There was a problem hiding this comment.
Since we'll always have conflicts with Microsoft.CodeAnalysis.Diagnostic, does it make sense to add these to our global usings?
Member
Author
There was a problem hiding this comment.
We don't currently have any global usings to speak of in this project, but I've made a note on #10682
src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Diagnostics/RemoteDiagnosticsService.cs
Outdated
Show resolved
Hide resolved
...Studio.LanguageServices.Razor/LanguageClient/Cohost/CohostDocumentPullDiagnosticsEndpoint.cs
Show resolved
Hide resolved
.../Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/HtmlFormattingCollection.cs
Show resolved
Hide resolved
...zor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostEndpointTestBase.cs
Outdated
Show resolved
Hide resolved
| namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost; | ||
|
|
||
| [CollectionDefinition(Name)] | ||
| public class HtmlFormattingCollection : ICollectionFixture<HtmlFormattingFixture> |
Member
There was a problem hiding this comment.
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.
8 tasks
This was referenced Sep 20, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
ExportProvideras needed and expect consumers to dispose of it like any otherIDisposable, 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.