Skip to content

Conversation

@0xced
Copy link
Contributor

@0xced 0xced commented Sep 28, 2025

System.Text.Json ignores the System.Runtime.Serialization.EnumMember attribute. It needs the System.Text.Json.Serialization.JsonStringEnumMemberName attribute to customize the names of individual enum members.

System.Text.Json ignores the `System.Runtime.Serialization.EnumMember` attribute. It needs the [`System.Text.Json.Serialization.JsonStringEnumMemberName` attribute](https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/customize-properties#custom-enum-member-names) to customize the names of individual enum members.
@0xced
Copy link
Contributor Author

0xced commented Sep 28, 2025

I should have seen it with the new verified files introduced in #1863 but I got fooled by the code compiling properly. Of course compiling doesn't mean working as expected! 😄

Copy link
Collaborator

@lahma lahma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks again!

@lahma lahma merged commit dd26885 into RicoSuter:master Sep 28, 2025
3 of 4 checks passed
@0xced 0xced deleted the JsonStringEnumMemberName branch September 28, 2025 18:30
0xced added a commit to 0xced/refitter that referenced this pull request Sep 29, 2025
Apply the equivalent of RicoSuter/NJsonSchema#1863 and RicoSuter/NJsonSchema#1864 while waiting for the next version of NJsonSchema.CodeGeneration.CSharp to be released.
0xced added a commit to 0xced/refitter that referenced this pull request Sep 29, 2025
Apply the equivalent of RicoSuter/NJsonSchema#1863 and RicoSuter/NJsonSchema#1864 while waiting for the next version of NJsonSchema.CodeGeneration.CSharp to be released.
0xced added a commit to 0xced/refitter that referenced this pull request Sep 29, 2025
Apply the equivalent of RicoSuter/NJsonSchema#1863 and RicoSuter/NJsonSchema#1864 while waiting for the next version of NJsonSchema.CodeGeneration.CSharp to be released.
0xced added a commit to 0xced/refitter that referenced this pull request Sep 30, 2025
Apply the equivalent of RicoSuter/NJsonSchema#1863 and RicoSuter/NJsonSchema#1864 while waiting for the next version of NJsonSchema.CodeGeneration.CSharp to be released.
@Novanet-
Copy link

Novanet- commented Oct 1, 2025

@0xced @lahma

[JsonStringEnumMemberName] was only introduced in .NET 9

.NET 8 projects that are using NJsonSchema and generate code that uses the [JsonStringEnumMemberName] attribute now fail to compile

@lahma
Copy link
Collaborator

lahma commented Oct 1, 2025

@0xced @lahma

[JsonStringEnumMemberName] was only introduced in .NET 9

.NET 8 projects that are using NJsonSchema and generate code that uses the [JsonStringEnumMemberName] attribute now fail to compile

Before fix you can always upgrade the STJ dependency to v9 version.

@RicoSuter
Copy link
Owner

Both libraries have now been released as NuGet packages.

@RicoSuter
Copy link
Owner

RicoSuter commented Oct 2, 2025

@0xced @lahma

[JsonStringEnumMemberName] was only introduced in .NET 9

.NET 8 projects that are using NJsonSchema and generate code that uses the [JsonStringEnumMemberName] attribute now fail to compile

We need to fix this ASAP, this is really bad...

TBH i dont even understand what this new attribute is providing in additional value, you could already change name with the previous attriubute, or not?

I think we need to introduce CSharpVersion configuration property (same as TypeScriptVersion property, set it to 8.0 by default).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants