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
<PackageReference Include="Shuttle.Serialization" Version="21.0.1" />
<PackageVersion Include="Shuttle.Serialization" Version="21.0.1" />
<PackageReference Include="Shuttle.Serialization" />
paket add Shuttle.Serialization --version 21.0.1
#r "nuget: Shuttle.Serialization, 21.0.1"
#:package Shuttle.Serialization@21.0.1
#addin nuget:?package=Shuttle.Serialization&version=21.0.1
#tool nuget:?package=Shuttle.Serialization&version=21.0.1
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: usesSystem.Text.Jsonfor serialization.SerializerService: used to manage multipleISerializerinstances.
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 | Versions 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. |
-
net10.0
- Microsoft.Extensions.DependencyInjection (>= 10.0.3)
- Microsoft.Extensions.Options (>= 10.0.3)
- Shuttle.Contract (>= 21.0.1)
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 |