Q:

T4 "header guard" for included files

I'm trying to write some nice and structured t4 for code generation. I decompose my logic into reusable functions and put them into separate files (just like "normal" code). The problem is I cannot include a common file since it will be included multiple times. 
For example, I have files 4 files: Core.tt, File1.tt, File2.tt and MainTemplate.tt.
Core.tt is inclued in both File1.tt and File2.tt. 
While File1.tt and File2.tt are included in MainTemplate.tt
When I want to generate output from MainTemplate.tt I get the following error:
Error   8   Compiling transformation: The type 'Microsoft.VisualStudio.TextTemplating62CD98C8FF0EB737CAFBD5ED17A158C3.GeneratedTextTransformation' already contains a definition for 'PropertyAttribute'

I guess, the reason is that Core.tt has been included twice. Is there a workaround for my problem? In c++ It's possible to add header guards: #ifndef xxx #define xxx #endif

A:

Unfortunately, I've not been able to work out a way to get this to work, as there are hard limitations about where you can use #define in C#, and the #include comes in too late in the code.
Your best bet at this point is to log a feature request on http://visualstudio.uservoice.com and try to drum up some support.
Personally, I'd love to get this feature into the product.

