A C# toolkit for code generation using plain C# templates, offering a modern alternative to T4 with hybrid programmatic and markup approaches.
CodegenCS is a C# toolkit for code generation that allows developers to write templates in plain C# instead of specialized templating languages. It generates code in any language or text format, combining programmatic control with markup-like simplicity through string interpolation. The toolkit solves the complexity and maintenance issues of traditional code generators like T4 by leveraging familiar C# syntax and the full .NET ecosystem.
C# developers and .NET teams who need to automate code generation for tasks like generating POCOs from databases, creating API clients from OpenAPI specs, or producing configuration files. It's ideal for those seeking a modern, debuggable alternative to T4 templates.
Developers choose CodegenCS because it eliminates the learning curve of new templating languages, provides seamless debugging in Visual Studio, and offers automatic indentation control that avoids the whitespace issues common in other generators. Its hybrid model balances simplicity for straightforward templates with the power of full C# for complex logic.
C# Toolkit for Code Generation (T4 alternative!)
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Enables mixing programmatic C# logic with markup-like string interpolation, balancing power and maintainability for complex code generation tasks.
Preserves indentation intelligently across nested blocks and subtemplates, critical for languages like Python and avoiding whitespace issues common in other generators.
Leverages full .NET support, including dependency injection, async/await, and Visual Studio debugging, reducing boilerplate and enhancing developer experience.
Includes ready-to-use models like DatabaseSchema for reverse engineering and a cross-platform CLI for automation in CI/CD pipelines, speeding up common workflows.
Templates must be written in C#, requiring familiarity with .NET syntax and idioms, which can be a barrier for non-C# developers or teams using other languages.
For basic templating needs, the dependency on .NET runtime and the hybrid model's complexity might be excessive compared to lighter-weight alternatives.
While the CLI is cross-platform, the core reliance on .NET libraries and tooling makes it less attractive for projects outside the Microsoft ecosystem.
CodegenCS is an open-source alternative to the following products: