如何从 Avsc 文件生成 C# 类,以便这些类可以被 SchemaRegistry.Serdes.Avro 中的 AvroSerializer 提取。如https://github.com/confluentinc/confluent-kafka-dotnet/blob/master/examples/AvroSpecific/User.cs中的示例文件所示
如何从 Avsc 文件生成 C# 类,以便这些类可以被 SchemaRegistry.Serdes.Avro 中的 AvroSerializer 提取。如https://github.com/confluentinc/confluent-kafka-dotnet/blob/master/examples/AvroSpecific/User.cs中的示例文件所示
有一个
Apache.Avro.Tools
NuGet应该作为 dotnet CLI 工具安装。您可以使用以下命令全局安装它:dotnet tool install --global Apache.Avro.Tools --version 1.12.0
使用此工具,您可以从 Avro 模式文件生成 C# 类。例如:
avrogen -s <schema-file> <output-directory>
其中,是
<schema-file>
Avro 模式文件的完整路径以及<output-directory>
要保存生成的 C# 类的目录。--skip-directories
如果希望输出具有平面结构,则可以使用附加参数。