You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Thiruvalluvan M. G. (JIRA)" <ji...@apache.org> on 2018/12/30 04:23:00 UTC

[jira] [Updated] (AVRO-1899) PascalCase for property names generated by avrogen for C#

     [ https://issues.apache.org/jira/browse/AVRO-1899?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Thiruvalluvan M. G. updated AVRO-1899:
--------------------------------------
    Component/s: csharp

> PascalCase for property names generated by avrogen for C#
> ---------------------------------------------------------
>
>                 Key: AVRO-1899
>                 URL: https://issues.apache.org/jira/browse/AVRO-1899
>             Project: Apache Avro
>          Issue Type: Improvement
>          Components: csharp
>            Reporter: Xtra Coder
>            Priority: Major
>
> Currently (code in branch 1.8) avrogen generates properties in C# data classes 1:1 as they are defined in shema, what results for field named 'favorite_color' in code like following:
>         public string favorite_color {
>             get { return this._favorite_color; }
>             set { this._favorite_color = value; }
>         }
> In general property names should use PascalCasing (see: https://msdn.microsoft.com/en-us/library/ms229043.aspx) and correctly generated code would look like
>         public string FavoriteColor {
>             get { return this._favorite_color; }
>             set { this._favorite_color = value; }
>         }
> Potential change is rather minor:
> .\avro\lang\csharp\src\apache\main\CodeGen\CodeGen.cs : 581
> change
> var mangledName = CodeGenUtil.Instance.Mangle(field.Name);
> to
> var mangledName = CodeGenUtil.Instance.Mangle(AsPropName(field.Name));
> where AsPropName function may look like following
>         public string AsPropName(string name) {
>             return Regex.Replace(name, @"^\S|_\S", match => match.Value.Replace("_","").ToUpper());
>         }



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