понедельник, 22 июня 2026 г.

T4, Templates, (.tt), Generators, T4DemoSln.slnx

T4, Templates, (.tt), Generators, T4DemoSln.slnx

https://giga.chat/link/gcsmwdNZKS

https://www.perplexity.ai/search/81c6b37a-6c86-4042-8c0f-1b97309d9e00

D:\Projects\VS02\2606\Generation\Giga\T4DemoSln\T4DemoSln.slnx

D:\Projects\VS02\2606\Generation\Giga\T4DemoSln\T4Demo\T4Demo.csproj

Code

-------------------------
<#@ template debug="false" hostspecific="true" language="C#" #> <#@ output extension=".generated.cs" #> <#@ assembly name="System.Runtime.dll" #> <#@ assembly name="netstandard.dll" #> <#@ assembly name="System.Collections.dll" #> <#@ assembly name="System.Memory.dll" #> <# var names = new string[] { "Иван", "Мария" }; foreach(var name in names) { #> public class Greeter_<#= name #> { public void SayHello() { Console.WriteLine("Привет, <#= name #>!"); } } <# } #>

--------------------------
Results
-------------------------
public class Greeter_Иван
{
public void SayHello()
{
Console.WriteLine("Привет, Иван!");
}
}

public class Greeter_Мария
{
public void SayHello()
{
Console.WriteLine("Привет, Мария!");
}
}
--------------------------------------------------------


Комментариев нет:

Отправить комментарий