aaubry / YamlDotNet

YamlDotNet is a .NET library for YAML
MIT License
2.58k stars 486 forks source link

EnumMember support "" #983

Closed IvanJosipovic closed 2 months ago

IvanJosipovic commented 2 months ago

Describe the bug When an Enum Member has the following annotation, EnumMember(Value = ""). The returned value should be "", as opposed to the Enum Member Name.

To Reproduce

Console.WriteLine("Start");

var yamlValue = new YamlDotNet.Serialization.Serializer().Serialize(EnumMemberedEnum.EmptyValue);

//yamlValue == "EmptyValue" // Should be '' as opposed to EmptyValue

var yamlObject = (new YamlDotNet.Serialization.Deserializer().Deserialize<EnumMemberedEnum>(yamlValue));

Console.WriteLine("End");

public enum EnumMemberedEnum
{
    No = 0,

    [System.Runtime.Serialization.EnumMember(Value = "goodbye")]
    Hello = 1,

    [System.Runtime.Serialization.EnumMember(Value = "")]
    EmptyValue = 2,

    [System.Runtime.Serialization.EnumMember()]
    NullValue = 3
}
EdwardCooke commented 2 months ago

It'll be fixed shortly, about to push up a PR with the fix and I'll try and get it out today.