-
-
Notifications
You must be signed in to change notification settings - Fork 491
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
EnumMember is not applied when enum value is a combination of flags. #1016
Comments
We do support enum member but only in .net core. Full framework doesn’t have that functionality. Are you doing this in a .net core 6/7/8 app or full framework 4.x? |
I'm using .NET 8 or later. By the way, is there any reasons that exclude EnumMember support for .NET Framework 4.x? It's explicitly excluded by YamlDotNet/YamlDotNet/Serialization/TypeInspectors/ReflectionTypeInspector.cs Lines 34 to 69 in 7bed5cf
|
There was a reason for it. I just don’t remember what it was when I put that feature in place. |
What version of the library are you using? And can you share the code you’re using for the serializerbuilder? I can try and take a closer look in the next few days but I suspect it’s because it’s a multi value enum value. I only tested if it’s a single value, if it was AAA or BBB not AAA|BBB. If you want to take a stab at fixing that i do accept pull requests and it might get fixed quicker. |
TestCode is described on above Test Code section. <ItemGroup>
<PackageReference Include="FluentAssertions" Version="7.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.Text.Json" Version="9.0.0" />
<PackageReference Include="YamlDotNet" Version="16.2.1" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup> On my actual test code. Reported Issue is occurred when passing |
Describe the bug
When serialize
enum value combinations
.value is serialized by default enum name.
And the name that is specified by
EnumMember
is not used.To Reproduce
Test Code
Serialize result of System.Text.Json / NewtonsoftJson
When serialize same value with
System.Text.Json
/NewtonsoftJson
enum value is serialized as expected.The text was updated successfully, but these errors were encountered: