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

Kyle Schoonover commented on AVRO-1899:
---------------------------------------

This would break the functionality, not only across the Avro library, but 
things that inherit from it.  I would however, recommend we create something 
like [JsonPropertyAttribute name 
(newtonsoft.com)|https://www.newtonsoft.com/json/help/html/jsonpropertyname.htm]

Update AvroGen with a commandline parameter --PascalProperties.  When the code 
is generated you would see something like:


{code:java}
public class Videogame
{
    [AvroProperty("name")]
    public string Name { get; set; }

    [AvroProperty("release_date")]
    public DateTime ReleaseDate { get; set; }
} {code}

Then we could update to support the serialization / deserialization when these 
are set.

> 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
(v8.20.1#820001)

Reply via email to