Browse Source

* SoapReflectionImporter.cs, XmlReflectionImporter.cs,
SoapReflectionImporter.cs: Fixed bug #94694. Check for public constructor
is not needed for value types.

svn path=/trunk/mcs/; revision=18784

Lluis Sanchez 22 years ago
parent
commit
8205d9bfac

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

@@ -1,5 +1,11 @@
 2003-10-09  Lluis Sanchez Gual <[email protected]>
 
+	* SoapReflectionImporter.cs, XmlReflectionImporter.cs, 
+	  SoapReflectionImporter.cs: Fixed bug #94694. Check for public constructor
+	  is not needed for value types.
+
+2003-10-08  Lluis Sanchez Gual <[email protected]>
+
 	* XmlSerializer.cs, XmlSerializationWriter.cs: Fixed bug #49353
 	  (XmlSerializer.Serialize() handles namespace parameter incorrectly)
 

+ 8 - 1
mcs/class/System.XML/System.Xml.Serialization/ReflectionHelper.cs

@@ -49,5 +49,12 @@ namespace System.Xml.Serialization
 		{
 			return new InvalidOperationException ("There was an error reflecting '" + map.TypeFullName + "': " + message);
 		}
+		
+		
+		public static void CheckSerializableType (Type type)
+		{
+			if (type.GetConstructor (Type.EmptyTypes) == null && !type.IsAbstract && !type.IsValueType)
+				throw new InvalidOperationException (type.Name + " cannot be serialized because it does not have a default public constructor");
+		}
 	}
-}
+}

+ 1 - 2
mcs/class/System.XML/System.Xml.Serialization/SoapReflectionImporter.cs

@@ -148,8 +148,7 @@ namespace System.Xml.Serialization {
 			if (type.IsValueType) throw CreateStructException (type);
 			if (type == typeof (object)) defaultNamespace = XmlSchema.Namespace;
 
-			if (type.GetConstructor (Type.EmptyTypes) == null && !type.IsAbstract)
-				throw new InvalidOperationException (type.Name + " cannot be serialized because it does not have a default public constructor");
+			ReflectionHelper.CheckSerializableType (type);
 				
 			TypeData typeData = TypeTranslator.GetTypeData (type);
 			XmlTypeMapping map = helper.GetRegisteredClrType (type, GetTypeNamespace (typeData, defaultNamespace));

+ 1 - 2
mcs/class/System.XML/System.Xml.Serialization/XmlReflectionImporter.cs

@@ -188,8 +188,7 @@ namespace System.Xml.Serialization {
 			XmlTypeMapping map = helper.GetRegisteredClrType (type, GetTypeNamespace (typeData, root, defaultNamespace));
 			if (map != null) return map;
 
-			if (type.GetConstructor (Type.EmptyTypes) == null && !type.IsAbstract)
-				throw new InvalidOperationException (type.Name + " cannot be serialized because it does not have a default public constructor");
+			ReflectionHelper.CheckSerializableType (type);
 			
 			map = CreateTypeMapping (typeData, root, null, defaultNamespace);
 			helper.RegisterClrType (map, type, map.Namespace);