There's sort of a survivorship bias in play here, where you only noticed the brittle codegen being brittle.
A solution that does not need lots of boilerplate code would be even better, but codegen is still better than the makeshift code that it originally replaced.
This is totally a 'C' hacker's approach but it's not bad for some things - especially serialization and the like. But it will need some generic reference mechanism - as void * is used in 'C' - to work.
When it works, you forget that the only thing that computers understand is their native instruction set, and everything on top of that is built on some form of codegen. When it doesn't, you curse out the programmer who left you a pile of buggy scripts to maintain.