Visual Studio Templates for T4


Add New Item DialogIf you have been following my series of posts about T4 text templates, you probably noticed that we have to create T4 templates as text files with a special (.tt) extension. There is no template in the Add New Item dialog of Visual Studio to create a T4 file. As silly as it sounds, I think this may be the reason few people know about T4. After all, who has the time to go through all of the information about new features added to Visual Studio 2008? Even if T4 was listed there, chances are it wouldn’t get much attention compared to the big features like LINQ and AJAX.

Ironically and similar to T4, Visual Studio templates are also little known because Export Template wizard is not available in Visual Studio main menu by default.

I learned about (existence of) Visual Studio templates several years ago, but had no pressing need to use them until I started working with T4. I had this in the back of my mind for several months until, a few weeks ago, Hilton Giesenow wrote a great post about T4 Template Items. Hilton created a set of simple Visual Studio Templates for T4, which you can copy to the My Documents/Visual Studio 2008/Templates/Item Templates folder on your computer and make T4 project items show up in the Visual Studio Add New Item dialog.

Staying true to the not invented here spirit, I thought I could build a better mouse trap. In particular, take advantage of Visual Studio template parameters, use a matching icon and a more useful T4 boilerplate file. So here it is: Code Generation with Visual Studio Templates.

Here is another amusing thing you may have noticed. Four months I joked about "software factory factories" and suggested T4 as an alternative to overengineered frameworks. And here I am, writing an article about creating a "text template template". This is the sort of thing that makes you wonder how long it will take me go to the dark side and start blogging about Domain Specific Languages.

 

Information and Links

Join the fray by commenting, tracking what others have to say, or linking to it from your blog.


Other Posts
Code Generation with Visual Studio Templates
March meeting of Tampa Bay IASA chapter

Write a Comment

Take a moment to comment and tell us what you think. Some basic HTML is allowed for formatting.

Reader Comments

Be the first to leave a comment!