Uncategorized Archive

T4 Template Design: Template Method


Template Method is one of T4 template design techniques that can be used to develop reusable templates. It encapsulates the main template as a method in a class feature block. Template parameters are defined as parameters of the method. The calling template uses an include directive to merge code of the template method with the code of the calling template and calls the method from a statement block.

T4 Template Design: Merged Template Class


Merged Template Class is one of T4 template design techniques that can be used to develop reusable templates. It uses class feature blocks to define parameters as fields or properties in the main template. The calling template uses an include directive to merge code of main template with the code of the calling template and assigns parameter values in a statement block.

Visual Studio Templates for T4


Musings about Visual Studio Templates. Includes links to articles about Visual Studio Templates and ready-to-use templates for T4 files.

T4 as a general-purpose .NET scripting engine


At first, I had a mixed reaction to Kirill’s new article about using T4 and JavaScriptCommentStripper to strip comments and non-significant white space from JavaScript files. The T4 template he created for this purpose was not a template at all - it had no text blocks, just code going through a directory and stripping comments […]

How to use T4 to generate strongly-typed navigation class in ASP.NET


In this article, Kirill Chilingarashvili demonstrates how to use a T4 template to generate a navigation class in ASP.NET. This class contains nested classes that represent folders and string constants that represent user control (.ascx) files in the application. Using such navigation class helps to avoid hard-coding file paths as string literals and since it […]

Understanding T4: <#@ include #> directive


This post describes the purpose and implementation mechanics of the T4 <#@ include #> directive.

Understanding T4: <#@ assembly #> directive


This post describes the purpose and implementation mechanics of the T4 <#@ assembly #> directive.

Understanding T4: <#@ import #> directive


This post describes the purpose and implementation mechanics of the T4 <#@ import #> directive.

Understanding T4: <#@ output #> directive


This post describes the purpose and implementation mechanics of the T4 <#@ output #> directive.

Understanding T4: <#@ template #> directive


This post describes the purpose and implementation mechanics of the T4 <#@ template #> directive.