AvroGen.NET.Tool 0.5.47

dotnet tool install --global AvroGen.NET.Tool --version 0.5.47                
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest # if you are setting up this repo
dotnet tool install --local AvroGen.NET.Tool --version 0.5.47                
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=AvroGen.NET.Tool&version=0.5.47                
nuke :add-package AvroGen.NET.Tool --version 0.5.47                

AvroGen.NET

MSBuild-based tool for generating C# classes from Avro schemas stored in Schema Registry.

Russian version

Features

  • Automatic C# class generation from Avro schemas
  • Integration with Confluent Schema Registry
  • MSBuild integration for automatic code generation during build
  • Command-line tool for manual code generation
  • Support for all Avro data types
  • Namespace customization
  • Generated classes are compatible with Confluent.SchemaRegistry.Serdes.Avro

Installation

NuGet Package (MSBuild Integration)

dotnet add package AvroGen.NET

Command Line Tool

dotnet tool install -g AvroGen.NET.Tool

Usage

Add the following to your project file:

<ItemGroup>
  <AvroSchema Include=".">
    <SchemaRegistryUrl>http://localhost:8081</SchemaRegistryUrl>
    <Subject>your-schema-subject</Subject>
    <Version>1</Version>
    <OutputDirectory>$(MSBuildProjectDirectory)\Generated</OutputDirectory>
    <Namespace>$(RootNamespace).Generated</Namespace>
  </AvroSchema>
</ItemGroup>

The classes will be generated automatically during build. You can also generate them manually by running:

dotnet build

Command Line Tool

For one-time generation or when you need more control, you can use the command line tool:

# Generate from latest schema version
avrogennet --schema-registry-url http://localhost:8081 --subject user-value --output-directory ./Generated

# Generate from specific schema version
avrogennet --schema-registry-url http://localhost:8081 --subject user-value --version 1 --output-directory ./Generated --namespace MyCompany.Models

Available options:

  • --schema-registry-url (required): URL of the Schema Registry
  • --subject (required): Schema Registry subject name
  • --version (optional): Schema version (defaults to latest)
  • --output-directory (optional): Output directory (defaults to ./Generated)
  • --namespace (optional): Namespace for generated classes (defaults to subject name)

Configuration

The AvroSchema item supports the following metadata:

  • SchemaRegistryUrl - URL of the Schema Registry
  • Subject - Schema Registry subject name
  • Version - Schema version (optional, defaults to latest)
  • OutputDirectory - Directory where the generated classes will be placed
  • Namespace - Namespace for generated classes (optional, defaults to subject name)

Example

Check out the example project for a complete working example.

How it works

  1. During build, AvroGen.NET connects to the specified Schema Registry
  2. Retrieves the Avro schema for the specified subject and version
  3. Generates C# classes that match the schema structure
  4. Places generated files in the specified output directory
  5. Includes generated files in compilation

Generated classes:

  • Implement ISpecificRecord interface from Apache.Avro
  • Support serialization/deserialization with Confluent.SchemaRegistry.Serdes.Avro
  • Include all necessary properties and data types from the Avro schema
  • Maintain schema compatibility for seamless integration with Kafka

License

MIT

Product Compatible and additional computed target framework versions.
.NET 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last updated
0.5.47 186 1/23/2025
0.5.4 188 12/26/2024
0.3.15 134 12/22/2024
0.3.12 143 12/21/2024
0.2.0 161 12/21/2024
0.1.0 130 12/21/2024