Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News Multiple Output Files using T4

Multiple Output Files using T4

Leia em Português

This item in japanese

T4 is Visual Studio’s built-in code generator. Though fundamental for many of the frameworks built atop .NET, it is none the less incredibly under-powered. Even the simplest things like intelligently reusing templates or emitting multiple files seem beyond it at first glance. Yet developers are finding of ways to incrementally improve it. One such developer, Damien Guard, has built an extension to solve the multiple-output limitation.

Damien Guard’s Manager class takes over control of rendering the output so that it can be split into multiple files. Implemented as a template file itself, it is both easy to understand and yet quite clever. Out of the box it supports useful things like common headers and footers that are applied to all files in the set.

Damien recently published an improved version of his manager class. The most important change is its improved support for source control. It will now check to see if files have changed before writing them to disk. If a file has changed, it will be automatically checked out. There are also some internal improvements to reduce conflicts with other plugins that may be watching for changing files.

Rate this Article