© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago
palapapa

✅ How does the implementation of `IServiceProvider.GetServices` work?

In https://source.dot.net/#Microsoft.Extensions.DependencyInjection.Abstractions/ServiceProviderServiceExtensions.cs,ed6b36f4cd78b748, you can see that it only calls
GetRequiredService
GetRequiredService
with
IEnumerable<T>
IEnumerable<T>
, which then calls
GetService
GetService
. There is nothing in the contract of
IServiceProvider
IServiceProvider
that says if you pass an
IEnumerable<T>
IEnumerable<T>
as the service type to
GetService
GetService
, it would return a
IEnumerable
IEnumerable
of all registered services. Does this mean that
GetServices
GetServices
only works with the internal implementation of
IServiceProvider
IServiceProvider
by MS?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ How does the main method work?
C#CC# / help
3y ago
How to find the implementation of Math. functions
C#CC# / help
4y ago
❔ IServiceProvider, scoped services, scopes
C#CC# / help
3y ago
How does marshalling work?
C#CC# / help
5mo ago