This is fascinating! Code generation is a thing that's solved a couple problems for me recently. The way I do it never feels great. Whenever I want to cache a big dictionary literal, I tend to generate the code as a string and write it to a file. I've yet to find a compelling upgrade that checks all the boxes. (The generated side has run in the kneecapped .net for unity, although the generator doesn't necessarily.)
I'm going to dig into your implementation.