Chapter 4: Transforming Text Templates

In This Chapter

check.png Discovering where templating for Visual Studio originated

check.png Defining a user case for T4

check.png Getting your environment ready for T4 use

check.png Using T4 like a language

T4 (Text Template Transformation Toolkit) is a code-generation toolkit built into Visual Studio. It is a built-in language used to make the default ASP.NET and Windows Forms files in C# or VB (for example, when you use the Add New Item feature).

Scott Hanselman, from Microsoft, said it best: “Now’s the time to introduce code generation to your company.” I wholeheartedly agree. Code generation increases developer productivity, decreases bugs in final versions, and makes people happy.

Lars Corneliussen, a Microsoft MVP, said, “T4 in VS is the equivalent to index.php in Apache,” and he isn’t far from the truth. T4 is a starting point for a project, providing seamless redirection and logical formatting of what the user (in this case, the developer) actually sees. It is the template, just as its name suggests.

T4 is a big topic, like so many others in this book, but you should be ...

Get C# 5.0 All-in-One For Dummies now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.