Site Archives C#
T4 Tutorial: Creating your first code generator
This is the first article in a series that introduces code generation using C# and Text Templates (also known as T4 Templates) in Visual Studio; explains how to create reusable templates and combine them in complex code generators.
Simplifying WCF: Using Exceptions as Faults
This article describes an overview of error handling in WCF, discusses its advantages and drawbacks and shows how to extend WCF to marshal .NET exceptions as SOAP faults. Ready-to-use source code and examples are available for download.
T4 template for generating SQL view from C# enumeration
Database tables often contain columns that store codes, or values with special meaning. In application code, these special values can be encapsulated as enumerations. This article demonstrates how to use T4 code generation templates and Visual Studio CodeModel API to generate SQL views that encapsulate the special values for use in SQL code.
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.
Find It Quickly
Find what you're looking for quickly by using our keyword search. Can't find it? Try our links below.


