T4 Support in VS2008

Did you know there's T4 (Text Template Transformation Toolkit) support inside VS2008 now? Add a file with the .tt or .t4 extension to your project and you got a T4 template which VS2008 will automatically run when you save it. If you're into this and want to try it out, go to http://www.t4editor.net/ and download the T4-editor from Clarius. It gives you proper editing support from within Visual Studio. They got a version for vs2003 as well.

This may not be as attractive as it used to be, now that we got designer tools for Linq to Sql, entity framework and so on to help us generate boilerplat code for database access, but I'm sure I can come up with some good use for this. The ASP3-like syntax is very easy to grasp, so basically there is no excuse for not using this if you know you're going to produce lots of code that looks or behaves the same. As long as you have some metadata to work from, be it a database, xml file or text file, I'm sure this can be of help to you. Ah yes, you can write the templates in either c# or VB.

Some T4 resources for you maybe:

Hilton Giesenow blogs about T4 and you can download a couple of VS T4 templates from him!

Oleg Sych has a large number of very, very good blog posts about T4, Oleg is THE T4 blogger out there.

The T4-editor website by Clarius has a couple of videos.

The Text Template documentation for vs2008 on MSDN.

On MSDN there's also a good intro video on the topic that you might want to look at if this is of interest to you.

No Comments