Is there any way to have functions in basic T4 templates?
You mean like this: <#+ public List<string> Dostuff() { List<string> result = new List<string>(); // … return result; } #> Here’s a complete example: Reading a Xml File in T4 Templates Oleg Sych’s T4Toolbox is a good resource.