Excalibur.Dispatch.Serialization.Protobuf 3.0.0-alpha.26

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

Excalibur.Dispatch.Serialization.Protobuf

Opt-in Protocol Buffers serialization support for the Excalibur framework.

Purpose

Provides Protocol Buffers (Protobuf) serialization for:

  • Google Cloud Platform (GCP) interoperability
  • AWS service integration requiring Protobuf
  • High-performance binary protocols
  • External systems using .proto schema definitions

Requirements Alignment

This package satisfies the following framework requirements:

  • R0.14: Serializer segregation (opt-in package, NOT in Excalibur.Dispatch)
  • R0.5: Transitive bloat guard (pay-for-play; only referenced when explicitly needed)
  • R9.44: Internal wire uses MemoryPack (Core unchanged; Protobuf is opt-in only)
  • R9.46: Opt-in binary alternatives (this package provides Protobuf as opt-in)
  • R9.47: AOT/trim safety (source-generated Protobuf types are trim-safe)

Installation

dotnet add package Excalibur.Dispatch.Serialization.Protobuf

Usage

Basic Registration

using Excalibur.Dispatch.Serialization.Protobuf;

// In your service configuration (Program.cs or Startup.cs):
services.AddDispatch()
    .AddProtobufSerialization(); // Opt-in to Protobuf support

Configure Protobuf Options

services.AddProtobufSerialization(options =>
{
    // Wire format: Binary (default) or JSON
    options.WireFormat = ProtobufWireFormat.Binary;

    // Ignore missing fields during deserialization (default: true)
    options.IgnoreMissingFields = true;

    // Preserve unknown fields (default: false)
    options.PreserveUnknownFields = false;
});

Message Definition

Your message types must implement Google.Protobuf.IMessage and have source-generated parsers:

using Google.Protobuf;

// Example: Generated from .proto file
public partial class UserCreatedEvent : IMessage<UserCreatedEvent>
{
    // Source-generated Protobuf code
}

Serialization Example

using Excalibur.Dispatch.Abstractions.Serialization;

public class UserEventHandler
{
    private readonly IMessageSerializer _serializer;

    public UserEventHandler(IMessageSerializer serializer)
    {
        _serializer = serializer;
    }

    public async Task HandleAsync(UserCreatedEvent evt, CancellationToken ct)
    {
        // Serialize to binary Protobuf
        byte[] data = _serializer.Serialize(evt);

        // Deserialize from binary
        var deserialized = _serializer.Deserialize<UserCreatedEvent>(data);
    }
}

Package Dependencies

  • Google.Protobuf - Protocol Buffers runtime
  • Excalibur.Dispatch.Abstractions - Core contracts only (no Excalibur.Dispatch dependency)
  • MemoryPack - Used internally per R9.44 (envelope/headers remain MemoryPack)

AOT Compatibility

Native AOT compatible with source-generated Protobuf types.

Ensure your .proto files are compiled with protoc to generate C# code, and the generated types will be trim-safe.

Wire Formats

options.WireFormat = ProtobufWireFormat.Binary;
  • Compact binary format
  • Fastest serialization/deserialization
  • Best for internal/transport use

JSON

options.WireFormat = ProtobufWireFormat.Json;
  • Human-readable JSON representation
  • Useful for debugging or external API boundaries
  • Slower than binary format

When to Use This Package

Use Protobuf serialization when:

  • Integrating with GCP services (Cloud Pub/Sub, Cloud Functions, etc.)
  • AWS services require Protobuf (EventBridge, Kinesis with Protobuf schema)
  • External systems expose Protobuf schemas (.proto files)
  • You need schema evolution with backward/forward compatibility

Do NOT use Protobuf when:

  • Internal Excalibur.Dispatch messaging (use MemoryPack - the default)
  • Public HTTP/REST APIs (use System.Text.Json per R9.45)
  • No Protobuf schema requirements exist

Architecture Notes

Per Excalibur framework requirements:

  1. Excalibur.Dispatch MUST NOT reference this package (R0.14 compliance)
  2. This package is pay-for-play (R0.5: no transitive bloat)
  3. MemoryPack remains the internal wire format (R9.44)
  4. System.Text.Json is used for public edges (R9.45)
  5. This package is opt-in only (R9.46)

Performance Characteristics

  • Serialization: ~100-500 ns/op (binary), ~1-5 μs/op (JSON)
  • Allocations: Minimal (reuses buffers where possible)
  • Throughput: ~1-5 million msg/sec (binary), ~200k-1M msg/sec (JSON)

Benchmark results available in: management/perf/perf-baselines.json

Schema Evolution

Protobuf supports schema evolution via:

  • Field numbers: Never reuse field numbers
  • Reserved fields: Mark removed fields as reserved
  • Optional fields: Use optional for nullable fields
  • Unknown fields: Preserved if PreserveUnknownFields = true

Example .proto:

syntax = "proto3";

message UserCreatedEvent {
  string user_id = 1;
  string email = 2;
  reserved 3; // Removed field
  // New field with number 4
  string full_name = 4;
}

License

This package is licensed under the same licenses as the Excalibur framework:

  • Excalibur License 1.0
  • GNU Affero General Public License v3.0 or later (AGPL-3.0)
  • Server Side Public License v1.0 (SSPL-1.0)
  • Apache License 2.0

See LICENSE files in project root for details.

Support

For issues, questions, or contributions, visit:

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  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
3.0.0-alpha.59 0 3/24/2026
3.0.0-alpha.51 30 3/19/2026
3.0.0-alpha.48 30 3/18/2026
3.0.0-alpha.45 30 3/17/2026
3.0.0-alpha.44 39 3/16/2026
3.0.0-alpha.43 37 3/16/2026
3.0.0-alpha.42 34 3/16/2026
3.0.0-alpha.41 43 3/16/2026
3.0.0-alpha.33 41 3/15/2026
3.0.0-alpha.31 35 3/15/2026
3.0.0-alpha.26 39 3/5/2026
3.0.0-alpha.19 45 2/26/2026