Skip to content

fix(compiler): preserve union case names on unknown-carrier collisions - #4106

Merged
chaokunyang merged 2 commits into
apache:mainfrom
ayush00git:fix/csharp-union-unknown-case
Oct 5, 2026
Merged

chaokunyang merged 2 commits into
apache:mainfrom
ayush00git:fix/csharp-union-unknown-case

Conversation

@ayush00git

@ayush00git ayush00git commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

An IDL union case named unknown collides with the automatically generated unknown-case carrier in C#, Kotlin, Scala, Rust, and Swift. Renaming the schema case to UnknownValue also collides when the schema declares unknown_value.

Preserve schema case names and rename only the generated carrier: use Unknown_ on collision in C#, Kotlin, Scala, and Rust, or unknown_ in Swift. If the alternate name is also occupied, fail generation. The source generators identify the carrier by its annotation or attribute, preserving its structural and uniqueness requirements. Case IDs, defaults, and wire encoding remain unchanged.

Validation

  • Compiler: 536 tests passed, including generated-name checks and double-collision rejection.
  • Actual IDL-generated unions in all five languages round-trip both schema cases and the renamed unknown carrier, preserve its case ID and value, and reserialize to the same bytes in both compatibility modes.
  • C#: 377 runtime/generator tests and 29 IDL tests passed; focused Java peer tests passed.
  • Rust: 63 derive tests, 4 doc tests, and 5 IDL tests passed; Clippy and focused Java peer tests passed.
  • Kotlin: IDL build and 10 Java peer tests passed.
  • Scala: 26 derivation tests, 7 IDL tests, and 26 Java peer tests passed.
  • Swift: 282 package tests, 7 IDL tests, and 26 Java peer tests passed; lint and formatting passed.

@ayush00git
ayush00git requested a review from chaokunyang October 1, 2026 12:25
…member

Every generated C# union declares an Unknown(UnknownCase) member for the
unknown-case fallback. A schema union case named "unknown" produced a second
'sealed partial record Unknown' in the same union, which fails to compile
(CS0102). Rename such a case record to UnknownValue; case identity is the
ForyCase number, so the rename does not affect wire behavior.

Claude-Session: https://claude.ai/code/session_01YcPbRyTJYmU8t6mkGCbnUf
@chaokunyang
chaokunyang force-pushed the fix/csharp-union-unknown-case branch from afd4fc3 to e0fe829 Compare October 5, 2026 01:48
@chaokunyang chaokunyang changed the title fix(compiler): rename C# union case colliding with generated Unknown member fix(compiler): preserve union case names on unknown-carrier collisions Oct 5, 2026
@chaokunyang
chaokunyang merged commit f85877f into apache:main Oct 5, 2026
128 of 129 checks passed
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.

2 participants