AvroGen.NET 0.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package AvroGen.NET --version 0.1.0                
NuGet\Install-Package AvroGen.NET -Version 0.1.0                
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="AvroGen.NET" Version="0.1.0">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AvroGen.NET --version 0.1.0                
#r "nuget: AvroGen.NET, 0.1.0"                
#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.
// Install AvroGen.NET as a Cake Addin
#addin nuget:?package=AvroGen.NET&version=0.1.0

// Install AvroGen.NET as a Cake Tool
#tool nuget:?package=AvroGen.NET&version=0.1.0                

AvroGen.NET

Русская версия

AvroGen.NET is a library for automatic generation of C# classes from Avro schemas stored in Confluent Schema Registry. It provides both a programmatic API for integration into your applications and a command-line tool for quick class generation.

Installation

NuGet Package

dotnet add package AvroGen.NET

Command Line Tool

dotnet tool install --global --add-source ./nupkg AvroGen.NET.Tool

Usage

Programmatic Way

using AvroGen.NET;

var config = new SchemaGeneratorConfig
{
    SchemaRegistryUrl = "http://localhost:8081",
    OutputDirectory = "./generated"
};

var generator = new SchemaGenerator(config);
await generator.GenerateClassFromSchema("user-value", 1);

Command Line Way

After installing the global tool, you can use it to generate classes:

avrogennet --schema-registry-url http://localhost:8081 --subject user-value --schema-version 1 --output ./generated

Parameters:

  • --schema-registry-url - Schema Registry URL
  • --subject - Schema subject name in Schema Registry
  • --schema-version - Schema version
  • --output - Path for saving generated class

Features

  • Automatic C# class generation from Avro schemas
  • Integration with Schema Registry
  • MSBuild task for seamless build process integration
  • Support for schema versioning
  • Clean and maintainable generated code
  • NuGet package for easy distribution

Configuration Options

  • Subject: The Schema Registry subject name
  • Version: The schema version to use (optional, defaults to latest)
  • SchemaRegistryUrl: URL of your Schema Registry instance
  • OutputPath: Directory where generated classes will be placed

Example

Here's a complete example of how to use AvroGen.NET in your project:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
    <GeneratedCodePath>$(MSBuildProjectDirectory)\Generated</GeneratedCodePath>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="AvroGen.NET" Version="1.0.0" />
    <PackageReference Include="Confluent.SchemaRegistry" Version="2.3.0" />
    <PackageReference Include="Confluent.SchemaRegistry.Serdes.Avro" Version="2.3.0" />
  </ItemGroup>

  <ItemGroup>
    <AvroSchema Include="Schemas\test-schema.avsc">
      <Subject>test-schema-value</Subject>
      <Version>1</Version>
      <SchemaRegistryUrl>http://localhost:8081</SchemaRegistryUrl>
      <OutputPath>$(GeneratedCodePath)</OutputPath>
    </AvroSchema>
  </ItemGroup>
</Project>

Requirements

  • .NET 8.0 or later
  • Access to a Schema Registry instance
  • MSBuild 17.0 or later

Building from Source

  1. Clone the repository:
git clone https://github.com/iiitpux/AvroGen.NET.git
  1. Build the solution:
dotnet build

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

Local Development

Requirements

  • .NET 8.0 SDK
  • Docker and Docker Compose (for local Schema Registry)

Environment Setup

  1. Start local Schema Registry:
cd infrastructure
./start.ps1
  1. Stop local environment:
cd infrastructure
./stop.ps1

Project Structure

  • src/ - source code
    • AvroGen.NET/ - main library
    • AvroGen.NET.Tool/ - command line tool
  • tests/ - tests
    • AvroGen.NET.UnitTests/ - unit tests
    • AvroGen.NET.IntegrationTests/ - integration tests
  • examples/ - usage examples
  • infrastructure/ - files for local development
  • docs/ - documentation
  • build/ - build artifacts
  • schemas/ - Avro schema examples

Configuration Options

  • Subject: Schema Registry subject name
  • Version: Schema version
  • SchemaRegistryUrl: Schema Registry URL
  • OutputPath: Generated files path
  • Namespace: Namespace for generated classes
  • GenerateAsync: Generate async serialization methods
  • GenerateEquality: Generate equality comparison methods
  • GenerateJsonMethods: Generate JSON serialization methods

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a Pull Request

Acknowledgments

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.

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.5.47 101 1/23/2025
0.5.4 97 12/26/2024
0.3.15 91 12/22/2024
0.3.12 86 12/21/2024
0.2.0 127 12/21/2024
0.1.0 96 12/21/2024