Shuttle.Serialization 21.0.1

Prefix Reserved
dotnet add package Shuttle.Serialization --version 21.0.1
                    
NuGet\Install-Package Shuttle.Serialization -Version 21.0.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="Shuttle.Serialization" Version="21.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Shuttle.Serialization" Version="21.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Shuttle.Serialization" />
                    
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 Shuttle.Serialization --version 21.0.1
                    
#r "nuget: Shuttle.Serialization, 21.0.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 Shuttle.Serialization@21.0.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=Shuttle.Serialization&version=21.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Shuttle.Serialization&version=21.0.1
                    
Install as a Cake Tool

Shuttle.Core.Serialization

The Shuttle.Core.Serialization package provides a consistent interface for serializing and deserializing objects.

Installation

dotnet add package Shuttle.Core.Serialization

ISerializer interface

The core of the library is the ISerializer interface:

public interface ISerializer
{
    string Name { get; }
    Task<object> DeserializeAsync(Type type, Stream stream, CancellationToken cancellationToken = default);
    Task<Stream> SerializeAsync(object instance, CancellationToken cancellationToken = default);
}

The following implementation is provided:

  • JsonSerializer: uses System.Text.Json for serialization.
  • SerializerService: used to manage multiple ISerializer instances.

Usage

AddJsonSerializer

To register the JsonSerializer, use the AddJsonSerializer extension method on IServiceCollection:

services.AddJsonSerializer(options => 
{
    options.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
});

The options is of type JsonSerializerOptions.

ISerializerService

The ISerializerService can be used to manage multiple serializers:

public interface ISerializerService
{
    IEnumerable<ISerializer> Serializers { get; }
    ISerializerService Add(ISerializer serializer);
    bool Contains(string name);
    ISerializer Get(string name);
}

You can use the SerializerService implementation to store and retrieve serializers by their Name:

var serializerService = new SerializerService();

serializerService.Add(new JsonSerializer(Options.Create(new JsonSerializerOptions())));

if (serializerService.Contains("Json"))
{
    var serializer = serializerService.Get("Json");
}

Methods

SerializeAsync

Task<Stream> SerializeAsync(object instance, CancellationToken cancellationToken = default);

Returns the object as a Stream.

DeserializeAsync

Task<object> DeserializeAsync(Type type, Stream stream, CancellationToken cancellationToken = default);

Deserializes the Stream into an object of the given Type.

DeserializeAsync<T> (Extension method)

Task<T> DeserializeAsync<T>(Stream stream, CancellationToken cancellationToken = default);

Deserializes the Stream into an object of the given type T.

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 (2)

Showing the top 2 NuGet packages that depend on Shuttle.Serialization:

Package Downloads
Shuttle.Recall

Event sourcing mechanism.

Shuttle.Hopper

Hopper is a flexible enterprise service bus which works with Azure Storage Queues, Amazon SQS, RabbitMQ, Kafka, and Event Hubs through a provider plugin API.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
21.0.1 140 4/15/2026
21.0.1-rc3 196 4/11/2026