瀏覽代碼

2005-07-14 Lluis Sanchez Gual <[email protected]>

	* SerializationCodeGenerator.cs: In the generated serializer always
	use the Object equality operator when comparing objects to serialize
	to null, since those objects may have the equality operator
	overloaded. This fixes bug #75543.


svn path=/trunk/mcs/; revision=47296
Lluis Sanchez 20 年之前
父節點
當前提交
cd403b28dc

+ 7 - 0
mcs/class/System.XML/System.Xml.Serialization/ChangeLog

@@ -1,3 +1,10 @@
+2005-07-14  Lluis Sanchez Gual  <[email protected]>
+
+	* SerializationCodeGenerator.cs: In the generated serializer always
+	use the Object equality operator when comparing objects to serialize
+	to null, since those objects may have the equality operator
+	overloaded. This fixes bug #75543.
+
 2005-07-01  Lluis Sanchez Gual  <[email protected]>
 
 	* XmlCustomFormatter.cs: Properly read/write duration values.

+ 6 - 6
mcs/class/System.XML/System.Xml.Serialization/SerializationCodeGenerator.cs

@@ -565,7 +565,7 @@ namespace System.Xml.Serialization
 			
 			if (!typeMap.TypeData.IsValueType)
 			{
-				WriteLine ("if (ob == null)");
+				WriteLine ("if (((object)ob) == null)");
 				WriteLineInd ("{");
 				WriteLineInd ("if (isNullable)");
 				
@@ -1053,7 +1053,7 @@ namespace System.Xml.Serialization
 			bool multichoice = (map.ItemInfo.Count > 1);
 
 			if (multichoice)
-				WriteLine ("if (" + item + " == null) { }");
+				WriteLine ("if (((object)" + item + ") == null) { }");
 			
 			foreach (XmlTypeMapElementInfo info in map.ItemInfo)
 			{
@@ -1976,7 +1976,7 @@ namespace System.Xml.Serialization
 			else
 			{
 				if (list != null) {
-					WriteLineInd ("if (" + list + " == null)");
+					WriteLineInd ("if (((object)" + list + ") == null)");
 					WriteLine ("throw CreateReadOnlyCollectionException (" + GetLiteral (typeMap.TypeFullName) + ");");
 					Unindent ();
 					WriteLineInd ("if (!ReadNull()) {");
@@ -1984,7 +1984,7 @@ namespace System.Xml.Serialization
 				else {
 					list = GetObTempVar ();
 					WriteLine (typeMap.TypeFullName + " " + list + " = null;");
-					WriteLineInd ("if (" + list + " == null)");
+					WriteLineInd ("if (((object)" + list + ") == null)");
 					WriteLine ("throw CreateReadOnlyCollectionException (" + GetLiteral (typeMap.TypeFullName) + ");");
 					Unindent ();
 					return list;
@@ -2080,7 +2080,7 @@ namespace System.Xml.Serialization
 			}
 			else	// Must be IEnumerable
 			{
-				WriteLine ("if (" + list + " == null)");
+				WriteLine ("if (((object)" + list + ") == null)");
 				if (canCreateInstance) 
 					WriteLine ("\t" + list + " = new " + listType.FullTypeName + "();");
 				else 
@@ -2105,7 +2105,7 @@ namespace System.Xml.Serialization
 				string metName = GetFillListName (td);
 				WriteLine ("void " + metName + " (object list, object source)");
 				WriteLineInd ("{");
-				WriteLine ("if (list == null) throw CreateReadOnlyCollectionException (" + GetLiteral (td.FullTypeName) + ");");
+				WriteLine ("if (((object)list) == null) throw CreateReadOnlyCollectionException (" + GetLiteral (td.FullTypeName) + ");");
 				WriteLine ("");
 
 				WriteLine (td.FullTypeName + " dest = (" + td.FullTypeName + ") list;");