AvroSharp.CodeGen
1.0.0
dotnet add package AvroSharp.CodeGen --version 1.0.0
NuGet\Install-Package AvroSharp.CodeGen -Version 1.0.0
<PackageReference Include="AvroSharp.CodeGen" Version="1.0.0" />
<PackageVersion Include="AvroSharp.CodeGen" Version="1.0.0" />
<PackageReference Include="AvroSharp.CodeGen" />
paket add AvroSharp.CodeGen --version 1.0.0
#r "nuget: AvroSharp.CodeGen, 1.0.0"
#:package AvroSharp.CodeGen@1.0.0
#addin nuget:?package=AvroSharp.CodeGen&version=1.0.0
#tool nuget:?package=AvroSharp.CodeGen&version=1.0.0
AvroSharp.CodeGen
The C# code generation engine behind AvroSharp's source generator, in the AvroSharp.CodeGen namespace. It turns parsed Avro schemas into C# source: records, enums and fixed types with serializers that call AvroWriter/AvroReader directly, with no reflection.
Status: stable. The public API follows semantic versioning: no breaking changes before 2.0. Most projects should reference
AvroSharp.Generatorsinstead, which runs this engine inside the compiler. Use this package to generate code from your own tools.
Documentation · API reference · Code generation guide
Usage
CSharpCodeGenerator.Generate takes the schemas and a CodeGenOptions, and returns one GeneratedSource per named type, and one more in the Apache.Avro compatibility mode:
using AvroSharp.CodeGen;
using AvroSharp.Schemas;
var schemas = new[] { AvroSchema.Parse(File.ReadAllText("order.avsc")) };
var options = new CodeGenOptions { Namespace = "Shop", PropertyNames = PropertyNaming.PascalCase };
foreach (var source in CSharpCodeGenerator.Generate(schemas, options))
{
File.WriteAllText(Path.Combine("Generated", source.HintName), source.Text);
}
SchemaFileSet.Parse parses several schema files together, as the source generator and the avrosharp tool do, so a file may refer to named types that another file defines.
CodeGenOptions also selects namespace mappings (NamespaceMap), how logical types are mapped (LogicalTypes), the Apache.Avro compatibility mode (ApacheCompatible), property names (PropertyNames), whether the target framework has DateOnly/TimeOnly (TargetHasDateOnly), and the C# version the code may use (NullableAnnotations, which needs C# 8; LanguageVersion, 7 or later, where 7 means C# 7.2 or later and 11 or later adds IAvroSerializable<T> on .NET 8 and later).
The generated code needs the AvroSharp package at runtime.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. 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 was computed. 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 was computed. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
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 |
|---|---|---|
| 1.0.0 | 67 | 10/3/2026 |
| 1.0.0-rc.1 | 40 | 10/1/2026 |
| 0.2.0 | 637 | 9/29/2026 |
| 0.1.1 | 73 | 9/28/2026 |