Soenneker.Cosmos.Serializer 4.0.2691

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Soenneker.Cosmos.Serializer --version 4.0.2691
                    
NuGet\Install-Package Soenneker.Cosmos.Serializer -Version 4.0.2691
                    
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="Soenneker.Cosmos.Serializer" Version="4.0.2691" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Cosmos.Serializer" Version="4.0.2691" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Cosmos.Serializer" />
                    
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 Soenneker.Cosmos.Serializer --version 4.0.2691
                    
#r "nuget: Soenneker.Cosmos.Serializer, 4.0.2691"
                    
#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 Soenneker.Cosmos.Serializer@4.0.2691
                    
#: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=Soenneker.Cosmos.Serializer&version=4.0.2691
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Cosmos.Serializer&version=4.0.2691
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

Soenneker.Cosmos.Serializer

An Azure Cosmos DB CosmosSerializer backed by System.Text.Json and pooled memory streams.

Installation

dotnet add package Soenneker.Cosmos.Serializer

Use with CosmosClient

using Soenneker.Cosmos.Serializer;
using Soenneker.Utils.MemoryStream.Abstract;
using Soenneker.Utils.MemoryStream.Registrars;

services.AddMemoryStreamUtilAsSingleton();

IMemoryStreamUtil memoryStreams =
    serviceProvider.GetRequiredService<IMemoryStreamUtil>();

var serializer = new CosmosSystemTextJsonSerializer(memoryStreams);

var client = new CosmosClient(
    endpoint,
    accountKey,
    new CosmosClientOptions
    {
        Serializer = serializer
    });

Soenneker.Cosmos.Client already constructs and installs this serializer, so applications using that client utility do not need to configure it again.

JSON behavior

Serialization uses Soenneker.Json.OptionsCollection.JsonOptionsCollection.WebOptions. The same options are used for reads and writes, keeping property naming and configured converters consistent. This replaces the Cosmos SDK's default Newtonsoft.Json serializer, so verify stored JSON compatibility before switching an existing container.

Stream ownership

ToStream returns a positioned stream owned by the Cosmos SDK or direct caller. The recipient must dispose it. If serialization fails before the stream is returned, the serializer disposes the pooled stream itself.

FromStream<T> consumes and disposes the supplied stream after deserialization. The exception is FromStream<Stream>, which returns the original stream without disposing it and transfers ownership to the caller. An empty MemoryStream deserializes to default(T).

Serialization and deserialization failures propagate to the caller. The adapter uses the synchronous CosmosSerializer contract, so it does not accept a cancellation token.

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

Showing the top 1 NuGet packages that depend on Soenneker.Cosmos.Serializer:

Package Downloads
Soenneker.Cosmos.Client

A utility library for Azure Cosmos client accessibility

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.0.2704 0 8/31/2026
4.0.2703 0 8/31/2026
4.0.2702 32 8/31/2026
4.0.2701 40 8/31/2026
4.0.2700 30 8/31/2026
4.0.2699 84 8/30/2026
4.0.2698 94 8/30/2026
4.0.2696 40 8/30/2026
4.0.2694 105 8/30/2026
4.0.2693 48 8/30/2026
4.0.2691 31 8/30/2026
4.0.2690 204 8/30/2026
4.0.2688 49 8/29/2026
4.0.2687 35 8/29/2026
4.0.2686 123 8/29/2026
4.0.2685 633 8/26/2026
4.0.2684 368 8/26/2026
4.0.2683 92 8/25/2026
4.0.2682 486 8/22/2026
4.0.2681 334 8/21/2026
Loading failed

Document and secure Cosmos serialization