Skip to content

fix(compiler): rename C# union case colliding with generated Unknown member - #4106

Open
ayush00git wants to merge 2 commits into
apache:mainfrom
ayush00git:fix/csharp-union-unknown-case
Open

ayush00git wants to merge 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?

The C# generator declares an Unknown(UnknownCase) member in every generated union for the unknown-case fallback. A schema union case named unknown produced a second sealed partial record Unknown in the same union, so the generated file failed to compile (CS0102 duplicate member):

[ForyUnknownCase]
public sealed partial record Unknown(UnknownCase Value) : Payload;
public sealed partial record Unknown(string Value) : Payload;

This renames such a case record to UnknownValue, following the existing Value-suffix convention used for field/nested-type collisions. Case identity on the wire is the ForyCase number, so the rename does not change wire behavior.

Checklist

  • Regression test test_union_unknown_case_renamed in test_csharp_generator.py; it fails without the generator change.
  • Full compiler suite passes: 492 passed, 1 skipped.

…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
@ayush00git
ayush00git requested a review from chaokunyang October 1, 2026 12:25

This branch has not been deployed

No deployments
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.

1 participant