Skip to content

AVRO-3671: [C#] Preserve specific enum types - #4031

Open
sadicangel wants to merge 1 commit into
apache:mainfrom
sadicangel:avro-3671-preserve-specific-enum-type
Open

sadicangel wants to merge 1 commit into
apache:mainfrom
sadicangel:avro-3671-preserve-specific-enum-type

Conversation

@sadicangel

Copy link
Copy Markdown

What is the purpose of the change

Fix AVRO-3671 by materializing enum values as their generated CLR types in SpecificDatumReader.

Previously, enum values were returned as boxed integer ordinals, losing branch identity in unions such as ["int", "Enum1", "Enum2"].

Resolve the reader enum type through ObjectCreator and create the CLR enum value from the resolved reader ordinal. Existing symbol translation, default handling, generic-reader behavior, and public APIs remain unchanged.

Callers relying on boxed integer enum results must now handle the generated CLR enum types.

Verifying this change

Added 21 regression cases using generated CLR types, covering:

  • Ordinary and nullable enum fields.
  • Integer/enum and multiple-enum unions, including ["int", "Enum1", "Enum2"] and ["null", "int", "Enum1"].
  • Runtime type preservation and byte-preserving reserialization.
  • Reordered symbols, reader enum defaults, and missing-field defaults.
  • Unchanged generic enum materialization.

Validation on Windows:

  • Release build passed with zero warnings or errors.
  • C# test suite passed across .NET 8, 9, and 10, including interop and package-content tests.

Documentation

  • Does this pull request introduce a new feature? No; this is a bug fix.
  • If yes, how is the feature documented? Not applicable.

Materialize enums as their generated CLR types in SpecificDatumReader
so unions containing integers and multiple enums retain branch identity.
Returning boxed ordinals made these values indistinguishable after
deserialization.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant