Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
1.10.1
-
None
-
None
Description
The avrogen tool for C# fails to map the namespaces of inner records.
Example:
{ "type": "record", "name": "ExampleRecord", "namespace": "com.example", "fields": [ { "name": "Id", "type": "string", "logicalType": "UUID" }, { "name": "InnerRecord", "type": { "type": "record", "name": "InnerRecord", "fields": [ { "name": "Id", "type": "string", "logicalType": "UUID" } ] } } ] }
Command:
avrogen -s ./example.avsc ./dotnet --namespace "com.example:Example"
Result:
// ------------------------------------------------------------------------------ // <auto-generated> // Generated by avrogen, version 1.10.0.0 // Changes to this file may cause incorrect behavior and will be lost if code // is regenerated // </auto-generated> // ------------------------------------------------------------------------------ namespace Example { using System; using System.Collections.Generic; using System.Text; using Avro; using Avro.Specific; public partial class ExampleRecord : ISpecificRecord { public static Schema _SCHEMA = Avro.Schema.Parse("{\"type\":\"record\",\"name\":\"ExampleRecord\",\"namespace\":\"com.example\",\"fields\":[{\"nam" + "e\":\"Id\",\"type\":\"string\"},{\"name\":\"InnerRecord\",\"type\":{\"type\":\"record\",\"name\":\"I" + "nnerRecord\",\"namespace\":\"com.example\",\"fields\":[{\"name\":\"Id\",\"type\":\"string\"}]}}" + "]}"); private string _Id; private com.example.InnerRecord _InnerRecord; public virtual Schema Schema { get { return ExampleRecord._SCHEMA; } } public string Id { get { return this._Id; } set { this._Id = value; } } public com.example.InnerRecord InnerRecord { get { return this._InnerRecord; } set { this._InnerRecord = value; } } public virtual object Get(int fieldPos) { switch (fieldPos) { case 0: return this.Id; case 1: return this.InnerRecord; default: throw new AvroRuntimeException("Bad index " + fieldPos + " in Get()"); }; } public virtual void Put(int fieldPos, object fieldValue) { switch (fieldPos) { case 0: this.Id = (System.String)fieldValue; break; case 1: this.InnerRecord = (com.example.InnerRecord)fieldValue; break; default: throw new AvroRuntimeException("Bad index " + fieldPos + " in Put()"); }; } } }
In this case the InnerRecord is referenced via "com.Example.InnerRecord", but it should be "Example.InnerRecord".