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

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Tue Feb 13 06:12: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 atsushi at ximian.com.

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

--- shadow/80759	2007-02-08 04:33:51.000000000 -0500
+++ shadow/80759.tmp.21544	2007-02-13 06:12:51.000000000 -0500
@@ -1,14 +1,14 @@
 Bug#: 80759
 Product: Mono: Class Libraries
 Version: 1.2
 OS: Windows XP
 OS Details: 
-Status: NEW   
-Resolution: 
-Severity: 
+Status: RESOLVED   
+Resolution: INVALID
+Severity: Unknown
 Priority: Normal
 Component: Sys.XML
 AssignedTo: atsushi at ximian.com                            
 ReportedBy: bugzilla at woy.nl               
 QAContact: mono-bugs at ximian.com
 TargetMilestone: ---
@@ -60,6 +60,90 @@
     [XmlElement("NullableIntSpecified")]
     public bool NullableIntSpecified
     {
         get { return true; }
     }
 }
+
+------- Additional Comments From atsushi at ximian.com  2007-02-13 06:12 -------
+It is incorrect. .NET raises an error in the same way as we do:
+
+$ cat 80759.cs
+using System;
+using System.IO;
+using System.Text;
+using System.Xml;
+using System.Xml.Serialization;
+
+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; }
+    }
+}
+
+atsushi at PC ~/tests/xml/serialization
+$ csc 80759.cs
+Microsoft (R) Visual C# 2005 Compiler version 8.00.50727.208
+for Microsoft (R) Windows (R) 2005 Framework version 2.0.50727
+Copyright (C) Microsoft Corporation 2001-2005. All rights reserved.
+
+
+atsushi at PC ~/tests/xml/serialization
+$ !./
+./80759.exe
+
+Unhandled Exception: System.InvalidOperationException: Unable to
+generate a temp
+orary class (result=1).
+error CS0200: Property or indexer 'Foo.NullableIntSpecified' cannot be
+assigned
+to -- it is read only
+
+   at System.Xml.Serialization.Compiler.Compile(Assembly parent,
+String ns, Comp
+ilerParameters parameters, Evidence evidence)
+   at
+System.Xml.Serialization.TempAssembly.GenerateAssembly(XmlMapping[] xmlMap
+pings, Type[] types, String defaultNamespace, Evidence evidence,
+CompilerParamet
+ers parameters, Assembly assembly, Hashtable assemblies)
+   at System.Xml.Serialization.TempAssembly..ctor(XmlMapping[]
+xmlMappings, Type
+[] types, String defaultNamespace, String location, Evidence evidence)
+   at
+System.Xml.Serialization.XmlSerializer.GenerateTempAssembly(XmlMapping xml
+Mapping, Type type, String defaultNamespace)
+   at System.Xml.Serialization.XmlSerializer..ctor(Type type, String
+defaultName
+space)
+   at System.Xml.Serialization.XmlSerializer..ctor(Type type)
+   at XmlSerializerTest.Main(String[] args)
+
+


More information about the mono-bugs mailing list