[API Proposal]: AutoActivation should support async initialization
- Dominant language
- C#
- Stars
- 3.2k
- Forks
- 894
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 23
Description
### Background and motivation
If you are using auto activation you would likely need some logic to run upon activation that could potentially require async code.
### API Proposal
```csharp
namespace Microsoft.Extensions.DependencyInjection;
public interface IAsyncAutoActivation : IAsyncDisposable
{
Task OnActivationAsync();
}
```
### API Usage
```csharp
class MySingleton : IAsyncAutoActivation { .. }
services.AddActivatedSingleton();
```
### Additional considerations
Async activations should not block each other, that is, they would run concurrently.
There's also the question of how to handle failed tasks which I think it should **prevent the application from running**.
Contributor guide
Assessment
This issue has not been assessed yet.