Uncategorized Archive
T4: Extending the Generated Template Class by Mike Pagel
Mike Pagel recently posted an interesting article about T4 on CodeProject called “T4: Extending the Generated Template Class“. In this article, Mike describes several approaches for implementing code generation logic - helper methods defined in class feature blocks, custom directive processors and a custom TextTransformation base class referenced using the inherits attribute of the template […]
Test runner for T4 unit tests
This post shows how to create unit tests that run during T4 template transformation. This approach allows creating automated tests for template code that relies on specific capabilities of a T4 host, such as access to Visual Studio extensibility APIs. The post includes a ready to use test runner for T4 unit tests.
T4 Template for Generating ADO.NET Entity Framework Stored Procedures
David DeWinter posted a great article about using T4 to generate stored procedures for ADO.NET entity data models. It includes a ready to use T4 template that will generate stored procedures for every .EDMX file in a given directory.
T4 Template Design: Nested Template Class
Nested Template Class is one of T4 template design techniques that can be used to develop reusable templates. The main template is defined as a nested TextTransformation class inside of a class feature block.
T4 Template Design: Standalone Template
Standalone Template is one of T4 template design techniques that can be used to develop reusable templates. The using template uses T4 engine to compile the main template into a separate assembly and run the compiled code independently of the using template.
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 […]
Find It Quickly
Find what you're looking for quickly by using our keyword search. Can't find it? Try our links below.


