I recently went on an expedition for unit testing a fairly complex T4 class. I came to a major breakthrough, but I am afraid that the observed behavior can only be random (i.e. it may break in future versions of Visual Studio)
I basically have something like this:
MainTemplate.tt:
<#@ include file="generator.tt.cs" #>
And then in generator.tt.cs I have
//<
The observed behavior of this is that I can both use the declared classes, and from the T4 template AND compile the code file as usual. However, the comment prefix before the <#+ and #> tags for any specific behavior? Can I risk it in the future?
In addition, I tested this on both MonoDevelop and Visual Studio 2012. It works for both. Visual Studio 2008 compatibility is not important to me.
Earlz
source share