Pass in HostServices when creating the LSP server#65384
Conversation
…misc workspace it creates can use items from the host mef composition
| WellKnownLspServerKinds serverKind, | ||
| ILspServiceLogger logger); | ||
| ILspServiceLogger logger, | ||
| HostServices hostServices); |
There was a problem hiding this comment.
to avoid having MS.CA.LanguageServer.Protocol depend on vs-mef, we use HostServices instead of ExportProvider. Then we import the ExportProvider at the layers that are already using it (e.g. EditorFeatures)
| var locations = await GetAnnotatedLocationsAsync(testWorkspace, testWorkspace.CurrentSolution); | ||
| var server = new TestLspServer(testWorkspace, locations, initializationOptions.ClientCapabilities, initializationOptions.ServerKind, logger); | ||
|
|
||
| var (clientStream, serverStream) = FullDuplexStream.CreatePair(); |
There was a problem hiding this comment.
just moved to unify the ctors
| internal interface IRazorLanguageServerFactoryWrapper | ||
| { | ||
| IRazorLanguageServerTarget CreateLanguageServer(JsonRpc jsonRpc, IRazorCapabilitiesProvider capabilitiesProvider); | ||
| IRazorLanguageServerTarget CreateLanguageServer(JsonRpc jsonRpc, IRazorCapabilitiesProvider capabilitiesProvider, HostServices hostServices); |
There was a problem hiding this comment.
Do we need a compat version of this since it's ExternalAPIs or is this not being called yet?
There was a problem hiding this comment.
I confirmed with @allisonchou that this is only being called in unit tests,. so only when Razor updates to a new version of Roslyn will they need to update this.
| ExceptionStrategy = ExceptionProcessing.ISerializable, | ||
| }; | ||
|
|
||
| // Workspace listener events do not run in tests, so we manually register the lsp misc workspace. |
There was a problem hiding this comment.
Is that intentional? Is that something we can change?
There was a problem hiding this comment.
IIRC it is intentional, I think to prevent other things (like sln crawler) from automatically spinning up in tests. cc @tmat
to ensure that the lsp misc workspace it creates can use items from the host mef composition.
This fixes a bug where the LspMiscellaneousFIlesWorkspace was not registered because the LspWorkspaceRegistrationEventListener was not part of the default mef services.
Resolves #57243 as a side effect - no need to make it nullable when we reuse the correct host services from vs
Thanks @jasonmalinowski for the idea.
PR validation in progress to verify does not regress RPS