I've just started playing with T4, as I eventually want to use it to generate POCO's that map to LINQ to SQL entity classes, but even the simplest example has me slightly confused. Some advice on what is happening, and some advice on some good reading would be greatly appreciated.
I am of the understanding that the following template should produce a file containing only the text Hello World!, but instead it produces a class that outputs the text Hello World! How do I get my plain and simple Hello World only file?
The template:
<#@ template language="C#"#>
<#@ output extension=".cs" #>
class HelloWorld
{
}
The output:
#line 1 "C:\Development\PocoGenerator\PocoGenerator\HelloWorld.tt"
[System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "10.0.0.0")]
public partial class HelloWorld : HelloWorldBase
{
public virtual string TransformText()
{
this.GenerationEnvironment = null;
this.Write("class HelloWorld\r\n{\r\n\r\n}\r\n\r\n");
return this.GenerationEnvironment.ToString();
}
}
#line default
#line hidden
This is followed by a relatively complex HelloWorldBase
class in the same output file. It seems to me that this is an intermediate class that is supposed to be used to generate the actual intended template realization, but what is supposed to happen to make that occur?