Bladeren bron

* TypeTranslator.cs, XmlCustomFormatter.cs: Removed map from Uri to anyUri,
not present in MS.NET.
* XmlSerializationWriter.cs: Improved error message.

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

Lluis Sanchez 22 jaren geleden
bovenliggende
commit
ef8f047dbe

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

@@ -1,3 +1,9 @@
+2004-04-14  Lluis Sanchez Gual <[email protected]>
+
+	* TypeTranslator.cs, XmlCustomFormatter.cs: Removed map from Uri to anyUri,
+	  not present in MS.NET.
+	* XmlSerializationWriter.cs: Improved error message.
+
 2004-03-30  Lluis Sanchez Gual <[email protected]>
 
 	* SerializationCodeGenerator.cs, XmlReflectionImporter.cs, 

+ 0 - 1
mcs/class/System.XML/System.Xml.Serialization/TypeTranslator.cs

@@ -47,7 +47,6 @@ namespace System.Xml.Serialization
 			nameCache.Add (typeof (byte[]), new TypeData (typeof (byte[]), "base64Binary", true));
 			nameCache.Add (typeof (XmlNode), new TypeData (typeof (XmlNode), "XmlNode", false));
 			nameCache.Add (typeof (XmlElement), new TypeData (typeof (XmlElement), "XmlElement", false));
-			nameCache.Add (typeof (Uri), new TypeData (typeof (Uri), "anyURI", true));
 			nameCache.Add (typeof (TimeSpan), new TypeData (typeof (TimeSpan), "duration", true));
 
 			primitiveTypes = new Hashtable();

+ 0 - 2
mcs/class/System.XML/System.Xml.Serialization/XmlCustomFormatter.cs

@@ -175,7 +175,6 @@ namespace System.Xml.Serialization {
 				case "unsignedLong": return XmlConvert.ToString ((UInt64)value);
 				case "guid": return XmlConvert.ToString ((Guid)value);
 				case "base64Binary": return Convert.ToBase64String ((byte[])value);
-				case "anyURI":
 				default: return value.ToString ();
 			}
 		}
@@ -204,7 +203,6 @@ namespace System.Xml.Serialization {
 				case "unsignedLong": return XmlConvert.ToUInt64 (value);
 				case "guid": return XmlConvert.ToGuid (value);
 				case "base64Binary": return Convert.FromBase64String (value);
-				case "anyUri": return new Uri (value);
 				default: 
 					if (type.Type != null)
 						return Convert.ChangeType (value, type.Type);

+ 3 - 1
mcs/class/System.XML/System.Xml.Serialization/XmlSerializationWriter.cs

@@ -30,6 +30,8 @@ namespace System.Xml.Serialization {
 		Hashtable callbacks;
 		Hashtable serializedObjects;
 		const string xmlNamespace = "http://www.w3.org/2000/xmlns/";
+		const string unexpectedTypeError = "The type {0} was not expected. Use the" +
+			" XmlInclude or SoapInclude attribute to specify types that are not known statically.";
 
 		#endregion // Fields
 
@@ -748,7 +750,7 @@ namespace System.Xml.Serialization {
 			if (xsiType)
 			{
 				if (td.SchemaType != SchemaTypes.Primitive)
-					throw new InvalidOperationException ("Invalid type: " + o.GetType().FullName);
+					throw new InvalidOperationException (string.Format (unexpectedTypeError, o.GetType().FullName));
 				WriteXsiType (td.XmlType, XmlSchema.Namespace);
 			}