[
https://issues.apache.org/jira/browse/AVRO-4137?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
ASF GitHub Bot updated AVRO-4137:
---------------------------------
Labels: pull-request-available (was: )
> C# SpecificWriter incorrectly assigns Enum type when using Union containing
> identical value names
> -------------------------------------------------------------------------------------------------
>
> Key: AVRO-4137
> URL: https://issues.apache.org/jira/browse/AVRO-4137
> Project: Apache Avro
> Issue Type: Bug
> Components: csharp
> Reporter: Tymur Hulua
> Priority: Major
> Labels: pull-request-available
> Time Spent: 10m
> Remaining Estimate: 0h
>
> At the moment, the C# library Avro matches Union types with Enum in the
> following way:
> {code:java}
> // SpecificDefaultWriter.cs - LN159 - protected override bool Matches(Schema
> sc, object obj)
> case Schema.Type.Enumeration:
> return obj.GetType().IsEnum && (sc as
> EnumSchema).Symbols.Contains(obj.ToString());{code}
> This leads to the scenario where several Enums declared within one Union
> schema cannot have the same value names, because upon serialization, the Enum
> that is declared earlier will be chosen, not the one that was originally
> passed.
> It is further suggested to conduct a check on the type name and the schema
> itself:
> {code:java}
> case Schema.Type.Enumeration:
> return obj.GetType().IsEnum && (sc as
> EnumSchema).Symbols.Contains(obj.ToString()) && sc.Name ==
> obj.GetType().Name;{code}
> If you believe that this could lead to unforeseen problems (such as breaking
> backward compatibility), it is proposed to make the check optional, by
> default turned off. There may be other, more reliable methods to solve this
> issue, but the demonstrated one seemed the most optimal in my mind ;)
> Thank you!
--
This message was sent by Atlassian Jira
(v8.20.10#820010)