[
https://issues.apache.org/jira/browse/AVRO-2883?focusedWorklogId=745362&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-745362
]
ASF GitHub Bot logged work on AVRO-2883:
----------------------------------------
Author: ASF GitHub Bot
Created on: 21/Mar/22 18:45
Start Date: 21/Mar/22 18:45
Worklog Time Spent: 10m
Work Description: zcsizmadia commented on a change in pull request #1610:
URL: https://github.com/apache/avro/pull/1610#discussion_r831434743
##########
File path: lang/csharp/src/apache/main/CodeGen/CodeGen.cs
##########
@@ -57,14 +57,6 @@ public class CodeGen
/// </value>
public IList<Protocol> Protocols { get; private set; }
- /// <summary>
- /// Gets mapping of Avro namespaces to C# namespaces.
- /// </summary>
- /// <value>
- /// The namespace mapping.
- /// </value>
- public IDictionary<string, string> NamespaceMapping { get; private
set; }
Review comment:
It is a good call out. I reshuffled the code and added back the
NamespaceMapping property and marked it obsolete.
Thebiggest issue with this serious bug is that the best solution is to
change the schema text before the actual parsing, otherwise the whole already
created Schema or Protocol object must be recreated. The documentation might
need mapping. So there might be some actual breaking for some people who
generate code on the fly and not via avrogen, however using a dynamically
compiled code is not very likely since using the generated SpecificRecord is
not very convinient.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 745362)
Time Spent: 1h 40m (was: 1.5h)
> Avrogen (csharp) namespace mapping missing for references
> ---------------------------------------------------------
>
> Key: AVRO-2883
> URL: https://issues.apache.org/jira/browse/AVRO-2883
> Project: Apache Avro
> Issue Type: Bug
> Components: csharp
> Reporter: Thomas Vigh Sørensen
> Assignee: Zoltan Csizmadia
> Priority: Major
> Labels: pull-request-available
> Time Spent: 1h 40m
> Remaining Estimate: 0h
>
> When using *avrogen* for generating C# models from a schemafile, the
> *--namespace* option doesn't behave as expected, if the model refers to other
> types (currently only tested with enums).
> When running
> {code:java}
> avrogen -s file.avsc . --namespace my.avro.ns:my.csharp.ns
> {code}
> the actual namespace of the generated C# files is changed to *my.csharp.ns*,
> but any references between the models are not updated with the correct
> namespace.
>
> Given a schemafile containing:
> {code:json}
> {
> "type" : "record",
> "name" : "TestModel",
> "namespace" : "my.avro.ns",
> "fields" : [ {
> "name" : "eventType",
> "type" : {
> "type" : "enum",
> "name" : "EventType",
> "symbols" : [ "CREATE", "UPDATE", "DELETE" ]
> }
> } ]
> }
> {code}
> And running
> {code:java}
> avrogen -s models.avsc . --namespace my.avro.ns:my.csharp.ns
> {code}
>
> Will produce the following *EventType.cs*
> {code:c#}
> namespace my.csharp.ns
> {
> using System;
> using System.Collections.Generic;
> using System.Text;
> using Avro;
> using Avro.Specific;
>
> public enum EventType
> {
> CREATE,
> UPDATE,
> DELETE,
> }
> }
> {code}
>
> and the following *TestModel.cs*
> {code:c#}
> 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.avro.ns.EventType _eventType;
> // More generated code
> }
> }
> {code}
> Notice how the namespace is set correctly to *my.csharp.ns* in both files,
> but the namespace of the referenced *EventType* in *TestModel.cs* is
> incorrect.
>
> Example of expected output (*TestModel.cs*):
> {code:c#}
> 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}
>
> Code for reproducing the issue can be found at:
> [https://github.com/FuKe/avrogen-namespace-bug]
--
This message was sent by Atlassian Jira
(v8.20.1#820001)