You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2018/03/11 00:14:00 UTC

[jira] [Commented] (AVRO-2156) Allow custom namespace for C# generated code

    [ https://issues.apache.org/jira/browse/AVRO-2156?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16394370#comment-16394370 ] 

ASF GitHub Bot commented on AVRO-2156:
--------------------------------------

blachniet opened a new pull request #297: AVRO-2156: Map Avro namespace to C# namespaces during code generation
URL: https://github.com/apache/avro/pull/297
 
 
   [AVRO-2156](https://issues.apache.org/jira/browse/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:
   
   ```csharp
   // 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:
   
   
   ```csharp
   // MD5.cs
   namespace Sample.Models
   {
       public partial class MD5 : SpecificFixed //...
   }
   ``` 
   
   I am open to any suggestions, whether implementation details or command line interface. Thanks!

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Allow custom namespace for C# generated code
> --------------------------------------------
>
>                 Key: AVRO-2156
>                 URL: https://issues.apache.org/jira/browse/AVRO-2156
>             Project: Avro
>          Issue Type: New Feature
>          Components: csharp
>    Affects Versions: 1.8.2
>            Reporter: Brian Lachniet
>            Priority: Major
>
> The namespace used in Avro schemas/protocols does not always map nicely to a standard C# namespace. Avrogen (the C# code generator) currently uses the Avro namespace as the C# namespace. I propose that we update the avrogen utility to allow the user to override the namespace used in the generated code via a command line parameter.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)