Explorar el Código

* XmlReflectionImporter.cs, SoapReflectionImporter.cs: Fixed bug #49349

svn path=/trunk/mcs/; revision=18637
Lluis Sanchez hace 22 años
padre
commit
ccb17da8f9

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

@@ -1,3 +1,7 @@
+2003-10-05  Lluis Sanchez Gual <[email protected]>
+
+	* XmlReflectionImporter.cs, SoapReflectionImporter.cs: Fixed bug #49349
+
 2003-10-04  Lluis Sanchez Gual <[email protected]>
 
 	* XmlSchemaExporter.cs: Keep track of elements being exported.

+ 3 - 0
mcs/class/System.XML/System.Xml.Serialization/SoapReflectionImporter.cs

@@ -148,6 +148,9 @@ 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");
+				
 			TypeData typeData = TypeTranslator.GetTypeData (type);
 			XmlTypeMapping map = helper.GetRegisteredClrType (type, GetTypeNamespace (typeData, defaultNamespace));
 			if (map != null) return map;

+ 3 - 0
mcs/class/System.XML/System.Xml.Serialization/XmlReflectionImporter.cs

@@ -188,6 +188,9 @@ 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");
+			
 			map = CreateTypeMapping (typeData, root, null, defaultNamespace);
 			helper.RegisterClrType (map, type, map.Namespace);
 			helper.RegisterSchemaType (map, map.XmlType, map.Namespace);