Skip to content

Rename LSP GetRequiredServices -> GetServices#83995

Draft
dibarbet wants to merge 2 commits into
dotnet:mainfrom
dibarbet:update-lsp-services
Draft

Rename LSP GetRequiredServices -> GetServices#83995
dibarbet wants to merge 2 commits into
dotnet:mainfrom
dibarbet:update-lsp-services

Conversation

@dibarbet
Copy link
Copy Markdown
Member

@dibarbet dibarbet commented Jun 3, 2026

Better matches the actual functionality

Microsoft Reviewers: Open in CodeFlow

@dibarbet dibarbet force-pushed the update-lsp-services branch from 9f67d13 to f2eadc2 Compare June 3, 2026 23:17
@dibarbet dibarbet marked this pull request as ready for review June 4, 2026 00:42
@dibarbet dibarbet requested a review from a team as a code owner June 4, 2026 00:42
Copilot AI review requested due to automatic review settings June 4, 2026 00:42
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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>() to ILspServices.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()
Comment thread src/LanguageServer/Protocol/LspServices/LspServices.cs Outdated
Copilot AI review requested due to automatic review settings June 4, 2026 01:01
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot's findings

  • Files reviewed: 9/9 changed files
  • Comments generated: 2

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>();
}
@dibarbet dibarbet marked this pull request as draft June 4, 2026 01:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants