[
https://issues.apache.org/jira/browse/AVRO-4094?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Shaw Young updated AVRO-4094:
-----------------------------
Environment: Avrogen is being run against dotnet 8 c# code from linux
(was: Avrogen is being run against dotnet 8 c# code from the linux command
line.)
> Namespaces not mapped in type references
> ----------------------------------------
>
> Key: AVRO-4094
> URL: https://issues.apache.org/jira/browse/AVRO-4094
> Project: Apache Avro
> Issue Type: Bug
> Components: csharp
> Affects Versions: 1.11.4
> Environment: Avrogen is being run against dotnet 8 c# code from linux
> Reporter: Shaw Young
> Priority: Major
> Labels: pull-request-available
> Time Spent: 10m
> Remaining Estimate: 0h
>
> Given this avsc schema file
> {code:java}
> [
> {
> "type": "enum",
> "name": "Planets",
> "namespace": "myapp.account",
> "symbols": [
> "EARTH",
> "MARS",
> "VENUS",
> "MERCURY"
> ],
> "doc": "Planets of the solar system"
> },
> {
> "type": "record",
> "name": "AccountCreation",
> "namespace": "myapp.account",
> "doc": "A individual user of the system.",
> "fields": [
> {
> "name": "id",
> "type": "string",
> "doc": "The unique identifier for the user."
> },
> {
> "name": "name",
> "type": [
> "null",
> "string"
> ],
> "default": null,
> "doc": ""
> },
> {
> "name": "homePlanet",
> "type": "Planets",
> "doc": ""
> },
> {
> "name": "favouritePlanet",
> "type": [
> "null",
> "Planets"
> ],
> "default": null,
> "doc": ""
> }
> ]
> }
> ] {code}
> and the avrogen with the following parameters;
> {code:java}
> avrogen -s ./simple.avsc ./out --namespace myapp.account:App.Account{code}
> Everything is generated as expected;
> {code:java}
> out
> └── App
> └── Account
> ├── AccountCreation.cs
> └── Planets.cs {code}
> Now consider a minor alteration of moving Planets into its own common
> namespace so it can reused- we still wish to reference it from the
> AccountCreation entity by simply adding the namespace to the type;
> {code:java}
> [
> {
> "type": "enum",
> "name": "Planets",
> "namespace": "myapp.common",
> "symbols": [
> "EARTH",
> "MARS",
> "VENUS",
> "MERCURY"
> ],
> "doc": "Planets of the solar system"
> },
> {
> "type": "record",
> "name": "AccountCreation",
> "namespace": "myapp.account",
> "doc": "A individual user of the system.",
> "fields": [
> {
> "name": "id",
> "type": "string",
> "doc": "The unique identifier for the user."
> },
> {
> "name": "name",
> "type": [
> "null",
> "string"
> ],
> "default": null,
> "doc": ""
> },
> {
> "name": "homePlanet",
> "type": "myapp.common.Planets",
> "doc": ""
> },
> {
> "name": "favouritePlanet",
> "type": [
> "null",
> "myapp.common.Planets"
> ],
> "default": null,
> "doc": ""
> }
> ]
> }
> ] {code}
> Including the extra namespace mapping when running avrogen;
> {code:java}
> avrogen -s ./demo.avsc ./out --namespace myapp.common:App.Common --namespace
> myapp.account:App.Account{code}
> This run fails
> {code:java}
> Exception occurred. Undefined name: myapp.common.Planets at
> '[1].fields[2].type'{code}
> Looking at the code it looks like the pre-parse step will substitute
> namespace attributes using the collection of namespace mapping, but doesn't
> substitute any of the type mappings, if they include one of the mapped
> namespaces.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)