Avro.Autofill
0.9.7
dotnet add package Avro.Autofill --version 0.9.7
NuGet\Install-Package Avro.Autofill -Version 0.9.7
<PackageReference Include="Avro.Autofill" Version="0.9.7"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
<PackageVersion Include="Avro.Autofill" Version="0.9.7" />
<PackageReference Include="Avro.Autofill"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add Avro.Autofill --version 0.9.7
#r "nuget: Avro.Autofill, 0.9.7"
#:package Avro.Autofill@0.9.7
#addin nuget:?package=Avro.Autofill&version=0.9.7
#tool nuget:?package=Avro.Autofill&version=0.9.7
Avro.Autofill
A C# source generator and analyzer for Apache Avro serialization in Kafka. Automatically generates Get() and Put() methods and Avro schemas for ISpecificRecord implementations.
Features
Automatic Code Generation - Generates boilerplate serialization code
Live Validation - Real-time errors for unsupported types in the IDE
Schema Generation - Optionally generates Avro schemas at compile time
Type Safety - Compile-time validation of property types
Zero Runtime Dependencies - Only development-time dependency
Quick Start
1. Mark your class with [AvroAutofill]
using Avro.Autofill;
using Avro.Specific;
[AvroAutofill] // Generates Get(), Put(), and Schema
public partial class Person : ISpecificRecord
{
public int Age { get; set; }
public string Name { get; set; } = string.Empty;
public DateTime BirthDate { get; set; }
public List<string> Hobbies { get; set; } = [];
}
2. The source generator creates
public partial class Person
{
private static readonly Schema Cached = Schema.Parse(AvroSchemaGen.GenerateSchema(typeof(Person)));
[AvroIgnore]
public Schema Schema { get; } = Cached;
public object Get(int fieldPos)
{
return fieldPos switch
{
0 => Age,
1 => Name,
2 => BirthDate,
3 => Hobbies,
_ => throw new ArgumentOutOfRangeException(...)
};
}
public void Put(int fieldPos, object fieldValue)
{
switch (fieldPos)
{
case 0: Age = (int)fieldValue; break;
case 1: Name = (string)fieldValue; break;
case 2: BirthDate = (DateTime)fieldValue; break;
case 3: Hobbies = (List<string>)fieldValue; break;
default: throw new ArgumentOutOfRangeException(...);
}
}
}
Supported Types
Primitives
int,long,float,double,bool,stringuint(serialized aslong)ulong(serialized asbytes)decimal(serialized asdouble)byte[]Guid(uuid)
Date/Time
DateTime(timestamp-millis)DateTimeOffset(timestamp-millis)DateOnly(timestamp-millis)
Collections
T[]- ArraysList<T>,HashSet<T>IEnumerable<T>,ICollection<T>,IList<T>Dictionary<string, T>,IDictionary<string, T>(string keys only)
Complex Types
- User-defined classes and structs
- Enums
- Nullable types:
int?,DateTime?,MyEnum?
Nested Types
[AvroAutofill]
public partial class Person : ISpecificRecord
{
public string Name { get; set; } = string.Empty;
public Address HomeAddress { get; set; } = new();
public List<Address> PreviousAddresses { get; set; } = [];
}
[AvroAutofill]
public partial class Address : ISpecificRecord
{
public string Street { get; set; } = string.Empty;
public string City { get; set; } = string.Empty;
}
Live Type Validation
The analyzer provides real-time errors for unsupported types:
[AvroAutofill]
public partial class MyClass : ISpecificRecord
{
// ❌ ERROR: Type 'HttpClient' from namespace 'System.Net.Http' is not supported in Avro schema
public HttpClient Client { get; set; }
// ❌ ERROR: Delegate type 'Func' from namespace 'System' is not supported in Avro schema
public Func<string, int> Converter { get; set; }
}
Excluding Properties
Use [AvroIgnore] to exclude properties from serialization:
[AvroAutofill]
public partial class Person : ISpecificRecord
{
public string Name { get; set; } = string.Empty;
[AvroIgnore]
public Func<string, int> Converter { get; set; } // Won't be serialized
}
Schema Generation Options
Generate schema (default)
[AvroAutofill] // or [AvroAutofill(true)]
public partial class Person : ISpecificRecord { }
Skip schema generation
[AvroAutofill(false)]
public partial class Person : ISpecificRecord { }
## Requirements
- .NET Standard 2.0 or later
- C# 9.0 or later (for source generators)
- Apache.Avro NuGet package (for runtime)
## Contributing
Contributions are welcome! Please open an issue or pull request on [GitHub](https://github.com/DavidHade/AvroAutofill).
## License
MIT License - see [LICENSE](LICENSE) for details.
| 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 was computed. 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. |
-
.NETStandard 2.0
- No dependencies.
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.9.7 | 141 | 2/17/2026 |