Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Support deserializing a 16 byte binary guid/uuid #2156

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

Draft
wants to merge 4 commits into
base: master
Choose a base branch
Loading
from

Conversation

ramonsmits
Copy link

When sending a uuid with javascript its a string. I tried sending a Uint8Array but that failed to deserialize. Turns out in only supports text formatted uuid. This adds support for deserializing a 16 byte guid.

@ramonsmits ramonsmits changed the title Support derializing a 16 byte binary guid/uuid Support deserializing a 16 byte binary guid/uuid Feb 12, 2025
@neuecc
Copy link
Member

neuecc commented Feb 18, 2025

Since we can expect GUIDs to come in various formats, I agree with making the deserialization somewhat flexible.
However, in the implementation, please be careful about unnecessary allocations.
Also, it's important to consider whether the approach is properly generalized.
If specialized handling is needed, I recommend preparing a separate formatter and combining it with the resolver.

@ramonsmits
Copy link
Author

ramonsmits commented Feb 18, 2025

However, in the implementation, please be careful about unnecessary allocations.

Fixed that

Also, it's important to consider whether the approach is properly generalized.

What does this mean? If many message pack serializeres serialize uuid as 16 byte big endian values?

If specialized handling is needed, I recommend preparing a separate formatter and combining it with the resolver.

I'm doing that now, but it felt such a common thing that I didn't expect that binary uuids were not supported. I didn't verify other runtimes/packages.

As you can see there is significant size savings. Imaging a type that has a few uuid properties. That is 20 byte per uuid.

@ramonsmits
Copy link
Author

ramonsmits commented Feb 18, 2025

@neuecc I also noticed this:

NativeGuidFormatter:

https://github.com/MessagePack-CSharp/MessagePack-CSharp/blob/v3.1.3/src/MessagePack/Formatters/UnsafeBinaryFormatters.cs

A remark on that type is the implementation only works on LITTLE endian environments.

Would it be ok to refactor this PR into a new NetworkOrderUuidFormatter that (de)serializes to a big endian 16 byte uuid? I think that makes sense.

@neuecc
Copy link
Member

neuecc commented Feb 21, 2025

Would it be ok to refactor this PR into a new NetworkOrderUuidFormatter that (de)serializes to a big endian 16 byte uuid

seems good.

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
Morty Proxy This is a proxified and sanitized view of the page, visit original site.