Re: In praise of T4 code generation
I gave up on T4 in frustration a long time ago. We use CodeSmith - we find it easy to use and quick to get things done. Having read this, might look at T4 again now and see if it's improved. On 12 October 2013 18:14, Greg Keogh g...@mira.net wrote: Folks, A few years ago I wrote (or rewrote) a quite large WPF Desktop app, it's my hobby app like a lot of us have. It maintains RDB tables of the music, books, video, etc in the household. This app was started in Access 2.0 back in 1992 and I think it's gone through at least 6 generations of rewrites since then due to the ever-changing languages, platforms, kits and frameworks. The last incarnation of the app took several months of spare time to get into a good working condition, but by the time it was nearly finished it was obsolete. A few months ago I started a new rewrite using the latest Entity Framework, lots of WPF binding and recent groovy techniques and tools. 14 underlying tables are editable, and by some unimaginable effort in previous years I managed to hand code (with lots of copy and paste) grids and dialogs for all of the tables, all similar but slightly different. In the latest rewrite I just couldn't face migrating or writing 14 sets of grids and editors again, so I decided to use T4 templates to generate it all. I'm really happy with the results and this post is basically just a reminder that in my opinion, good old fashioned code generation still has a place in the modern world. I composed an XML document describing the attributes of every table and field and then used TT files to generate the grid xaml, grid code, dialog xaml, dialog code, ICommand definitions and handlers, controllers, and validation. It's a slog to get the infrastructure started, but once it's going it just spits out reliable working code like confetti. As you make improvements in the templates it's most gratifying to see the benefits magnified out over the generated code. I find the T4 Toolkit a bit fiddly to use and generate multiple files, so I found this: https://github.com/damieng/DamienGKit I'm impressed by this concise and convenient utility that helps you spit out multiple files from a single template. Greg K
Re: In praise of T4 code generation
I gave up on T4 in frustration a long time ago. We use CodeSmith - we find it easy to use and quick to get things done. Having read this, might look at T4 again now and see if it's improved. I'm actually a licensed owner of CodeSmith 5.2, which I purchased a few years ago so I could use it with netTiers. However, all of the fancy bells and whistles and advanced features that came with it were of absolutely no interest to me. I have never used CodeSmith for anything (except it being the silent clockwork behind netTiers). For a start, I hated having yet another dependency on a 3rd party tool, then I would have to learn how it integrates with Visual Studio (I assume it does!), then learn its quirks, etc. I prefer TT files simply because they are built-in and just work. I don't think T4 has improved much in recent years, it's still the same basic tool. Greg K
Re: In praise of T4 code generation
Greg, I love T4 as well. A Massive part of my project is build around very custom T4 code generation that was all nicely coded to output very good, reliable and repeable bits of code that helps us mostly around some complex serializations. It would be great it VS would include a nice T4 editor by default as the Tangible T4 editor kills my VS every time I try to load it due maybe to the large number of objects we have. Apparently there are few other editors for T4 these days. I might try them again. On Mon, Oct 14, 2013 at 12:36 PM, Greg Keogh g...@mira.net wrote: I gave up on T4 in frustration a long time ago. We use CodeSmith - we find it easy to use and quick to get things done. Having read this, might look at T4 again now and see if it's improved. I'm actually a licensed owner of CodeSmith 5.2, which I purchased a few years ago so I could use it with netTiers. However, all of the fancy bells and whistles and advanced features that came with it were of absolutely no interest to me. I have never used CodeSmith for anything (except it being the silent clockwork behind netTiers). For a start, I hated having yet another dependency on a 3rd party tool, then I would have to learn how it integrates with Visual Studio (I assume it does!), then learn its quirks, etc. I prefer TT files simply because they are built-in and just work. I don't think T4 has improved much in recent years, it's still the same basic tool. Greg K
Re: In praise of T4 code generation
I love T4 as well. Thank heavens, I was starting to think I was a deviant. The first Tangible addons occasionally crashed on me too, but for the last year or more I've been keeping updated and can't recall any problems in that time, but, my demands are probably modest compared to yours -- Greg