Uncategorized Archive

T4 Toolbox


You may have noticed that in my last couple of articles about T4, the download links point to a CodePlex project called T4 Toolbox. This post describes what this project is about.

Recent blog posts about T4


July blogs posts about code generation with T4 text templates.

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 […]

Recent blog posts about T4


Recent blog posts about T4

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.