Currently I am using Typewriter for automatic generation of TypeScript class from my C# classes:
[TsDTO]
public class MyDto {
public string Prop1 { get; set; }
public string Prop2 { get; set; }
}
And I want to simply generate a Typescript interface appending the postfix "xyz" to the properties names:
export Interface IMyDto {
prop1xyz: string;
prop2xyz: string;
}
Is is possible to define my template for adding "xyz" without creating a custom method?
This template does not work:
$Classes(c => HasAttribute(c.Attributes, "TsDTO"))[
export interface I$Name {
// properties
$Properties()[$namexyz: $Type; <-- "xyz" breaks the code!
]
}]
Create an extension method in a code block at the top of your template:
Then use it in your Property template: