Open kikaragyozov opened 2 years ago
@JoshClose I don't want to replicate this bug but definitely attributes don't work at all - throws error when Map(p => p.UseTitle)
is added
[CsvHelper.Configuration.Attributes.Index(3)]
[CsvHelper.Configuration.Attributes.BooleanTrueValues("Y", "y")]
[CsvHelper.Configuration.Attributes.BooleanFalseValues("N", "n")]
public bool UseTitle { get; set; }
If the Map(p => p.UseTitle)
completely removed - no error but all values are false
.
It works only when this configuration is done
Map(p => p.UseTitle)
.TypeConverterOption.BooleanValues(true, true, "Y", "y")
.TypeConverterOption.BooleanValues(false, true, "N", "n")
.Index(3);
Nuget version
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
Attributes are only used in automatic mapping. They are not used if you are defining your own ClassMap
.
Perhaps MemberMap
should expose an ApplyAttributes
with the logic from:
This would allow a hybrid approach e.g. Map(p => p.UseTitle).ApplyAttributes()
.
In the meantime you could literally take the above code and make it an extension method public static void ApplyAttributes(this MemberMap memberMap)
.
Is this intentional?
I'll be able to provide a MRE at the weekend.