Rename LSP GetRequiredServices -> GetServices#83995
Draft
dibarbet wants to merge 2 commits into
Draft
Conversation
9f67d13 to
f2eadc2
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the LSP service retrieval API to use GetServices<T>() (instead of GetRequiredServices<T>()) for fetching multiple services, aligning the method name with the fact that the returned sequence may be empty.
Changes:
- Renamed
ILspServices.GetRequiredServices<T>()toILspServices.GetServices<T>()and updated implementations. - Updated LSP framework/protocol call sites to use the new
GetServices<T>()API. - Cleaned up example/test implementations to match the renamed interface method.
Show a summary per file
| File | Description |
|---|---|
| src/LanguageServer/Protocol/LspServices/LspServices.cs | Renames multi-service enumeration API and updates GetService<T>() to call GetServices<T>(). |
| src/LanguageServer/Protocol/Handler/RequestContext.cs | Updates RequestContext.GetRequiredServices<T>() to delegate to _lspServices.GetServices<T>(). |
| src/LanguageServer/Protocol/DefaultCapabilitiesProvider.cs | Switches capability computation to use GetServices<ITextDocumentContentProvider>(). |
| src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/ILspServices.cs | Renames interface method from GetRequiredServices<T>() to GetServices<T>(). |
| src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/HandlerProvider.cs | Updates handler discovery to use GetServices<IMethodHandler>(). |
| src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/AbstractLanguageServer.cs | Updates shutdown/exit hook enumeration to use GetServices<IOnServerShutdown>(). |
| src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework.UnitTests/Mocks/TestLspServices.cs | Updates test mock API surface to implement GetServices<T>(). |
| src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework.Example/ExampleLspServices.cs | Removes the now-nonexistent GetRequiredServices<T>() member; keeps GetServices<T>(). |
| src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/BrokeredServices/ServiceBrokerFactory.cs | Updates initializer retrieval to use GetServices<IServiceBrokerInitializer>(). |
Copilot's findings
- Files reviewed: 9/9 changed files
- Comments generated: 1
Comment on lines
+107
to
+110
| // If given an interface, query for a service that implements that interface (this is how GetRequiredServices works) | ||
| // Only allow this if there is exactly one service that implements the interface. | ||
| return type.IsInterface | ||
| ? GetRequiredServices<T>().SingleOrDefault() | ||
| ? GetServices<T>().SingleOrDefault() |
dibarbet
commented
Jun 4, 2026
Comment on lines
359
to
367
| public T GetRequiredService<T>() where T : class | ||
| { | ||
| return _lspServices.GetRequiredService<T>(); | ||
| } | ||
|
|
||
| public IEnumerable<T> GetRequiredServices<T>() where T : class | ||
| { | ||
| return _lspServices.GetRequiredServices<T>(); | ||
| return _lspServices.GetServices<T>(); | ||
| } |
JoeRobich
approved these changes
Jun 5, 2026
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.
Better matches the actual functionality
Microsoft Reviewers: Open in CodeFlow