Ling.AutoInject provides attribute-driven dependency injection registrations plus a source generator that emits IServiceCollection extension methods for automatic registration.
- Attribute-based registration:
SingletonService,ScopedService,TransientService. - Compile-time source generator that emits a single extension method to register discovered services.
- Roslyn analyzers that validate attribute usage and
AutoInjectConfigvalues at design time. - Optional keyed service support when the DI abstractions package supports it.
- Configurable generated method, class and namespace via an assembly-level
AutoInjectConfigattribute. - Service replacement support: use
Replace = trueto replace existing registrations instead of skipping when a service is already registered. - Class-level customization via
AutoInjectExtensionsAttributefor control over method generation behavior, including optionalIConfigurationparameter support.
For detailed usage instructions, including installation, attribute-based registration, and more, see the package README.
- Build:
dotnet build - Test:
dotnet test - Source generator and analyzers live under
src/Ling.AutoInject.SourceGenerators.
- Attribute-driven Options registration: upcoming support will generate registrations and configuration binding for
IOptions<T>style options classes.
- Contributions are welcome. Please open issues or PRs and include tests for new behavior.