ProtoCache 0.1.1

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

ProtoCache .NET

ProtoCache is a flat binary cache format generated from Proto3 schemas. It supports direct field access without first materializing a complete object graph and includes compact map support. The portable schema contract is defined by the ProtoCache schema specification.

Protobuf ProtoCache FlatBuffers
Data Size 574B 780B 1296B
Decode + Traverse 2805ns 1139ns 2353ns

The benchmark is available in ProtoCache.Benchmark. Numeric and bytes access is zero-copy. Reading strings and constructing some object-oriented wrappers may allocate, so the benchmark represents low-deserialization-overhead access rather than universally zero-allocation traversal.

Requirements

  • .NET 10 or later.
  • protoc for Protobuf code generation.
  • protoc-gen-pc.net from ProtoCache C++ v1.2.1 for typed ProtoCache accessors.

Installation

dotnet add package ProtoCache --version 0.1.0

Code generation

ProtoCache 0.1.0 is paired with protoc-gen-pc.net from ProtoCache C++ v1.2.1. Follow the C++ repository build and install instructions, then invoke the plugin through protoc:

protoc --pc.net_out=generated schema.proto

The schema must specify option csharp_namespace. Protobuf classes and ProtoCache accessors must use different C# namespaces because both generators emit the schema message names. Generate the accessors from a temporary schema copy that changes only csharp_namespace.

Basic API

using Pb = Example.Protobuf;
using Pc = Example.ProtoCache;

Pb.Main message = Pb.Main.Parser.ParseFrom(protobufBytes);
byte[] cache = global::ProtoCache.ProtoCache.Serialize(message);

var root = new Pc.Main(cache);
int count = root.Count;
ReadOnlySpan<byte> data = root.Data;
byte[] ownedData = root.Data.ToArray();

ProtoCache.Serialize(Google.Protobuf.IMessage) is the supported write path. Reading uses generated, strongly typed accessors. Numeric fields and bytes are read directly from the source buffer; call .ToArray() when an independently owned bytes value is required.

Compatibility

Portable schema rules are defined by the C++ repository schema.md. The binary layout is defined by data-format.md.

The .NET binding targets .NET 10 and provides the binding-specific _x_ alias spelling described by the schema document. It does not guarantee Protobuf field presence, oneof active-case semantics, or deterministic map serialization. Generated accessors and producers in other languages must use compatible schemas.

Reflection

The writer uses the descriptor exposed by Google.Protobuf.IMessage internally. The .NET runtime does not provide schema-reflection or dynamic-message reading APIs; reading requires generated, strongly typed accessors.

License

BSD 3-Clause

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.1.1 80 8/5/2026
0.1.0 80 7/29/2026
0.1.0-preview.1 69 7/28/2026