Description
The release of .NET 8 allowed to register services using an optional key. When doing so, the only way to retrieve the service is by using the GetKeyedService methods.
I would expect the GetServices<T> method to also return this keyed service
Reproduction Steps
The following test fails:
var provider = new ServiceCollection()
.Add<Car, FastCar>("KeyedCar")
.BuildServiceProvider();
var registeredCars = provider.GetServices<Car>().ToList();
Assert.AreEqual(1, registeredCars.Count);
Expected behavior
The GetServices<T>(this IServiceProvider provider) method should return all registered implementations of T not matter if they have been registered with a key or not
Actual behavior
The GetServices<T>(this IServiceProvider provider) method only returns services that have been registered without a key
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response
Description
The release of .NET 8 allowed to register services using an optional key. When doing so, the only way to retrieve the service is by using the
GetKeyedServicemethods.I would expect the
GetServices<T>method to also return this keyed serviceReproduction Steps
The following test fails:
Expected behavior
The
GetServices<T>(this IServiceProvider provider)method should return all registered implementations ofTnot matter if they have been registered with a key or notActual behavior
The
GetServices<T>(this IServiceProvider provider)method only returns services that have been registered without a keyRegression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response