preprocessed generators problem with t4toolbox ?

Sep 25, 2011 at 7:48 AM
Edited Sep 27, 2011 at 8:45 AM

I'm trying to generate some code via preprocessed generators , I use t4toolbox.tt in my tt file but i get the error "Method must have a return Type".

this is my tt code :

<#@ template hostspecific="true" language="C#" debug="true" #>
<#@ import namespace = "System.Reflection" #>
<#@ output extension=".text" #>
<#@ include file="T4Toolbox.tt" #>
<#@ import namespace="EnvDTE" #>
<#@ parameter name="EnumFileName" type="System.String" #>
<#
CodeEnum enumeration = GetEnum(EnumFileName);
  WriteLine("Found enumeration " + enumeration.Name);
  foreach (CodeElement element in enumeration.Children)
  {
    CodeVariable value = element as CodeVariable;
    if (value != null)
      WriteLine("… found value " + value.Name);
  }
#>
<#+
private CodeEnum GetEnum(string enumFile)
  {
    ProjectItem projectItem = TransformationContext.FindProjectItem(enumFile);
    FileCodeModel codeModel = projectItem.FileCodeModel;
    return FindEnum(codeModel.CodeElements);
  }
private CodeEnum FindEnum(CodeElements elements)
  {
    foreach (CodeElement element in elements)
    {
      CodeEnum enumeration = element as CodeEnum;
      if (enumeration != null)
      {
        return enumeration;
      }
      enumeration = FindEnum(element.Children);
      if (enumeration != null)
      {
        return enumeration;
      }
    }
    return null;
  }
#>

could you please tell me what's wrong in my code ?

thanks a lot