AvroSharp

A high-performance, Native AOT-friendly .NET implementation of the Apache Avro™ specification: schemas, binary and JSON encoding, schema evolution, source-generated serializers, container files with every codec, single-object encoding and schema-registry framing.

Get started · Code generation · Command-line tool · API reference · Benchmarks · Compared with Apache.Avro · GitHub

Status: an early preview (0.x). The API may still change before 1.0.

Why AvroSharp

  • Fast: faster than Apache.Avro on every benchmark, and never allocates more: generated records read 3.95× and write 6.18× faster, and container files read up to 22× faster. Benchmarks
  • Generated at build time: a source generator turns .avsc files into C# types with serializers, with no reflection, so they work with Native AOT and trimming. Code generation
  • Complete: Avro 1.12 schemas, binary and JSON encoding, schema resolution, container files with every codec, single-object encoding, canonical forms and fingerprints, and every logical type. Guide
  • Interoperable: the same bytes as Apache.Avro and Apache Avro Java, checked by tests in both directions, with the specification followed where Apache.Avro deviates. Compared with Apache.Avro
  • Safe with untrusted data: bounded memory and nesting for hostile files, messages and schemas, and fuzzed every night. Hostile input

Packages

Package What it is Docs
AvroSharp The runtime: schemas, readers and writers, the generic model, container files, messages and streams Guide, API
AvroSharp.Generators The source generator: C# types from .avsc files as the project builds Code generation
AvroSharp.Tool avrosharp, the dotnet tool: code generation, canonical forms and fingerprints from the command line Command-line tool
AvroSharp.Codecs The snappy, zstandard, bzip2 and xz codecs, fully managed Codecs
AvroSharp.CodeGen The code generation engine, for your own tools API

Guides

  • Getting started: parse a schema, write and read values, read an older version of the data, JSON.
  • Object container files: writing and reading .avro files, synchronously and asynchronously, with any codec.
  • Single-object encoding and schema registries: messages that carry their schema's fingerprint or ID, with Confluent, Apicurio and AWS Glue framing.
  • Streams of objects: objects one after another, for sockets and pipes.
  • Code generation: the source generator, its MSBuild properties, type mapping, schema evolution, and moving from avrogen.
  • The avrosharp tool: gen, schema canonical and schema fingerprint, exit codes, and use in CI.
  • Samples: runnable programs for the main APIs.

Reference

Apache Avro, Avro and Apache are trademarks of The Apache Software Foundation. AvroSharp is an independent project and is not endorsed by or affiliated with the Apache Software Foundation.