This question specifically refers to ASP.NET core 3.1 and the built-in dependency injection container (Microsoft DI).
This Microsoft documentation and this stackoverflow question confirm that the Microsoft DI container always resolves IEnumerable<TService> by respecting the registration order, when multiple implementation types are registered for the same service type. The order is guaranteed and this is clearly documented.
Does anyone know whether the same holds true for the IServiceProvider.GetServices<T>() method ?
If the answer to the above question is yes, does this holds true even in the following example (where two different instances of the same class are registered as implementations for the same service type) ?
public interface IService {}
public sealed class Foo : IService {}
var foo1 = new Foo();
var foo2 = new Foo();
services.AddSingleton<IService>(foo1);
services.AddSingleton<IService>(foo2);
var implementations = serviceProvider.GetServices<IFoo>();
// is it guaranteed that implementations[0] == foo1 and implementations[1] == foo2 ???