🏷️
Attribute-Only Registration
Register services with [Injectable] and [ServiceInjection] without marker interfaces or runtime reflection.
⚡
NativeAOT Focus
Generated constructors and init-property injection are designed for trimming and NativeAOT publish scenarios.
📐
Deterministic Ordering
Control precedence with Group and Order, with a stable ordinal service-name fallback for predictable pipelines.
🧪
Coverage Control
Use [assembly: GenDICoveration(...)] to include or exclude generated extension code in coverage reports.
🧩
Generator + Microsoft DI
Generated AddGenDIServices() integrates directly with Microsoft.Extensions.DependencyInjection.
✅
Validation Projects Included
Repository includes source-generator tests, real integration tests, trim publish tests, and NativeAOT publish tests.
Quick Example
[assembly: GenDI.GenDICoveration(true)]
[ServiceInjection]
public interface IMyService { }
[Injectable<IMyService>(ServiceLifetime.Singleton, Group = 10, Order = 1)]
public sealed class MyService(IDependency dep) : IMyService
{
[Inject]
public required IOtherService OtherService { get; init; }
}
services.AddGenDIServices();