Visual Studio T4 (Text Template Transformation Toolkit) Files

T4 is a Visual Studio code-generation language which was introduced with Visual Studio 2005. T4 templates are used in the Entity Framework and MVC and can be useful for your own development purposes.

T4 is not tightly integrated into Visual Studio and there iss no item templates in File > New Item and no intellisense or syntax highlighting. To use T4 templates create a file with the extension .tt, add some text content, save the file, and then Visual Studio generates a code file from your template.

You can use complex logic by utilizing the T4 templating language to modify the output generated depending on various conditions. T4 templates in Visual Studio 2010 are compiled saved, thus they are essentially an additional type that can be instantiated in code. Scott Hanselman wrote a very good roundup of this in his article at www.hanselman.com/blog/T4TextTemplateTransformationToolkitCodeGenerationBestKeptVisualStudioSecret.aspx

To enable Intellisense for T4 templates you will need to download and install the Tangible T4 plugin at
http://visualstudiogallery.msdn.microsoft.com/en-us/60297607-5fd4-4da4-97e1-3715e90c1a23.

The definitive online guide for T4 information is at http://www.olegsych.com/2007/12/text-template-transformation-toolkit/


Array

No comments yet... Be the first to leave a reply!