Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AVRO-2156: Map Avro namespace to C# namespaces during code generation #297

Merged
merged 1 commit into from Dec 5, 2018

Conversation

blachniet
Copy link
Member

AVRO-2156

Added new optional command line argument, --namespace <my.avro.ns:my.csharp.ns>.

Normally, avrogen.exe uses the namespaces defined in the schema or protocol as the namespace in the generated C# code. This default behavior has not changed as a part of this pull request. However, if the user wishes to replace the Avro namespace with a C#-friendly namespace in the generated code, they can provide the --namespace option.

For example, if this is our protocol:

// sample.avdl
@namespace("org.example.sample")
protocol MySampleProtocol {
    fixed MD5(16);
}

avrogen.exe -p sample.avdl output would produce something like:

// MD5.cs
namespace org.example.sample
{
    public partial class MD5 : SpecificFixed //...
}

If the user wanted a more C#-friendly namespace in the generated code, the could run avrogen.exe -p sample.avdl output --namespace "org.example.sample:Sample.Models" to produce something like:

// MD5.cs
namespace Sample.Models
{
    public partial class MD5 : SpecificFixed //...
}

I am open to any suggestions, whether implementation details or command line interface. Thanks!

@iemejia iemejia added C# and removed C# labels Nov 29, 2018
@dkulp dkulp merged commit 602a2c5 into apache:master Dec 5, 2018
@blachniet blachniet deleted the AVRO-2156 branch January 20, 2019 00:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants