Skip to content

feat(xlang): refine xlang api#3555

Open
chaokunyang wants to merge 7 commits intoapache:mainfrom
chaokunyang:refine_xlang_api
Open

feat(xlang): refine xlang api#3555
chaokunyang wants to merge 7 commits intoapache:mainfrom
chaokunyang:refine_xlang_api

Conversation

@chaokunyang
Copy link
Copy Markdown
Collaborator

@chaokunyang chaokunyang commented Apr 10, 2026

Why?

  • Java enums needed a stable numeric tag option for cross-language and schema-evolution scenarios that should not depend on declaration order.
  • The xlang implementation guide and related docs/specs had drifted from the current runtime architecture and API surface.

What does this PR do?

  • Remove ForyBuilder.Xlang(bool) from the C# public API, make Config builder-created only, and make C# always emit and require the xlang frame header.
  • Add Java @ForyEnumId support so enums can use a single annotated field, a zero-argument getter, or per-constant annotations for stable numeric tags, with dense-array lookup for small IDs and sparse-map lookup for larger IDs.
  • Add Java serializer and xlang tests covering default ordinal behavior, explicit enum IDs, validation failures, and cross-language enum evolution with stable IDs.
  • Refresh the C# guides and Java/xlang specs, including a rewrite of the xlang implementation guide around the current Fory / WriteContext / ReadContext / RefWriter / RefReader architecture.

Testing

  • cd csharp && dotnet format Fory.sln --verify-no-changes
  • cd csharp && dotnet test Fory.sln -c Release --no-restore
  • cd java && export JAVA_HOME=/Library/Java/JavaVirtualMachines/graalvm-25.jdk/Contents/Home && mvn -T16 -pl fory-core spotless:check
  • cd java && export JAVA_HOME=/Library/Java/JavaVirtualMachines/graalvm-25.jdk/Contents/Home && mvn -T16 -pl fory-core test -Dtest=org.apache.fory.serializer.EnumSerializerTest,org.apache.fory.xlang.EnumTest
  • cd python && python -m pip install -v -e .
  • cd java/fory-core && export JAVA_HOME=/Library/Java/JavaVirtualMachines/graalvm-25.jdk/Contents/Home && FORY_CSHARP_JAVA_CI=1 FORY_PYTHON_JAVA_CI=1 ENABLE_FORY_DEBUG_OUTPUT=1 mvn -T16 test -Dtest=org.apache.fory.xlang.CPPXlangTest,org.apache.fory.xlang.CSharpXlangTest,org.apache.fory.xlang.RustXlangTest,org.apache.fory.xlang.GoXlangTest,org.apache.fory.xlang.PythonXlangTest

Related issues

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?

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

Benchmark

N/A

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