When using T4 to generate C# code, I can't get correct identation with TABS scattered around:
public partial class Foo : Base
{
public int C { get; set; }
[MappedProperty("A.B[{C}].Foo")]
public int Foo { get; set; }
}
I'm using a seemingly correctly indented .TT code similar to the following:
public partial class <#= ViewModelName #>
{
<# foreach(var property in ViewModelProperties) { #>
<# if(property.Mapping != null) { #>
[MappedProperty("<#= property.Mapping #>")]
<# } #>
public <#= property.TypeDeclaration #> <#= property.MemberName #> { get; set; }
<# } #>
}
This code snippet reflects what I've already tried to do: make control statements and blocks to a single line as much as possible.
t4 template is used to scaffold a DbContext class for the database, and the EntityType. t4 template is used to scaffold entity type classes for each table and view in the database.
I like to do it this way and never had any problems.
public partial class <#= ViewModelName #>
{
<#
foreach(var property in ViewModelProperties) {
if(property.Mapping != null) {
#>
[MappedProperty("<#= property.Mapping #>")]
<#
}
#>
public <#= property.TypeDeclaration #> <#= property.MemberName #> { get; set; }
<#
}
#>
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With