Skip to content

feat(compiler): add csharp target and idl integration tests#3406

Merged
chaokunyang merged 7 commits intoapache:mainfrom
chaokunyang:csharp_idl_codegen
Feb 25, 2026
Merged

feat(compiler): add csharp target and idl integration tests#3406
chaokunyang merged 7 commits intoapache:mainfrom
chaokunyang:csharp_idl_codegen

Conversation

@chaokunyang
Copy link
Collaborator

@chaokunyang chaokunyang commented Feb 25, 2026

Why?

Add full C# schema IDL support end-to-end in Apache Fory: compiler target, documentation, runtime compatibility fixes, and integration coverage (including root/package cross-reference and file-based roundtrip scenarios).

What does this PR do?

  • Adds C# as a first-class compiler target:
    • foryc --lang ... ,csharp
    • foryc --csharp_out=<dir>
    • option csharp_namespace = "..."
  • Implements C# schema generator (compiler/fory_compiler/generators/csharp.py) for messages/enums/unions, registration helpers, and generated ToBytes/FromBytes helpers.
  • Wires C# into compiler generator registration and generated-code test matrix.
  • Adds C# generator unit tests (compiler/fory_compiler/tests/test_csharp_generator.py) covering namespace resolution, registration behavior, field encoding attributes, imported registration calls, and parser option support.
  • Adds full C# IDL integration test harness under integration_tests/idl_tests/csharp/IdlTests and runner integration_tests/idl_tests/run_csharp_tests.sh, including schema-consistent and compatible roundtrips across:
    • addressbook, auto_id, complex_pb primitives
    • collection union/array variants
    • optional_types
    • any_example (.fdl) and any_example (.proto)
    • flatbuffers (monster, complex_fbs)
    • reference-tracking models (tree, graph)
    • evolving compatibility cases
    • root/package cross-reference (root.idl) and generated bytes helper paths
  • Adds C# IDL output target to integration_tests/idl_tests/generate_idl.py.
  • Improves C# runtime compatibility behavior for generated IDL shapes:
    • collection/dictionary serializers now handle declared-type metadata correctly in compatible mode.
    • union serializer now supports typed case handling while preserving xlang-compatible dynamic framing and case value normalization.
  • Updates compiler documentation (compiler/README.md, docs/compiler/*) and C# README to document C# codegen, options, generated output, and test workflow.

Related issues

#1017
#3387

Does this PR introduce any user-facing change?

Yes. foryc now supports C# generation (--lang csharp, --csharp_out) and C# namespace override (csharp_namespace), with updated compiler docs and C# IDL test workflow.

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

Benchmark

N/A (feature + compatibility work; no benchmark updates in this PR)

@chaokunyang chaokunyang merged commit 037cd7b into apache:main Feb 25, 2026
59 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