-
Notifications
You must be signed in to change notification settings - Fork 193
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
Cohost diagnostics support #10882
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.
There was a problem hiding this 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!
using LspDiagnostic = Microsoft.VisualStudio.LanguageServer.Protocol.Diagnostic; | ||
using LspDiagnosticSeverity = Microsoft.VisualStudio.LanguageServer.Protocol.DiagnosticSeverity; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
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> |
There was a problem hiding this comment.
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.
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 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.