Skip to content

Emit both JsonStringEnumMemberName and EnumMember attributes#1905

Merged
lahma merged 1 commit intoRicoSuter:masterfrom
lahma:fix/enum-member-attribute-1866
Mar 8, 2026
Merged

Emit both JsonStringEnumMemberName and EnumMember attributes#1905
lahma merged 1 commit intoRicoSuter:masterfrom
lahma:fix/enum-member-attribute-1866

Conversation

@lahma
Copy link
Copy Markdown
Collaborator

@lahma lahma commented Mar 8, 2026

Summary

  • Fixes JsonStringEnumMemberName not taken into account for url parameters #1866
  • When UseSystemTextJson && JsonLibraryVersion >= 9.0, the Enum.liquid template only emitted [JsonStringEnumMemberName], dropping [EnumMember]
  • This broke NSwag's ConvertToString which uses reflection to find EnumMemberAttribute for URL parameter serialization
  • Now emits both attributes when JsonLibraryVersion >= 9.0

Test plan

  • Updated snapshot for When_enum_has_string_value_then_CS_code_has_JsonStringEnumMemberName_attribute to verify both attributes
  • All codegen tests pass on net8.0 (52 passed) and net9.0 (1 passed)

🤖 Generated with Claude Code

…er#1866)

When UseSystemTextJson and JsonLibraryVersion >= 9.0, emit EnumMember
attribute alongside JsonStringEnumMemberName. This fixes NSwag's
ConvertToString which uses reflection to find EnumMemberAttribute for
URL parameter serialization.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@lahma lahma force-pushed the fix/enum-member-attribute-1866 branch from 825e6d3 to 2a3b70a Compare March 8, 2026 17:59
@lahma lahma merged commit a67833e into RicoSuter:master Mar 8, 2026
2 checks passed
@lahma lahma deleted the fix/enum-member-attribute-1866 branch March 8, 2026 18:44
This was referenced Apr 8, 2026
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.

JsonStringEnumMemberName not taken into account for url parameters

1 participant