[
https://issues.apache.org/jira/browse/AVRO-2883?focusedWorklogId=744723&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-744723
]
ASF GitHub Bot logged work on AVRO-2883:
----------------------------------------
Author: ASF GitHub Bot
Created on: 20/Mar/22 16:34
Start Date: 20/Mar/22 16:34
Worklog Time Spent: 10m
Work Description: zcsizmadia opened a new pull request #1610:
URL: https://github.com/apache/avro/pull/1610
Make sure you have checked _all_ steps below.
### Jira
- [x] My PR addresses the following [Avro
Jira](https://issues.apache.org/jira/browse/AVRO-2883)
- https://issues.apache.org/jira/browse/AVRO-2883
- In case you are adding a dependency, check if the license complies with
the [ASF 3rd Party License
Policy](https://www.apache.org/legal/resolved.html#category-x).
### Tests
- [x] My PR adds the following unit tests __OR__ does not need testing for
this extremely good reason:
### Commits
- [x] My commits all reference Jira issues in their subject lines. In
addition, my commits follow the guidelines from "[How to write a good git
commit message](https://chris.beams.io/posts/git-commit/)":
1. Subject is separated from body by a blank line
1. Subject is limited to 50 characters (not including Jira issue reference)
1. Subject does not end with a period
1. Subject uses the imperative mood ("add", not "adding")
1. Body wraps at 72 characters
1. Body explains "what" and "why", not "how"
### Documentation
- [x] In case of new functionality, my PR adds documentation that describes
how to use it.
- All the public functions and the classes in the PR contain Javadoc that
explain what it does
### Fixes
https://issues.apache.org/jira/browse/AVRO-2883
https://issues.apache.org/jira/browse/AVRO-3046
--
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: 744723)
Remaining Estimate: 0h
Time Spent: 10m
> 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
> Priority: Major
> Time Spent: 10m
> 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)