- The
Person.cs
file can be thought of as the input. - The
EqualityClassTemplate.tt
acts as a template. You have to import it in a separate.tt
file to generate a class. - The
EqualityPerson.tt
is a template which callsEqualityClassTemplate.tt
, passing in arguments, and producesEqualityPerson.cs
as its output.
Make sure to blank out the "Custom Tool" property of the file.
To change this property, click on the file in the Solution Explorer and go to the properties window.
In order to have this.Host
reference in the .tt
file (it is being used in EqualityClassTemplate.tt
), you have to set hostspecific
to true
at the top of the .tt
file:
<#@ template debug="false" hostspecific="true" language="C#" #>
Since I am using Tangible's T4 Editor, it does not provide full code completion (you have to pay for it).
An easy workaround is to create a new C# console project and add the EnvDTE
assembly. Then you can use code like so to check the what properties exist on the interfaces:
var dte = null as EnvDTE.DTE;
- Creating Mixins with T4 in Visual Studio - the inspiration for this project
- Generating async WCF OperationContract signatures with a T4 template - source for the code of such methods as
GetEnvDTE
. - Project Metadata Generation using T4 - shows a different way to generate classes using T4