Daniel
Daniel

Reputation: 1491

Avro AVSC to C# classes

How can I generate C# classes from Avsc files so that these classes can be ingested by AvroSerializer in SchemaRegistry.Serdes.Avro. Like the example file in https://github.com/confluentinc/confluent-kafka-dotnet/blob/master/examples/AvroSpecific/User.cs

Upvotes: 2

Views: 25

Answers (1)

Serg.ID
Serg.ID

Reputation: 1967

There is a Apache.Avro.Tools NuGet that should be installed as dotnet CLI tool. You can install it globally using:

dotnet tool install --global Apache.Avro.Tools --version 1.12.0

Using this tool you can generate C# classes from your Avro schema file. For example:

avrogen -s <schema-file> <output-directory>

Where <schema-file> a full path to your Avro schema file and <output-directory> with the directory where you want the generated C# classes to be saved. You can use additional parameter --skip-directories if you want to have a flat structure of the output.

Upvotes: 3

Related Questions