Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support serializing index-based types as maps as well as arrays #112

Merged
merged 2 commits into from
Nov 18, 2024

Conversation

AArnott
Copy link
Owner

@AArnott AArnott commented Nov 18, 2024

Arrays are most compact when they are packed with data. But if there are 'holes' in the indexes (whether by missing indexes in the key attributes or by properties having default values and thus not serialized), a map that uses those same ordinal indexes as keys can be more compact.
With this new feature, the more compact of the two formats is automatically chosen (when SerializeDefaultValues == false) during serialization.

@AArnott AArnott linked an issue Nov 18, 2024 that may be closed by this pull request
Arrays are most compact when they are packed with data. But if there are 'holes' in the indexes (whether by missing indexes in the key attributes or by properties having default values and thus not serialized), a map that uses those same ordinal indexes as keys can be more compact.
With this new feature, the more compact of the two formats is automatically chosen (when `SerializeDefaultValues == false`) during serialization.
@AArnott AArnott force-pushed the 90-support-serializing-objects-as-integer-keyed-maps branch from 1ae2129 to 7b40783 Compare November 18, 2024 18:17
@AArnott AArnott enabled auto-merge November 18, 2024 18:21
@AArnott AArnott merged commit 040550b into main Nov 18, 2024
2 checks passed
@AArnott AArnott deleted the 90-support-serializing-objects-as-integer-keyed-maps branch November 18, 2024 18:21
Copy link

codecov bot commented Nov 18, 2024

Codecov Report

Attention: Patch coverage is 96.97733% with 12 lines in your changes missing coverage. Please review.

Project coverage is 77.83%. Comparing base (39101a7) to head (29d97d3).
Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
...k.MessagePack/Converters/ObjectArrayConverter`1.cs 94.55% 3 Missing and 5 partials ⚠️
src/Nerdbank.MessagePack/MessagePackAsyncReader.cs 75.00% 1 Missing and 1 partial ⚠️
...Nerdbank.MessagePack.Tests/ObjectsAsArraysTests.cs 98.90% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #112      +/-   ##
==========================================
+ Coverage   76.57%   77.83%   +1.26%     
==========================================
  Files         127      127              
  Lines        7593     7914     +321     
  Branches     1048     1101      +53     
==========================================
+ Hits         5814     6160     +346     
+ Misses       1448     1425      -23     
+ Partials      331      329       -2     
Flag Coverage Δ
Linux 77.83% <96.97%> (+1.26%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

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.

Support serializing objects as integer-keyed maps
1 participant