Blog Logo
TAGS

AutoCtor - Roslyn Source Generator for Constructor Dependency Injection

AutoCtor is a powerful Roslyn Source Generator that automatically creates a constructor for your class, which can be used with constructor Dependency Injection. It generates constructors that include all the necessary parameters for your class, making Dependency Injection a breeze. With AutoCtor, you can also initialize readonly fields, and the tool will not include them in the constructor. Additionally, if there is a single base constructor with parameters, AutoCtor will include that base constructor in the constructor it creates. It is also possible to embed the `[AutoConstruct]` attribute directly in your project, and if you wish to preserve these attributes in the build output, you can define the `AUTOCTOR_USAGES` MSBuild variable. Get started with AutoCtor by visiting the NuGet packages for more information and examples. Lets make dependency injection easy and fun!