Skip to content

Repository files navigation

SourceGen

SourceGen

A collection of C# Source Generators for compile-time code generation.

Packages

PackageDescription
NuGetIoC/DI registration source generator for Microsoft.Extensions.DependencyInjection.Abstractions
NuGetCLI tool for adding IoC attributes to existing projects

SourceGen.Ioc

A C# source generator that extends Microsoft.Extensions.DependencyInjection.Abstractions by generating registration code at compile time.

Compared to MS.E.DI

FeatureMS.E.DISourceGen.Ioc
Open GenericRuntime resolution only✅ Auto-discovers closed types from usage
Nested Open Generic✅ Auto-discovery + [IocDiscover]
Decorator Pattern✅ With type constraint validation
Field/Property/Method Injection[IocInject]
Lifecycle validationRuntime errors✅ Compile-time
Circular dependencyRuntime errors✅ Compile-time

Quick Start

dotnet add package SourceGen.Ioc
usingSourceGen.Ioc;usingMicrosoft.Extensions.DependencyInjection;publicinterfaceIMyService;[IocRegister<IMyService>(ServiceLifetime.Scoped)]internalclassMyService:IMyService;// Register in DI container
services.AddMyProject();// Generated extension method

Documentation

See full documentation for all features including defaults, keyed services, decorators, open generics, tags, modules, wrappers, factory/instance registration, and compile-time containers.

License

MIT

About

A collection of C# source generator for .NET project.

Topics

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

Used by

Contributors

Languages