[
https://issues.apache.org/jira/browse/AVRO-4187?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
David Neukam updated AVRO-4187:
-------------------------------
Attachment: (was:
0001-fix-AVRO-4187-fix-bug-causing-csharp-Avrogen-generat.patch)
> Avrogen (csharp) --namespace causes "SCHEMA" to contain csharp instead of
> avro namespaces leading to the serializer not finding the schema in the
> schema registry
> -----------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: AVRO-4187
> URL: https://issues.apache.org/jira/browse/AVRO-4187
> Project: Apache Avro
> Issue Type: Bug
> Components: csharp
> Affects Versions: 1.11.1, 1.12.0
> Reporter: David Neukam
> Priority: Major
>
> When using *avrogen* for generating C# models from a schemafile, the
> *--namespace* option doesn't behave as expected.
> When running
> {code:java}
> avrogen -s file.avsc . --namespace my.avro.ns:my.csharp.ns
> {code}
> the namespace within the SCHEMA property of the generated C# files is changed
> to {*}my.csharp.ns{*}, but should be left with value *my.avro.ns.*
>
> This was introduced with the bugfix in AVRO-2883.
>
> Example of expected output ({*}TestModel.cs{*}):
> {code:java}
> namespace my.csharp.ns
> {
> using System;
> using System.Collections.Generic;
> using System.Text;
> using Avro;
> using Avro.Specific;
>
> public partial class TestModel : ISpecificRecord
> {
> public static Schema _SCHEMA =
> Avro.Schema.Parse("{\"type\":\"record\",\"name\":\"TestModel\",\"namespace\":\"my.avro.ns\",\"fields\":[{\"name\":\"e"
> +
>
> "ventType\",\"type\":{\"type\":\"enum\",\"name\":\"EventType\",\"namespace\":\"my.avro.ns\",\"sym"
> +
>
> "bols\":[\"CREATE\",\"UPDATE\",\"DELETE\"]}}]}");
> private my.csharp.ns.EventType _eventType;
> // More generated code
> }
> }
> {code}
>
> Example of *ACTUAL* output ({*}TestModel.cs{*}):
> {code:java}
> namespace my.csharp.ns
> {
> using System;
> using System.Collections.Generic;
> using System.Text;
> using Avro;
> using Avro.Specific;
>
> public partial class TestModel : ISpecificRecord
> {
> public static Schema _SCHEMA =
> Avro.Schema.Parse("{\"type\":\"record\",\"name\":\"TestModel\",\"namespace\":\"my.csharp.ns\",\"fields\":[{\"name\":\"e"
> +
>
> "ventType\",\"type\":{\"type\":\"enum\",\"name\":\"EventType\",\"namespace\":\"my.csharp.ns\",\"sym"
> +
>
> "bols\":[\"CREATE\",\"UPDATE\",\"DELETE\"]}}]}");
> private my.csharp.ns.EventType _eventType;
> // More generated code
> }
> }{code}
>
> This issue is already mentioned in the comments of AVRO-2883:
> {quote}Calling Schema.ToString() on the generated _SCHEMA property will use
> the mapped namespaces. I suspect this could cause
> [Confluent.SchemaRegistry.Serdes.SpecificSerializerImpl<T>.Serialize|https://github.com/confluentinc/confluent-kafka-dotnet/blob/0f44064fd7ff2513e5fb01230f0faab9f9715a64/src/Confluent.SchemaRegistry.Serdes.Avro/SpecificSerializerImpl.cs#L228]
> not to find the schema in the schema registry, if it is configured to
> neither register schemas automatically nor use the latest schema. I'm not
> sure whether their schema registry distinguishes between schemas using
> different namespaces.
> {quote}
> ??[~kniemitalo]??
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)