ch-robinson / dotnet-avro

An Avro implementation for .NET
https://engineering.chrobinson.com/dotnet-avro/
MIT License
135 stars 51 forks source link

Support overriding a namespace when generating C# code from Avro schemas #149

Open skovalyova opened 3 years ago

skovalyova commented 3 years ago

Let's assume we have the following AVRO schema example-class.avsc:

{ "name": "Name", "namespace": "Avro.Namespace", "type": "record", "doc": "...", "fields": [ { "doc": "Description", "name": "some_field", "type": "string" } ] }

After calling the dotnet avro generate < example-class.avsc > ExampleClass.cs command, the namespace in the C# class matches the namespace defined in the schema (Avro.Namespace), so I need to rename it manually to fit the rest of C# code. Is it possible to add some parameter to dotnet avro generate command to specify a custom namespace?

For example, the avrogen tool provides similar parameter: --namespace - Map an Avro schema/protocol namespace to a C# namespace. The format is "my.avro.namespace:my.csharp.namespace". May be specified multiple times to map multiple namespaces.