Code Generation with T4 Text Templates: Introduction

Code Generation with T4 Text TemplatesAbstract

Why write repetitive code when you can generate it? Learn about Text Template Transformation Toolkit (T4) - one of the best-hidden new features of Visual Studio 2008. T4 allows you to use simple ASP.NET-like template syntax to generate application source code, configuration files, stored procedures and more. This session provides an overview of code generation, describes T4 template syntax and shows how to create a template for generating CRUD stored procedures.

Duration

60 minutes

Outline

  • Why Generate Code?
    • Improve Developer Productivity
    • Improve Code Quality
    • Synchronize Multiple Source Files
  • What is T4?
    • Template Syntax
    • Transformation Process
    • Statement Blocks
    • Expression Blocks
    • Class Feature Blocks
  • T4 template for DELETE stored procedure(Demo)
  • Troubleshooting T4 errors
    • Template parsing and compilation errors (Demo)
    • Runtime template errors (Demo)
    • Debugging templates (Demo)

Resources

Download

Slides 
Source Code