4 ms·
Surprised it's not more well-known but Visual Studio (MSBuild really) has had support for this kind of code generation for a while, it's called T4 (probably in
by speps 3y ago
Surprised it's not more well-known but Visual Studio (MSBuild really) has had support for this kind of code generation for a while, it's called T4 (probably in reference to the GNU M4 utility).
It can be used to generate files on save as well, so as the template is edited, it updates the output files automatically.
[0] https://learn.microsoft.com/en-us/visualstudio/modeling/design-time-code-generation-by-using-t4-text-templates https://learn.microsoft.com/en-us/visualstudio/modeling/desi...
- mjd 3y agoJust FYI, m4 was in the original Unix in 1977, years before the GNU project began. (It was invented by Kernighan and Ritchie.) Thanks for the VS tip.
- _a_a_a_ 3y agoI needed code generation for C# and looked at T4, decided it was less capable than M4 (and obviously less portable, a big plus for Microsoft in tying you into their environment) and went with python instead. That was a while back, maybe T4 has improved but I still wouldn't use it.