SbeSourceGenerator 1.1.4

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

SBE Source Generator

NuGet License: MIT

A Roslyn incremental source generator that converts FIX Simple Binary Encoding (SBE) XML schemas into high-performance, zero-allocation C# structs. Ideal for real-time market data, trading systems, and any latency-sensitive binary protocol.

Getting Started

  1. Install the package:

    dotnet add package SbeSourceGenerator
    
  2. Add your SBE schema files as AdditionalFiles:

    <ItemGroup>
      <AdditionalFiles Include="Schemas\*.xml" />
    </ItemGroup>
    
  3. Build. Generated code is available at compile time — no runtime reflection, no code-behind files.

Quick Example

// Decode (with groups and varData) — zero-copy via MessageDataReader
if (OrderData.TryParse(buffer, out var reader))
{
    Console.WriteLine($"Order {reader.Data.OrderId} @ {reader.Data.Price}");
    reader.ReadGroups(/* group/varData callbacks */);
}

// Encode (simple message — no groups)
OrderData order = default;
order.OrderId = 42;
order.Price = 100_00;
order.TryEncode(buffer, out int bytesWritten);

// Encode (with groups)
OrderBookData.TryEncode(orderBook, buffer, bids, asks, out int bytesWritten);

Features

  • Zero-copy blittable structs[StructLayout(Explicit)] with [FieldOffset], directly overlay on buffers
  • TryParse / TryEncode — safe decode/encode with zero-copy MessageDataReader and group/varData support
  • Zero-copy decodeTryReadBlock<T> and ReadBlockRef<T> read directly from spans
  • in delegate callbacks — group iteration passes structs by readonly reference (no copies)
  • Schema evolutionTryReadBlock handles blockLength mismatches (forward/backward compat)
  • Big-endian support — automatic byte swapping for big-endian schemas
  • Enums, sets, composites — full SBE type system with optional field support
  • Nested groups — recursive group generation to any depth
  • SpanReader / SpanWriter — embedded sequential binary reader/writer (no manual offset tracking)
  • Cross-schema coexistence — multiple schemas generate isolated namespaces, no conflicts
  • AOT / trimming compatible — no reflection, no dynamic code generation
  • Roslyn diagnosticsSBE001SBE014 for schema validation at build time

Requirements

  • .NET 6.0+ for consumer projects (generator itself targets netstandard2.0)
  • SBE XML schema using the FIX SBE 1.0 namespace (http://fixprotocol.io/2016/sbe)

Performance

All generated code targets zero allocations on hot paths:

  • Structs are stack-allocated value types
  • readonly property getters prevent defensive copies through in/ref readonly
  • Group callbacks use in delegates — no boxing, no struct copies
  • SpanReader/SpanWriter are ref struct with [MethodImpl(AggressiveInlining)]

Documentation

Full documentation at github.com/pedrosakuma/SbeSourceGenerator:

Contributing

Issues and pull requests are welcome at github.com/pedrosakuma/SbeSourceGenerator.

License

Distributed under the MIT License. See LICENSE.txt for details.

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on SbeSourceGenerator:

Package Downloads
B3.EntryPoint.Sbe

Source-generated SBE codecs for the B3 EntryPoint (FIXP 8.4.2) wire protocol.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.6.1 3,471 4/30/2026
1.6.0 107 4/29/2026
1.5.0 123 4/25/2026
1.4.0 90 4/25/2026
1.3.0 106 4/25/2026
1.2.1 95 4/25/2026
1.2.0 92 4/25/2026
1.1.4 242 4/15/2026
1.1.3 98 4/15/2026
1.1.2 112 4/15/2026
1.1.1 91 4/15/2026
1.1.0 93 4/15/2026
1.0.2 244 4/10/2026
1.0.1 99 4/10/2026
1.0.0 96 4/10/2026
0.9.1 94 4/10/2026
0.9.0 93 4/10/2026
0.8.0 96 4/10/2026
0.7.0 97 4/9/2026
0.5.0 98 4/9/2026
Loading failed