ViShap.Viper 1.0.3

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

ViShap.Viper

A binary serializer for .NET 10. Viper writes objects as self-describing frames, reads them from memory, streams and pipes, and can compress, checksum and encrypt a frame. It is built to read bytes it does not trust: every declared length, count and nesting level is bounded before anything is allocated for it, and every failure is an exception from one hierarchy.

This is the meta-package. It ships no code of its own; it references the three packages that do:

Package Contains
ViShap.Viper.Core the attributes, the algorithm and key contracts, the exception hierarchy
ViShap.Viper.Serialization the serializer, its options and limits, the built-in algorithms and key providers, the diagnostics
ViShap.Viper.Generator the build-time source generator of type contracts; it runs in the compiler and ships nothing with your application
dotnet add package ViShap.Viper

Getting started

using ViShap.Viper;

var serializer = new BinarySerializer();

var order = new Order
{
    Id = 1001,
    Customer = "Ada Lovelace",
    Lines = [new OrderLine { Sku = "ANL-1", Quantity = 2 }]
};

byte[] bytes = serializer.Serialize(order);
Order? copy = serializer.Deserialize<Order>(bytes);

Console.WriteLine(copy!.Lines[0].Sku);

public sealed class Order
{
    public int Id { get; set; }
    public string Customer { get; set; } = "";
    public List<OrderLine> Lines { get; set; } = [];
}

public sealed class OrderLine
{
    public string Sku { get; set; } = "";
    public int Quantity { get; set; }
}

Serialize returns one frame: a header that records the format version and any compression, checksum and encryption, followed by the payload. Deserialize reads all of that from the bytes.

In a file-based app (dotnet run app.cs), which is published with native AOT unless it says otherwise, Viper's reflection path is off and this example raises a BinaryConfigurationException: add #:property ViperReflectionEnabled=true at the top of the file, or describe the types with a context.

What it offers

  • Buffers, streams and pipes. byte[], IBufferWriter<byte>, pooled payloads, ReadOnlySpan<byte>, ReadOnlySequence<byte>, Stream and System.IO.Pipelines, with asynchronous methods, Populate into an existing object, and a stream of frames.
  • Explicit layouts. Positional by default; keyed contracts with [BinaryContract] and [BinaryKey(n)] so a type can evolve without breaking stored data.
  • Declared polymorphism. [BinaryUnion(tag, typeof(Derived))]; only tags travel, never type names.
  • Shared and cyclic references with PreserveReferences().
  • Data protection. Deflate and Brotli compression, CRC-32 and XXH3 checksums, AES-256-GCM and ChaCha20-Poly1305 encryption with an authenticated header, key providers with key ids, and RequireEncryption and RequireChecksum policies.
  • Two formats. V1, the self-describing frame, and V0, the headerless payload for protocols that already frame their messages.
  • Limits. Bounds on depth, sizes, cumulative budgets and the size of every phase, checked before the memory they protect is allocated.
  • Diagnostics. BinaryFormatInspector reads a header; BinaryFormatDumper renders a frame as a tree and points at the value that failed.

Documentation

The public API is documented in XML that ships beside the assemblies. Viper is released under the MIT License.

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
1.1.0-rc.1 54 11/17/2026
1.0.4 95 11/16/2026
1.0.3 92 11/16/2026
1.0.2 95 11/13/2026
1.0.1 110 10/27/2026
1.0.0 99 10/26/2026
1.0.0-rc.2 63 10/26/2026
1.0.0-rc.1 76 9/29/2026