[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
Sat Feb 18 08:54:33 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 gert.driesen at pandora.be.

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

--- shadow/77530	2006-02-16 08:58:53.000000000 -0500
+++ shadow/77530.tmp.17440	2006-02-18 08:54:33.000000000 -0500
@@ -124,6 +124,52 @@
 +			WriteLineInd ("if (Reader.NodeType != XmlNodeType.None)");
 +			WriteLineUni ("Reader.ReadEndElement ();");
  			WriteLine ("return res;");
 
 
 
+
+------- Additional Comments From gert.driesen at pandora.be  2006-02-18 08:54 -------
+Lluis,
+
+Thanks for taking the time to review this patch. May I ask one small 
+favor: would it be possible to number your remarks next time, that 
+makes it a little easier (for me, at least ;-)).
+
+In EnumMap.GetXmlName:
+1) * 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?
+
+2) The cration of the names and values arrays should only be done 
+once and they should be stored in the enum map.
+
+=> Ok, I modified my patch accordingly. I wasn't sure on whether we 
+should do lazy init of these arrays or not. Initializing them in the 
+ctor allows us to mark these array read-only, perhaps this allows 
+the JIT to optimize it more ?
+
+In SerializationCodeGenerator.GenerateGetXmlEnumValue:
+
+3) Same as before, the names and values arrays should not be created 
+for each call to the generated conversion method.
+
+=> Took care of that, see previous remark.
+
+4) Also, looks like the old line "if (val.ToString () == \"0\") 
+return string.Empty;" is lost?
+
+=> FromEnum takes care of that check, but that may waste a few 
+cycles so I moved it back in.
+
+5) This is wrong. It's going to fail if types.Count > 0. ....looks 
+like a better solution.
+
+=> You're right. I modified my patch.
+
+6) Which error does this fix:
+
+=> Deserialization of an empty element to (flags) enum (eg. 
+<EnumDefaultValue />). There are a few tests for this in 
+DeserializeTests.cs
+
+


More information about the mono-bugs mailing list