Thursday 20 May 2010

A T4 Generator Tool for VS Express

T4 stands for Text Templating Transformation Toolkit which is a transformation engine built into all VS studio editions. In a few words, you can write a text template file which consists of plain text and source code wrapped around the T4 language notation. The T4 notation is similar to the ASP.NET design page source code. You indicate directives by using <#@ tags, statements with <# tags, and expressions with <#= tags. Below is a simple T4 template.

<#@ template debug="true" language="C#v3.5"#>
<#@ Import Namespace="System.Linq" #>
<#@ Assembly Name="System.Core,Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" #>
<#@ output extension=".cs" #>
<# WriteLine(@"Hello World");#>