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
Source generated formatter support of sparse/patch objects via BitArray #1793
Comments
In that case, let's hold onto this till source generation for v3 stabilizes and see whether adding this makes sense at that point. |
How important is it that the BitArray be an actual field on the class? What if the formatter did the BitArray magic without the field being declared? It might be interesting to see an example where the |
It doesn't need to be exposed as BitArray, but there should be a way to indicate that a given BitArray property should be used for this purpose. It allows the app logic to determine which properties were deserialized in a fast way. It also works well with the
I'm ok supporting the To avoid proliferation of methods we could also support
Essentially, the holes in keys translate into holes in the BitArray |
It sounds like you have a scenario in mind where you use messagepack to serialize only changes to an object. That's a notable scope change in the library. I've never heard of a general purpose serializer that was designed to do that. |
Yes, and I wanted the library logic to be minimal and only handle the actual (de)serialization so that the responsibility for doing comparisons or otherwise detecting changes would still be in the developer's hands. |
Is your feature request related to a problem? Please describe.
In my use case it's common to send updated data to the client. Currently, there is no built-in way to do so without also sending redundant data.
This is related to #265, #678 and could be leveraged for #107. It would also allow versioning with int keys without a significant perf penalty.
Describe the solution you'd like
My proposal is to leverage a
BitArray
property that would contain bits corresponding to the keyed properties that should be (de)serialized.null
array is equivalent to an array with all bits set. One of the bits would correspond to theBitArray
itself, it can be used to indicate whether to set the array value in the deserialized object, but it could be just ignored.The feature would be activated for any type with int keys that have a
BitArray
property assigned to0
.I'm only interested in the source generated approach, but this could also be implemented dynamically.
If there's enough interest I can contribute the implementation.
Additional context
Here's an example of a generated formatter using this feature:
MapItem
MapItemFormatter
The text was updated successfully, but these errors were encountered: