Skip to content

refactor(dart): aligned dart internal implementation#3601

Open
Geethapranay1 wants to merge 2 commits intoapache:mainfrom
Geethapranay1:dart_serialization_alignment
Open

refactor(dart): aligned dart internal implementation#3601
Geethapranay1 wants to merge 2 commits intoapache:mainfrom
Geethapranay1:dart_serialization_alignment

Conversation

@Geethapranay1
Copy link
Copy Markdown
Contributor

@Geethapranay1 Geethapranay1 commented Apr 21, 2026

Why?

The dart implementation's internal collections and map serializers were previously structured differently than the java and c# runtimes, using raw hex bitmasks and monolithic methods which made reading the code difficult.

What does this PR do?

  • extracts chunk/header magic numbers into MapFlags and CollectionFlags.
  • breaks down ListSerializer.writePayload into _writeSameTypeElements and _writeDifferentTypeElements.
  • adds identical depth getters to writecontext and readcontext.
  • maintained dart proper maxDepth spec enforcement on both read/write bounds.

Related issues

Fixes #3595

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

@Geethapranay1
Copy link
Copy Markdown
Contributor Author

@chaokunyang PTAL

@Geethapranay1 Geethapranay1 changed the title aligned dart internal implementation refactor(dart): aligned dart internal implementation Apr 21, 2026
* under the License.
*/

abstract final class CollectionFlags {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to split it into separate files. dart file is like java package.

When align with java, it's more about implementation detailes instead of code style. We still need be dart idiomatic

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense, i just now moved the flags directly into the serializer files

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.

[Dart] Align Dart internal implementation with java/csharp

2 participants