Open pardahlman opened 1 year ago
I doubt it will work, but can you try the yamlmember attribute and set the alias property? I suspect it won’t though. If you want to implement that if it doesn’t we’re always open to pull requests.
Thanks for getting back on this. I'll take a look at yamlmember and get back to you if I find the time to implement this feature.
This is indeed necessary.
A fix for this issue has been released in version 15.1.0.
Is your feature request related to a problem? Please describe.
I have a YAML file where both properties and their values use snake case.
The corresponding C# DTO uses enum
I have configred YamlDotNet to use
UnderscoredNamingConvention
, but the deserialization fails:My initial analysis suggests that it's the call to
Enum.Parse
in ScalarNodeDeserializer that is performed with the underscored value (database_migration
). Looking further into howINamingConvention
is used, it appears that it's only used for property values (I might be wrong here!).Describe the solution you'd like
I would like to deserialize YAML with snake case property values into C# enums defined in pascal case. It would be preferable if I could serialize C# DTOs using pascal case enums values into YAML with snake case property values (e.g. roundtrip).
Describe alternatives you've considered
Using a C# enum with snake case works, but is not desirable