Skip to content

Fix C# discriminator enum naming to include package prefix#279

Draft
Copilot wants to merge 2 commits intodevelopfrom
copilot/check-enumeration-csharp
Draft

Fix C# discriminator enum naming to include package prefix#279
Copilot wants to merge 2 commits intodevelopfrom
copilot/check-enumeration-csharp

Conversation

Copy link
Contributor

Copilot AI commented Mar 14, 2026

C# was generating field_order oneof discriminator enums without the package prefix, inconsistent with regular C# enums, C++, and TypeScript which all include it.

Before:

// Missing "SerializationTest" prefix
public enum UnionTestMessageFieldOrderDataField : byte { ... }

After (matching C++/TypeScript):

public enum SerializationTestUnionTestMessageFieldOrderDataField : byte { ... }

Changes

  • csharp_gen.py: Fixed 5 call sites of get_discriminator_enum_name() / generate_discriminator_enum() to pass the full structName ({package}{MessageName}) instead of bare msg.name. Affected locations: field declaration, deserialization, field-order dispatch, envelope methods, and file generation.

  • tests/proto/test_messages.proto: Added SimplePayload (no msgid) and UnionTestMessageFieldOrder (msgid=212) to exercise the field_order discriminator path — a case previously absent from the test suite.

Original prompt

the cpp/ts generated files create an enumeration for one of messages with the auto discriminator, does the c# as well?


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…t with C++/TypeScript)

Co-authored-by: rijesha <7819200+rijesha@users.noreply.github.com>
Copilot AI changed the title [WIP] Update implementation for message enumeration in C# Fix C# discriminator enum naming to include package prefix Mar 14, 2026
Copilot AI requested a review from rijesha March 14, 2026 04:35
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