2

I am trying to implement a T4 template to generate some redundant csharp code. My template gets object type passed in as following GenericTextFormatter<<#=type>> where type is typeof(objectA) etc. So I expected generated output of GenericTextFormatter<ObjectA> however the template is having trouble displaying the outer angled brackets and, instead, I see no output for this part.

eYe
  • 1,695
  • 2
  • 29
  • 54
  • t4 is _text_ template, so you should pass to output not `type` object, but type name, or type full name – Grundy Nov 02 '15 at 18:06
  • The problem is described above with the code that is causing my problem. I am sure someone knowledgeable with T4 templates must have seen this before. – eYe Nov 03 '15 at 14:01

1 Answers1

3

You forgot the closing #. Try GenericTextFormatter<<#=type #>>.

As a reference, the following t4 code outputs List<System.String>:

<#@ template debug="false" hostspecific="false" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ output extension=".txt" #>

<#
    var type = typeof(string);
#>

List<<#= type #>>
Shlomo
  • 14,102
  • 3
  • 28
  • 43