This is a mirror of official site: http://jasper-net.blogspot.com/

More T4

| Tuesday, April 13, 2010
T4 (Text Template Transformation Toolkit) is a code generator integrated on Visual Studio. Hmmm CodeSmith? ;-)

Creating and editing a T4 Template
Steps

   * Add a Text File
   * Rename with a .tt extension
   * Write T4 template header configuration and template code


<#@ template language="C#v3.5" #>
<#@ import namespace = "System.Text.RegularExpressions" #>
<#@ output extension=".cs" #>

<#
string lTitle = "MyHelloWorldClass";
#>

namespace MyProject.Test
{
   public class <#=lTitle #>
   {
       public <#=lTitle #>()
       {
       }
   }
}

Actually EF (Entity Framework) uses T4 to customize your EF generated classes.

Tools
Tangible Engineering offer a T4 Editor (Free or Pro versions) to integrate on Visual Studio with intellisense.

Read more: Refact your C# Code

Posted via email from jasper22's posterous

0 comments: