Provides MessagePack serialization support for the UUID library, enabling high-performance binary serialization and deserialization of UUID values. Features include compact binary representation, thread-safe implementation, comprehensive error handling, and seamless integration with MessagePack's type resolution system. Optimized for both performance and memory efficiency across different .NET platforms.
$ dotnet add package UUID.Serialization.MessagePackA MessagePack serialization provider for the UUID library.
dotnet add package UUID.Serialization.MessagePack
using MessagePack;
using MessagePack.Resolvers;
// Register the resolver globally
var options = MessagePackSerializerOptions.Standard
.WithResolver(CompositeResolver.Create(
UUIDResolver.Instance,
StandardResolver.Instance
));
// Serialize
var uuid = new UUID();
byte[] bytes = MessagePackSerializer.Serialize(uuid, options);
// Deserialize
UUID deserializedUuid = MessagePackSerializer.Deserialize<UUID>(bytes, options);
public class UserModel
{
[Key(0)]
public UUID Id { get; set; }
[Key(1)]
public string Name { get; set; }
}
// Register resolver
var options = MessagePackSerializerOptions.Standard
.WithResolver(CompositeResolver.Create(
UUIDResolver.Instance,
StandardResolver.Instance
));
// Serialize model
var user = new UserModel
{
Id = new UUID(),
Name = "John Doe"
};
byte[] bytes = MessagePackSerializer.Serialize(user, options);
// Deserialize model
UserModel deserializedUser = MessagePackSerializer.Deserialize<UserModel>(bytes, options);
The formatter provides detailed error messages for common scenarios:
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the terms of the LICENSE file included in the root directory.