Jestem nowicjuszem T4 próbującym użyć T4 Toolbox do wygenerowania kodu F # opartego na this answer, ale wydaje się, że bloków klasy nie można mieszać z blokami instrukcji. Oto mój kod:T4 Toolbox - funkcja klasy mieszania i bloki instrukcji
<#@ 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();
}
}
#>
i dostaję ten błąd:
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.
... więc jak mogę przepisać szablon do osiągnięcia tego celu?
Jeśli to zrobić otrzymuję żadnego wyjścia na wszystkich –
widzę. Naprawdę nie rozumiem, jak ma wyglądać odpowiedź w drugim pytaniu, ale mogę powiedzieć, że jest to reguła dla T4. Polecam dodać link do wygenerowanego pliku w innym projekcie. – erikkallen