New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support naming conventions for enum members #773
Comments
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. |
Enables #773 Adds naming conventions for convert enums to/from scalars Adds .NET8 binaries Adds support for custom formatting of enums, easy to expose enums as integers or whatever else. Quotes necessary enum strings (Null for example) Breaking: For those that get impacted pass in NullNamingConvention.Instance to the EnumNamingConvetion arguments on the constructor Breaking: Removed many of the redundant constructors for the classes, pass in the old default values to the new constructors +semver:breaking
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
The text was updated successfully, but these errors were encountered: