Introduction to Code Generation with T4 and Visual Studio

Abstract

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

Level

300

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 generating DELETE stored procedures (Demo)
  • Troubleshooting T4 errors (Demo)
  • Review of T4 processing directives

Resources

Download

Slides 
Source Code

Welcome

Thank you for taking the time to visit my site! If you are looking for information about T4, this article would be a good place to start.

If you like what you see on this site, take a minute to visit my company, Catapult Systems. Check out their services and ask how we can help you on your project. See you around!