[System.Text.Json] Generated enum values are Pascal-case
See original GitHub issueSchema:
enum SnakeEnum {
PIE_CHARMER,
VS_CODE,
}
Generates:
public enum SnakeEnum
{
[EnumMember(Value = "PIE_CHARMER")] PieCharmer,
[EnumMember(Value = "VS_CODE")] VsCode
}
This is fine if you are using a Json library that supports the EnumMember
attribute. Unfortunately System.Text.Json does not.
Propose:
- Command-line option
--enumTypeNaming
: EitherCSharp
(default, current) orUpperSnakeCase
I’ve started work on this and will submit a PR later today if it’s desired.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
System.Text.Json: How to serialize a individual enum as ...
System.Text.Json default to number the enum serialization. In my case I need the string for that in the Startup.cs I add a converter...
Read more >How to enable case-insensitive property name matching ...
In this article, you will learn how to enable case-insensitive property name matching with the System.Text.Json namespace.
Read more >Serializing enums as strings using System.Text.Json library ...
While serializing an object into JSON using the new library we can control various options such as casing, indentation, etc, but one notable ......
Read more >How to Serialize Enum to a String in C# - Code Maze
In this article, we will demonstrate different ways of how to serialize enum to string in C# with detailed explanation and examples.
Read more >How to customize property names and values with System. ...
Learn how to customize property names and values when serializing with System.Text.Json in .NET.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@HaikuJock thank you for explaining. Sorry I saw you had contribution and thought you were the owner.
published a new version 0.9.9
Use
EnumValueNaming = EnumValueNamingOption.Original
if generating from code--enumValueNaming Original
if using console app/tool<GraphQlClientGenerator_EnumValueNaming>Original</GraphQlClientGenerator_EnumValueNaming>
if using source generator