[Mono-bugs] [Bug 77530][Nor] Changed - [PATCH] serialization of integral enum value is not correct

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Thu Feb 16 08:58:53 EST 2006


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 lluis at ximian.com.

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

--- shadow/77530	2006-02-11 08:20:35.000000000 -0500
+++ shadow/77530.tmp.5920	2006-02-16 08:58:53.000000000 -0500
@@ -1,14 +1,14 @@
 Bug#: 77530
 Product: Mono: Class Libraries
 Version: 1.1
-OS: 
+OS: unknown
 OS Details: 
 Status: NEW   
 Resolution: 
-Severity: 
+Severity: Unknown
 Priority: Normal
 Component: Sys.XML
 AssignedTo: lluis at ximian.com                            
 ReportedBy: gert.driesen at pandora.be               
 QAContact: mono-bugs at ximian.com
 TargetMilestone: ---
@@ -60,6 +60,70 @@
 Let me know if its ok to commit this patch.
 
 ------- Additional Comments From gert.driesen at pandora.be  2006-02-11 08:20 -------
 Created an attachment (id=16479)
 Fixes and unit tests
 
+
+------- Additional Comments From lluis at ximian.com  2006-02-16 08:58 -------
+Gert, thanks for the patch. Here are some comments:
+
+In EnumMap.GetXmlName:
+* I think the call to XmlCustomFormatter.FromEnum should be done only
+when the enum is a flags enum. If it is not, shouldn't it just return
+the long value?
+* The cration of the names and values arrays should only be done once
+and they should be stored in the enum map.
+
+In SerializationCodeGenerator.GenerateGetXmlEnumValue:
+Same as before, the names and values arrays should not be created for
+each call to the generated conversion method.
+Also, looks like the old line "if (val.ToString () == \"0\") return
+string.Empty;" is lost?
+
+In GenerateWriteObject:
+
+@@ -608,28 +620,27 @@
+ 			ArrayList types = typeMap.DerivedTypes;
+ 			
+ 			WriteLine ("System.Type type = ob.GetType ();");
+-			WriteLine ("if (type == typeof(" + typeMap.TypeFullName + "))");
+-			WriteLine ("\t;");
+-				
++			WriteLine ("if (type == typeof(" + typeMap.TypeFullName + ")) {");
++
+ 			for (int n=0; n<types.Count; n++)
+ 			{
+ 				XmlTypeMapping map = (XmlTypeMapping)types[n];
+ 				
+-				WriteLineInd ("else if (type == typeof(" + map.TypeFullName + "))
+{ ");
++				WriteLineInd ("} else if (type == typeof(" + map.TypeFullName +
+")) { ");
+ 				WriteLine (GetWriteObjectName (map) + "((" + map.TypeFullName +
+")ob, element, namesp, isNullable, true, writeWrappingElem);");
+ 				WriteLine ("return;");
+ 				WriteLineUni ("}");
+ 			}
+
+This is wrong. It's going to fail if types.Count > 0.
+
+Replacing 
+-			WriteLine ("\t;");
+by
++			WriteLine ("{ }");
+looks like a better solution.
+
+
+Which error does this fix:
+@@ -2232,7 +2243,8 @@
+ 		{
+ 			WriteLine ("Reader.ReadStartElement ();");
+ 			WriteLine (typeMap.TypeFullName + " res = " + GenerateGetEnumValue
+(typeMap, "Reader.ReadString()") + ";");
+-			WriteLine ("Reader.ReadEndElement ();");
++			WriteLineInd ("if (Reader.NodeType != XmlNodeType.None)");
++			WriteLineUni ("Reader.ReadEndElement ();");
+ 			WriteLine ("return res;");
+
+
+


More information about the mono-bugs mailing list