AvroGen.NET.Tool
0.1.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet tool install --global AvroGen.NET.Tool --version 0.1.0
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.1.0
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=AvroGen.NET.Tool&version=0.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
nuke :add-package AvroGen.NET.Tool --version 0.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
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 nameVersion
: The schema version to use (optional, defaults to latest)SchemaRegistryUrl
: URL of your Schema Registry instanceOutputPath
: 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
- Clone the repository:
git clone https://github.com/iiitpux/AvroGen.NET.git
- 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
- Apache Avro for the Avro serialization system
- Confluent Schema Registry for schema management
- The .NET community for inspiration and support
Local Development
Requirements
- .NET 8.0 SDK
- Docker and Docker Compose (for local Schema Registry)
Environment Setup
- Start local Schema Registry:
cd infrastructure
./start.ps1
- Stop local environment:
cd infrastructure
./stop.ps1
Project Structure
src/
- source codeAvroGen.NET/
- main libraryAvroGen.NET.Tool/
- command line tool
tests/
- testsAvroGen.NET.UnitTests/
- unit testsAvroGen.NET.IntegrationTests/
- integration tests
examples/
- usage examplesinfrastructure/
- files for local developmentdocs/
- documentationbuild/
- build artifactsschemas/
- Avro schema examples
Configuration Options
Subject
: Schema Registry subject nameVersion
: Schema versionSchemaRegistryUrl
: Schema Registry URLOutputPath
: Generated files pathNamespace
: Namespace for generated classesGenerateAsync
: Generate async serialization methodsGenerateEquality
: Generate equality comparison methodsGenerateJsonMethods
: Generate JSON serialization methods
Contributing
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
Acknowledgments
- Apache Avro for the Avro serialization system
- Confluent Schema Registry for schema management
- The .NET community for inspiration and support
License
MIT
Product | Versions 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.