[Mono-bugs] [Bug 473693] New: DataContractJsonSerializer

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Sat Feb 7 21:27:39 EST 2009


https://bugzilla.novell.com/show_bug.cgi?id=473693


           Summary: DataContractJsonSerializer
    Classification: Mono
           Product: Mono: Class Libraries
           Version: 2.2.x
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: System
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: mirko-novell at nextware.it
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


This code:

using System;
using System.IO;
using System.Runtime.Serialization.Json;
using System.Text;
using System.Runtime.Serialization;
using System.Xml;

public class TTest {

        [DataContract()]
        public class A {
                [DataMember()]
                public int B=0;
        }

        static void Funziona() {
                MemoryStream ms=new MemoryStream();
                DataContractJsonSerializer ser=new
DataContractJsonSerializer(typeof(A));
                using (XmlWriter
w=JsonReaderWriterFactory.CreateJsonWriter(ms)) {
                        ser.WriteObject(w,new A());
                }
                Console.WriteLine("OK:
"+Encoding.UTF8.GetString(ms.ToArray()));
        }

        static void NonFunziona() {
                MemoryStream ms=new MemoryStream();
                DataContractJsonSerializer Ser=new
DataContractJsonSerializer(typeof(A));
                Ser.WriteObject(ms,new A());
                Console.WriteLine("KO:
"+Encoding.UTF8.GetString(ms.ToArray()));
        }

        public static void Main() {
                Funziona();
                NonFunziona();
        }
}

Compiled with:
gmcs -r:System.ServiceModel.Web -r:System.Runtime.Serialization Test.cs

return:
OK: {"B":0}
KO:

----------------------------------------------

With .NET 3.5
"C:\WINDOWS\Microsoft.NET\Framework\v3.5"\csc Test.cs

return:
OK: {"B":0}
KO: {"B":0}

-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list