Uploaded image for project: 'Apache Avro'
  1. Apache Avro
  2. AVRO-2499

C# reflect does not cache classes referenced in a union

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: 1.10.0
    • Component/s: csharp
    • Labels:
      None

      Description

      In the example below an attempt to serialize an object of type A fails.

      { "name" : "A", 

         "type" " : "record",

         "fields" : [

              { "name" : "OptionalProperty",

                 "type" : [ "null",

                               

      { "name" : "B",                              "type" : "record",                              "fields" : [ "name" : "C", "type" : "string" ]                            }

                            ]

              }

       

       

       

      C# classes

      public class A

      {     public B OptionalProperty \{ get; set;}

      }

      public class B

      {     public string C \{ get; set;}

      }

       

       

      Problem is in Reflect/ClassCache.cs line 259.

      Need to add the following case
      case UnionSchema us:
          foreach (var o in us.Schemas)
          {
              if (o.Tag!=Avro.Schema.Type.Null)
             

      {             LoadClassCache(objType, o);         }

          }
       
      Will do a PR 

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              paddypawprints Patrick Farry
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: