I've found that static metaprogramming produces an odd middle-ground. The intermediate code can be wonderfully legible and this lets you quickly find bugs... but when it comes time to fix the bug you have to go into the original generating code and then you find an absolute horror.
Visual Studio doesn't exactly treat T4 as a first-class language, which is a shame. Debugging it is much harder than it should be. I've found that it's frankly easier just to write your code generation in C# itself as an extra build phase.
In this case I'm referring to C# T4.