Closed hayghaza closed 8 years ago
This got discussed outside of GitHub. Summarizing for here:
The behavior you are seeing is how nullable<blob>
and blob = nothing
are represented in C#. Changing it now would be a breaking change in the generated code, which is not something we take lightly. In hindsight, could we have come up with a different way of representing these cases, yes.
To make Newtonsoft happy, you'll probably need to assign a new byte[0]
to the ArraySegment
. Note that in Bond, an empty array is different from a null array. Whether this causes problems will depend on how your components use the blob field.
I am using Bond.Core.4.0.2, Bond.CSharp.4.0.2 and Bond.Core.NET.3.0.63. I just realized that BOND CSharp compiler does the following type transformation:
BOND:
C#:
Well, I would expect to see something really nullable here and ArraySegment is not such. In case if PeHeader field is missing from the payload, BOND will create an ArraySegment with null array instead of simple null instance. Some downstream components, like Newtonsoft.Json serializer inside OWIN, will fail deserializing such ArraySegements with InvalidOperationException(“The underlying array in null.”).
Is this a known issue? What would be you recommendations?