Skip to content

feat(xlang): simplify xlang field ordering#3675

Merged
chaokunyang merged 7 commits into
apache:mainfrom
chaokunyang:refactor_fields_order_spec
May 13, 2026
Merged

feat(xlang): simplify xlang field ordering#3675
chaokunyang merged 7 commits into
apache:mainfrom
chaokunyang:refactor_fields_order_spec

Conversation

@chaokunyang
Copy link
Copy Markdown
Collaborator

@chaokunyang chaokunyang commented May 13, 2026

Why?

The xlang field-ordering spec and several runtimes still treated non-primitive fields as separate type-specific groups. This PR simplifies the rule so non-primitive fields use one language-neutral identifier order, and makes invalid negative field ids fail early instead of being interpreted as name-based fields.

What does this PR do?

  • Updates the xlang serialization spec so fields are ordered as non-null primitives, nullable primitives, then all non-primitives sorted by field identifier.
  • Applies the simplified ordering across C++, C#, Dart, Go, Java, JavaScript, Python, Rust, and Swift runtimes or generators.
  • Allows mixed explicit field ids and name-based identifiers, with explicit ids sorted before name identifiers inside a field group.
  • Rejects negative configured field ids in supported generators, parsers, and macros; name-based fields now omit an explicit id instead of using -1.
  • Updates language guides and cross-language fixtures to match the new field-id and ordering behavior.
  • Adds focused tests for non-primitive field ordering, mixed identifier ordering, and negative field-id diagnostics.

Related issues

#1017

AI Contribution Checklist

  • Substantial AI assistance was used in this PR: yes / no
  • If yes, I included a completed AI Contribution Checklist in this PR description and the required AI Usage Disclosure.
  • If yes, my PR description includes the required ai_review summary and screenshot evidence of the final clean AI review results from both fresh reviewers on the current PR diff or current HEAD after the latest code changes.

Does this PR introduce any user-facing change?

Yes. Xlang non-primitive struct field ordering now follows field identifiers directly, and configured negative field ids are rejected. Fields without explicit ids continue to use name-based identifiers.

  • Does this PR introduce any public API change?
  • Does this PR introduce any binary protocol compatibility change?

Benchmark

N/A

@chaokunyang chaokunyang force-pushed the refactor_fields_order_spec branch from 90c04ed to c3936b1 Compare May 13, 2026 07:12
@chaokunyang chaokunyang merged commit 74898f4 into apache:main May 13, 2026
75 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