0.7.0 · Stable
Avro Source Generator
Avro Source Generator is an incremental C# source generator for Avro schemas, protocols, and IDL. It generates models during compilation and integrates with your editor and dotnet build.
Getting started · Kafka and Schema Registry
Generated C# models
Generated models support partial records or classes, nullable reference types, init accessors, and required properties, depending on your project’s C# version. Add application-specific members through partial declarations.
var user = new User
{
Name = "Ada",
Email = "ada@example.com",
};
Runtime targets
The generator supports Apache.Avro, Chr.Avro, and library-neutral models. Select the target that matches your application’s serialization library. The Apache and Chr targets include their respective runtime integration members.
Schema handling and build behavior
- Three input formats: JSON schemas (
.avsc), JSON protocols (.avpr), and human-readable Avro IDL (.avdl). - References: share named types through IDL imports or resolve references between supplied files with deferred binding.
- Independent generation: a broken schema does not stop unrelated valid inputs from generating. Diagnostics identify the invalid input.
- Incremental builds: the generator runs in the editor and as part of compilation.
- MSBuild configuration: control visibility, records or classes, language features, and reference resolution.
Documentation
| Topic | Guide |
|---|---|
| Add the generator to an existing project | Getting started |
| Share definitions and import schemas | Schemas and imports |
| Understand properties, types, and unions | Generated models |
| Choose Apache.Avro, Chr.Avro, or standalone models | Avro libraries |
| Customize generated code | Configuration |
| Produce and consume generated models | Kafka and Schema Registry |
| Fix a warning or error | Troubleshooting |