I don’t want to speak too soon, but I’ve addressed a similar issue in .NET and started developing a simple DSL to tackle it. Currently, it offers the bare minimum for C# code generation with basic MSBuild integration.
The development is private for now, and the project is named Typr. (I considered Type-R as well, but opted for the shorter name.)
There are dozens of ways to approach type generation: Reflection and IL-based emitters, source generators, template-based solutions, GraphQL-based SDKs, and even language features like record types1 can play a role.
Honestly, I could’ve picked one of the existing tools—but creating your own syntax opens the door to expressing domain logic in a more readable, declarative form, enabling easier code generation, transformation, or even simulation workflows.
This post is a brief introduction to Domain-Specific Languages (DSLs), focusing on designing your own syntax and grammar, and integrating that into .NET build steps.
1// Types.typ
2Todo {
3 Id int
4 Title string
5}
6
7Product {
8 Name text,
9 QuantityPerUnit money,
10 UnitPrice money,
11 Discontinued yn
12}