Click here to Skip to main content
Click here to Skip to main content
Technical Blog

T4 – Too Troublesome to Tackle?

, 18 May 2010 Apache
Rate this:
Please Sign up or sign in to vote.
T4 – Too Troublesome to Tackle?

Text Template Transformation Toolkit (T4) is a code generator built into Visual Studio 2008 and 2010. Yes, you have it now on your machine :). It was proposed to me as a possible solution to the C# macros problem.

I played with it a little bit and my current verdict is it would be quite difficult to use in a serious project. Here’s why:

  1. No automated build integration

    This is a killer, especially if your templates include other templates. The only time template code is executed is when you save a template file. Not when you (re)build your solution. Not when you get your stuff from source control. If foobar.tt has changed and there are 50 files that include foobar.tt, you will have to hunt them down, open them in Visual Studio and save them to re-generate the code. That’s 51 files.

    This is not T4’s fault per se – all custom tools suffer from this problem, but it does not make the developer’s life any easier. There is some build integration in VS 2010, but “ in order to configure a Visual Studio project for build-time template transformation, you have to manually modify the MSBuild definition in the project file“. Not cool.

  2. No proper source control integration

    When you add your .tt file to source control, the generated file is added along with it, and every time you change anything, both files get checked out.

  3. No ability to group all files of a class under one node

    This is not a show stopper, but an inconvenience. I would like to have all code for class Foo to be under one node. Something like Foo.cs with Foo.props.tt below it, which generates Foo.props.cs. I am not sure how it can be accomplished with TT.

See also:

License

This article, along with any associated source code and files, is licensed under The Apache License, Version 2.0

Share

About the Author

Ivan Krivyakov
Technical Lead Thomson Reuters
United States United States
Ivan is a hands-on software architect/technical lead working for Thomson Reuters in the New York City area. At present I am mostly building complex multi-threaded WPF application for the financial sector, but I am also interested in cloud computing, web development, mobile development, etc.
 
Please visit my web site: www.ikriv.com.

Comments and Discussions

 
GeneralDepends on your point of view... PinmemberDave Elliott20-May-10 8:28 
GeneralRe: Depends on your point of view... PinmemberIvan Krivyakov24-May-10 17:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.141216.1 | Last Updated 18 May 2010
Article Copyright 2010 by Ivan Krivyakov
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid