Skip to content

feat(csharp): support generated class inheritance - #3893

Merged
chaokunyang merged 6 commits into
apache:mainfrom
chaokunyang:csharp-class-inheritance-support
Jul 28, 2026
Merged

feat(csharp): support generated class inheritance#3893
chaokunyang merged 6 commits into
apache:mainfrom
chaokunyang:csharp-class-inheritance-support

Conversation

@chaokunyang

@chaokunyang chaokunyang commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Why?

Generated C# serializers previously modeled only members declared by the concrete class. Base-class
wire members could be omitted from field ordering, schema metadata, reads, and writes, while private
parent storage could not be included correctly when the parent came from another compilation.
Third-party base classes also need an explicit, application-owned way to describe inaccessible
fields without inspecting private assembly metadata.

What does this PR do?

  • Adds declaration-owned hierarchy provider contracts for ordinary inheritable classes. A concrete
    serializer flattens the immediate parent provider's wire members with its own members and composes
    cumulative shallow-storage bytes without calling a parent serializer.
  • Separates the flattened wire-member model from shallow instance-storage accounting so inherited
    schema behavior and graph-memory reservation each have one clear owner.
  • Adds exact external class field mappings through TargetDeclaringType and TargetMemberName, plus
    BaseOnly declarations for unmodifiable third-party hierarchy prefixes and storage-only fields.
  • Validates referenced provider identity, descriptor counts and ordinals, accessor signatures,
    accessibility, generic construction, and override/member identities before generating child code.
  • Splits ForyModelGenerator into focused partial files for analysis, hierarchy composition,
    external mappings, models, and emission while retaining one generation path.
  • Adds same-compilation, cross-assembly, external private-field, graph-memory, generator diagnostic,
    and C# xlang coverage, and updates the C# guides and xlang implementation specification.

Related issues

N/A

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 or equivalent persisted links of the final clean AI review results from both fresh reviewers described in AI_POLICY.md, the Fory-guided reviewer and the independent general reviewer, on the current PR diff or current HEAD after the latest code changes.

Does this PR introduce any user-facing change?

Yes. Annotated C# class hierarchies now serialize inherited fields. External serializer declarations
gain BaseOnly, TargetDeclaringType, and TargetMemberName for explicit third-party class
hierarchy and private-field mappings. The shared binary protocol encoding is unchanged.

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

Benchmark

The existing C# external-equivalence benchmark model now declares exact backing storage through
storage-only external mappings. This PR does not add a benchmark harness or a separate inheritance
benchmark path.

@chaokunyang chaokunyang changed the title feat(csharp): add csharp class Inheriance support feat(csharp): support generated class inheritance Jul 28, 2026
@chaokunyang
chaokunyang marked this pull request as draft July 28, 2026 01:49
@chaokunyang
chaokunyang marked this pull request as ready for review July 28, 2026 02:03
@chaokunyang
chaokunyang merged commit 3d791e2 into apache:main Jul 28, 2026
66 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