Hi, I am using avrogen to generate C# classes from avro schema. And I found 2 problems:
1) when I use your AvroGen tool I end up with the situation when I have field "commandID" and it is translated to C# property "commandID" (in C# class i have the same field as I have in AVRO schema) but if I use avrogen.exe provided by nuget package Apache.Avro.Tools version 1.7.7.4 - in C# class I have field "CommandID" (starts with the capital letter). I expect more convenient behavior from your .Net Core version also.
2) I have in AVRO schema different namespaces and if I want to generate C# classes from this schema I get an error: Exception occurred. Undefined name: [type name]
Try to run AvroGen tool with my schema
schema.zip
avrogen.dll version: 1.7.7.4
Confluent.Apache.Avro.dll version: 1.7.7.4
Operating system: Windows 10
Critical issue
thanks for the feedback @akasyanchuk - i'll look into this. the capitalization issue seems odd.
our version is almost exactly the same as the official version, except for a minimal set of changes required to make it work with .NET Standard + cross platform. I also fixed a minor issue related to namespacing.
@mhowlett Sorry, but can you briefly estimate when this issue can be fixed and when do you plan to release new avrogen version with fixes (because I want to use avrogen and now I can't do this)?
I actually also tried to find a way to change the capitalization of the properties, but at the end what I have done it's to define the avro schema already in PascalCase, so the generated properties are correctly generated with the confluent avrogen build.
But I would like to have the avro schema also using the correct guidelines, which for json is to have camelCase properties, while c# is PascalCase.
Is anybody alive here?
If you prefix UnsignedByte with it's namespace, the schema compiles. I do note that this behavior differs from the java implementation though where this is not necessary. Does this workaround suffice?
Regarding the capitalization problem, I'll try to get this prioritized for next sprint (1.5 weeks from now). It doesn't seem like it would be difficult to resolve.
I just looked into this a bit more:
Regarding 1, auto-capitalizing properties seems like a bad idea to me since Avro names are case sensitive ( http://avro.apache.org/docs/current/spec.html#names ). Doing this would mean that avrogen would not be suitable for use with all valid inputs. I'm not sure why the Apache.Avro.Tools version does this (i didn't make any changes to our fork related to this).
Regarding 2, the namespacing behavior does actually seem to match the spec:
"References to previously defined names are as in the latter two cases above: if they contain a dot they are a fullname, if they do not contain a dot, the namespace is the namespace of the enclosing definition."
though as noted above, the java tool does seem to add flexibility beyond this.
@mhowlett Thanks!
@mhowlett Are you still working on getting Avrogen to generate properties with PascalCase even if those are mentioned in camelCase in schema? We dont want to modify the kafka topic schema with PascalCase as its not the kafka schema standard.
I wasn't, for the reasons mentioned. But we could make it a command line option since I think it's something a lot of people would want to do. Unfortunately I'm unlikely to get to this in the short term. It shouldn't be too hard to implement though, pull requests accepted!
Thanks for the reply @mhowlett. For time being I'm using the Apache.Avro Tools to generate the properties which gives me the properties with PascalCase. Would definitely like to create a command like option to generate properties as per the user need.
@ravi-sontale can you please share to use the apache avro tool to create the command line. i am facing issue to run the program
@vivekk1010 Sorry for late reply.
I have used https://www.nuget.org/packages/Confluent.Apache.Avro.AvroGen 1.7.7.5 version.
Most helpful comment
I actually also tried to find a way to change the capitalization of the properties, but at the end what I have done it's to define the avro schema already in PascalCase, so the generated properties are correctly generated with the confluent avrogen build.
But I would like to have the avro schema also using the correct guidelines, which for json is to have camelCase properties, while c# is PascalCase.