AvroSharp.Generators 0.1.1

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

AvroSharp.Generators

A C# source generator that turns Avro schema files (.avsc) into C# types with serializers for AvroSharp. The generated code uses no reflection, so it works with Native AOT and trimming.

Status: early development, not yet released.

Usage

Reference the package and pass your schema files to the compiler as AdditionalFiles:

<ItemGroup>
  <PackageReference Include="AvroSharp.Generators" Version="..." />
  <AdditionalFiles Include="Schemas\*.avsc" />
</ItemGroup>

The package brings in the AvroSharp runtime package. Each named type becomes a C# type: a record becomes a partial class, an enum a C# enum, and a fixed type a class that wraps exactly its number of bytes. Records get serializers that call AvroWriter/AvroReader directly:

byte[] bytes = order.ToAvroBytes();
var copy = shop.Order.FromAvroBytes(bytes);
var upgraded = shop.Order.FromAvroBytes(oldBytes, writerSchema);   // schema evolution

Options (MSBuild properties)

Property Values Effect
AvroSharpNamespace a C# namespace The namespace of types without an Avro namespace
AvroSharpPropertyNames avro Keeps the Avro field names, as Apache's avrogen does, instead of PascalCase
AvroSharpLogicalTypes raw Keeps logical types as their underlying types instead of DateOnly, Guid, decimal, …
AvroSharpApacheCompatible true Generated types also implement Apache.Avro's ISpecificRecord (requires a reference to Apache.Avro)

Requirements

The generator needs the .NET 10 SDK or Visual Studio 2026, because it runs AvroSharp inside the compiler (see #20). The generated code works on every target AvroSharp supports: .NET 8, 9 and 10, .NET Standard 2.0 and 2.1, and .NET Framework.

See the repository README for unions, logical types and the Apache.Avro compatibility mode.

There are no supported framework assets in this 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 37 9/28/2026
0.1.0 40 9/28/2026