On the IServiceCollection the provided methods for registring services AddTransiet, AddScoped, AddSingleton do not allow you the use of async-await construct when you have to retrieve a service by computing some of its steps.
I want to know if making an async version would be a valid approach.
internal static IServiceCollection AddScopedResolveAsync<TService>(this IServiceCollection serviceCollection, Func<IServiceProvider, Task<TService>> func)
=> serviceCollection.AddScoped(func);
and then use it
services.AddScopedResolveAsync<IMyService>(async serviceProvider =>
{
await something;
return new MyService();
});