T4 Toolbox - mixing class feature and statement blocks

Posted by Mauricio Scheffer on Stack Overflow See other posts from Stack Overflow or by Mauricio Scheffer
Published on 2010-04-17T21:08:52Z Indexed on 2010/04/17 21:13 UTC
Read the original article Hit count: 1302

Filed under:
|
|

I'm a T4 newbie trying to use T4 Toolbox to generate F# code based on this answer, but it seems that class feature blocks can't be mixed with statement blocks. Here's my code:

<#@ template language="C#" hostspecific="True" debug="True" #>
<#@ output extension="txt" #>
<#@ include file="T4Toolbox.tt" #>
<#
    FSharpTemplate template = new FSharpTemplate();
    template.Output.Project = @"..\Library1\Library1.fsproj";
    template.Output.File = "Module2.fs";
    template.Render();
#>
<#+
class FSharpTemplate: Template
{
    public override string TransformText()
    {
#>

module Module2

<# for (int i = 0; i < 10; i++) { #>
<#= i #>
<# } #>

<#+
        return this.GenerationEnvironment.ToString();
    }
}

#>

And I get this error:

A Statement cannot appear after the first class feature in the template. Only boilerplate, expressions and other class features are allowed after the first class feature block.

So... how can I rewrite the template to achieve this?

© Stack Overflow or respective owner

Related posts about T4

Related posts about t4-toolbox