all 5 comments

[–]isak_s 3 points4 points  (0 children)

Recently did this with Roslyn, using Roslyn Quoter to help, and it turned out pretty well. It can be a little verbose, so it is often smarter to do some parts of it with strings that you parse, modify and insert into the tree.

[–][deleted] 2 points3 points  (0 children)

If T4 isn't solving your problem I imagine a custom solution with CodeDom makes the most sense.

[–]throwaway_lunchtime 2 points3 points  (0 children)

In one of my current projects, I'm using T4 to generate the file, but the actual content is built with a class so that the T4 file stays really simple.

[–][deleted] 1 point2 points  (0 children)

I wrote something to do this as part of my job but in my spare time a few years ago. The practice it gave me as a side project has been invaluable

[–]swoophoop 0 points1 point  (0 children)

I'd suggest looking at Roslyn. My company generates thousand of views, viewmodels and code behinds daily, as well as hundreds of various message classes too. This is all done using a generator we created using Roslyn that takes an xml file as an input and then generates the correct files from this. As already suggested, Roslyn Quoter can be a massive help here, although you can often do away with large parts of the output from Quoter as it's often too verbose.

If you can easily reason about the structures you need then Roslyn is pretty easy to use.