
{"id":498,"date":"2010-05-17T15:22:46","date_gmt":"2010-05-17T19:22:46","guid":{"rendered":"http:\/\/www.ikriv.com\/blog\/?p=498"},"modified":"2010-05-17T15:22:46","modified_gmt":"2010-05-17T19:22:46","slug":"t4","status":"publish","type":"post","link":"https:\/\/ikriv.com\/blog\/?p=498","title":{"rendered":"T4 \u2013 Too Troublesome to Tackle?"},"content":{"rendered":"<p><a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/bb126445(VS.80).aspx\"> Text Template Transformation Toolkit<\/a> (T4) is a code generator built into Visual Studio 2008 and 2010. Yes, you have it now on your machine \ud83d\ude42  It was proposed to me as a possible solution to the <a href=\"http:\/\/www.ikriv.com\/blog\/?p=445\">C# macros<\/a> problem.<\/p>\n<p>I played with it a little bit and my current verdict is it would be quite difficult to use in a serious project. Here&#8217;s why:<\/p>\n<p><b>1. No automated build integration.<\/b> 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 <code>foobar.tt<\/code> has changed and there are 50 files that include <code>foobar.tt<\/code>, you will have to hunt them down, open them in Visual Studio and save them to re-generate the code. That&#8217;s 51 files.<\/p>\n<p>This is not T4&#8217;s fault per se &#8211; all custom tools suffer from this problem, but it does not make developer&#8217;s life any easier. There is some <a href=\"http:\/\/www.olegsych.com\/2010\/04\/understanding-t4-msbuild-integration\/\">build integration<\/a> in VS 2010, but &#8220;<quote>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<\/quote>&#8220;. Not cool.<\/p>\n<p><b>2. No proper source control integration.<\/b> 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.<\/p>\n<p><b>3. No ability to group all files of a class under one node.<\/b> This is not a show stopper, but an inconvenience. I would like to have all code for class <code>Foo<\/code> to be under one node. Something like <code>Foo.cs<\/code> with <code>Foo.props.tt<\/code> below it, which generates <code>Foo.props.cs<\/code>. I am not sure how it can be accomplished with TT.<\/p>\n<p>See also:<br \/>\n<a href=\"http:\/\/www.olegsych.com\/2007\/12\/text-template-transformation-toolkit\/\">T4: Text Template Transformation Toolkit (Oleg Sych blog)<\/a><br \/>\n<a href=\"http:\/\/www.olegsych.com\/2010\/04\/understanding-t4-msbuild-integration\/\">Understanding T4-MSBuild integration<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Text Template Transformation Toolkit (T4) is a code generator built into Visual Studio 2008 and 2010. Yes, you have it now on your machine \ud83d\ude42 It was proposed to me <a href=\"https:\/\/ikriv.com\/blog\/?p=498\" class=\"more-link\">[&hellip;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"Layout":"","footnotes":""},"categories":[4],"tags":[],"class_list":["entry","author-ikriv","post-498","post","type-post","status-publish","format-standard","category-hack"],"_links":{"self":[{"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/498","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=498"}],"version-history":[{"count":0,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/498\/revisions"}],"wp:attachment":[{"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=498"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=498"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=498"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}