SquidStd.Persistence.MessagePack 0.33.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package SquidStd.Persistence.MessagePack --version 0.33.1
                    
NuGet\Install-Package SquidStd.Persistence.MessagePack -Version 0.33.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SquidStd.Persistence.MessagePack" Version="0.33.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SquidStd.Persistence.MessagePack" Version="0.33.1" />
                    
Directory.Packages.props
<PackageReference Include="SquidStd.Persistence.MessagePack" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SquidStd.Persistence.MessagePack --version 0.33.1
                    
#r "nuget: SquidStd.Persistence.MessagePack, 0.33.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SquidStd.Persistence.MessagePack@0.33.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SquidStd.Persistence.MessagePack&version=0.33.1
                    
Install as a Cake Addin
#tool nuget:?package=SquidStd.Persistence.MessagePack&version=0.33.1
                    
Install as a Cake Tool

<h1 align="center">SquidStd.Persistence.MessagePack</h1>

MessagePack-backed binary IDataSerializer/IDataDeserializer for SquidStd. MessagePackDataSerializer implements both of SquidStd's serialization contracts over the MessagePack contractless resolver, so plain public POCOs round-trip with no [MessagePackObject] attributes and no key annotations. It is the recommended serializer for SquidStd.Persistence journals and snapshots: payloads are a fraction of the size of JSON and (de)serialization is faster, which matters when every entity write is appended to a binary journal. SquidStd.Core ships a JSON default; pull this package in when you want compact binary payloads instead.

Install

dotnet add package SquidStd.Persistence.MessagePack

Usage

The serializer is a single stateless class - construct it and use it directly. Serialize<T> returns a ReadOnlyMemory<byte> and Deserialize<T> reads one back:

using SquidStd.Core.Interfaces.Serialization;
using SquidStd.Persistence.MessagePack;

public sealed class Player
{
    public int Id { get; set; }
    public string Name { get; set; } = string.Empty;
}

var serializer = new MessagePackDataSerializer();

ReadOnlyMemory<byte> bytes = serializer.Serialize(new Player { Id = 1, Name = "Bob" });
Player back = serializer.Deserialize<Player>(bytes);

With SquidStd.Persistence

PersistenceEntityDescriptor<T, TKey> takes the serializer and deserializer explicitly, so you can use MessagePack for entity payloads without touching the rest of the app:

using SquidStd.Persistence.Data;
using SquidStd.Persistence.MessagePack;
using SquidStd.Persistence.Services;

var serializer = new MessagePackDataSerializer();

var registry = new PersistenceEntityRegistry();
registry.Register(new PersistenceEntityDescriptor<Player, int>(
    serializer, serializer, typeId: 1, typeName: "Player", schemaVersion: 1, keySelector: p => p.Id));

As the app-wide default serializer

RegisterCoreServices() registers the JSON default via RegisterDataSerializer(), which uses IfAlreadyRegistered.Keep - an already-registered serializer wins. So to make MessagePack the app-wide IDataSerializer/IDataDeserializer (used by messaging, caching, and DI-registered persistence descriptors), register it before RegisterCoreServices():

using DryIoc;
using SquidStd.Core.Interfaces.Serialization;
using SquidStd.Persistence.MessagePack;
using SquidStd.Services.Core.Extensions;
using SquidStd.Services.Core.Services.Bootstrap;

var bootstrap = SquidStdBootstrap.Create(o => o.ConfigName = "myapp");

bootstrap.ConfigureServices(c =>
{
    var serializer = new MessagePackDataSerializer();
    c.RegisterInstance<IDataSerializer>(serializer);
    c.RegisterInstance<IDataDeserializer>(serializer);

    return c.RegisterCoreServices(); // keeps your MessagePack registration
});

await bootstrap.StartAsync();

If you register it after RegisterCoreServices(), the JSON default is already in place and stays - the order matters, so always register MessagePack first.

Notes

  • Public types only: the contractless resolver requires public entity types. For non-public types, use the JSON serializer from SquidStd.Core (JsonDataSerializer) instead.
  • Attribute-free: ContractlessStandardResolver serializes by member name, so no [MessagePackObject]/[Key] attributes are needed - but member names become part of the payload contract, so renaming a property is a schema change (bump schemaVersion on persisted entities).
  • There is no registration extension - the class is the whole package. Register the same instance for both interfaces so serialize and deserialize agree.

Key types

Type Purpose
MessagePackDataSerializer Contractless MessagePack IDataSerializer/IDataDeserializer.

License

MIT - part of SquidStd.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.41.1 85 8/5/2026
0.41.0 867 7/24/2026
0.40.1 96 7/23/2026
0.40.0 451 7/21/2026
0.39.0 208 7/20/2026
0.38.0 137 7/20/2026
0.37.0 221 7/17/2026
0.36.0 179 7/15/2026
0.35.0 93 7/15/2026
0.34.0 101 7/14/2026
0.33.1 102 7/13/2026
0.33.0 98 7/13/2026
0.32.1 96 7/13/2026
0.32.0 95 7/13/2026
0.31.0 97 7/12/2026
0.30.0 97 7/12/2026
0.29.0 100 7/11/2026
0.28.0 101 7/8/2026
0.27.0 114 7/7/2026
0.26.0 95 7/7/2026
Loading failed