This project has moved. For the latest updates, please go here.

R7 build broken for Byte Arrays

Apr 19, 2010 at 4:22 PM

Looks like some buffer corruption issue with the latest R7 build when a BYTE property is zero length.  JsonTextReader.ReadAsBytes() seems to exhibit some sort of corruption.

The below sample code shows up the issue (happy to fix if JamesNK can give us a heads-up).

class Program
        private class MyClass
            public byte[] Prop1 { get; set; }

            public MyClass()
                Prop1 = new byte[0];
        static void Main(string[] args)
            MyClass[] m = new MyClass[2];
            m[0] = new MyClass();
            m[1] = new MyClass();
            JsonSerializer serializer1 = new JsonSerializer();

            serializer1.Converters.Add(new IsoDateTimeConverter());
            serializer1.NullValueHandling = NullValueHandling.Ignore;
            StringWriter writer = new StringWriter();
            serializer1.Serialize(writer, m);
            JsonTextReader jread = new JsonTextReader(new StringReader(writer.GetStringBuilder().ToString()));
            MyClass[] z = (MyClass[])serializer1.Deserialize(jread, typeof(MyClass[]));



Apr 20, 2010 at 8:16 AM