-
-
Notifications
You must be signed in to change notification settings - Fork 462
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
Enum properties do not serialize if set to the first value in the enum (position 0) #251
Comments
Here's a more pure demonstration of the issue which is rather fundamental. You can run it here: In summary, the first value of an enum seems to fail to serialize. This can be worked around by adding a "dummy" enum in the first position. Objectively speaking this seems like a major fundamental issue with a very basic case of serialization, which might mean that it's a relatively new bug. Otherwise, I expect this would have been experienced and reported by many.
|
This is a known (to me) issue. This is because default values are not emitted unless you call |
Ok, sounds good. I'm glad there's a ticket now. This way further people won't have to spend 3 hours debugging it and feeling stupid when trying to learn YamlDotNet. |
So to clarify, the effective workaround is numbering the Enum and not using 0. For example:
|
Could an attribute be implemented that determines whether or not the default value of a field/property is serialized? |
I have opened issue #427 that is related to your question. One of the points is the inclusion of such an attribute. Feel free to join the discussion and provide any feedback that might be relevant. I am closing the issue to avoid duplicate discussion. |
Removing original description of issue as it's more clearly demonstrated in the first comment below.
The text was updated successfully, but these errors were encountered: