[Mono-bugs] [Bug 80759][Nor] New - XmlSerializer behavior difference with Microsoft

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Thu Feb 8 04:33:51 EST 2007


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by bugzilla at woy.nl.

http://bugzilla.ximian.com/show_bug.cgi?id=80759

--- shadow/80759	2007-02-08 04:33:51.000000000 -0500
+++ shadow/80759.tmp.8818	2007-02-08 04:33:51.000000000 -0500
@@ -0,0 +1,65 @@
+Bug#: 80759
+Product: Mono: Class Libraries
+Version: 1.2
+OS: Windows XP
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Sys.XML
+AssignedTo: atsushi at ximian.com                            
+ReportedBy: bugzilla at woy.nl               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: XmlSerializer behavior difference with Microsoft
+
+Please fill in this template when reporting a bug, unless you know what 
+you are doing.
+Description of Problem:
+
+When i use an XmlSerializer to Serialize a class with an Nullable member 
+with the name NullableInt and a bool property NullableIntSpecified ( 
+Microsoft makes a difference between a null value and not specified with 
+nullable types ) on wich I don't specify an set accessor, I get an 
+Exception there isn't a set accessor when I try to deserialize de class. 
+Microsoft only gives this error on non nullable value types.
+
+The following code demonstrates the problem. Adding a set accessor makes 
+the code work properly, but the microsoft impelementation works without it.
+
+public class XmlSerializerTest
+{
+    public static void Main(string[] args)
+    {
+        Foo foo = new Foo();
+        foo.Test = "BAR";
+        foo.NullableInt = 10;
+
+        XmlSerializer serializer = new XmlSerializer(typeof (Foo));
+
+        MemoryStream stream = new MemoryStream();
+
+        serializer.Serialize(stream, foo);
+        Console.WriteLine(Encoding.UTF8.GetString(stream.ToArray()));
+        stream.Position = 0;
+        foo = (Foo)serializer.Deserialize(stream);
+
+        Console.WriteLine(foo.Test);
+        Console.ReadLine();
+    }
+}
+
+public class Foo
+{
+    public string Test;
+    public int NullableInt;
+
+    [XmlElement("NullableIntSpecified")]
+    public bool NullableIntSpecified
+    {
+        get { return true; }
+    }
+}


More information about the mono-bugs mailing list