Investigate Support for Source Generator Based Dependency Injection in ASP.NET Core #62104
Labels
NativeAOT
needs-area-label
Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically
Is your feature request related to a problem? Please describe the problem.
Currently, Microsoft.Extensions.DependencyInjection uses runtime reflection for dependency resolution, which introduces startup overhead and can present challenges for AOT (Ahead-Of-Time) scenarios (e.g., NativeAOT, Blazor WebAssembly). Community libraries such as Jab, ThunderboltIoc, and SourceInject demonstrate that C# source generators can provide compile-time DI containers that are significantly faster and more AOT-friendly.
Describe the solution you'd like
Investigate and consider implementing support for source generator-based dependency injection in ASP.NET Core. This could involve providing an official Roslyn-based source generator or a pluggable system, allowing developers to benefit from:
Describe the alternatives you've considered
Alternatives include continuing with the current reflection-based system or using third-party libraries, but these lack official integration and may not support all ASP.NET Core patterns. Adopting a hybrid approach or providing extensibility points for DI source generators are also possible solutions.
Additional context
The text was updated successfully, but these errors were encountered: