Forráskód Böngészése

* SerializationCodeGenerator.cs: Added support for generation of readers
and writers for several maps in a single class. Added support for
XmlMemberMapping. Fixed generation of serializers that use encoded format.
* SoapAttributeAttribute.cs, SoapAttributeOverrides.cs, SoapAttributes.cs,
SoapElementAttribute.cs, SoapEnumAttribute.cs, SoapTypeAttribute.cs,
XmlAnyElementAttribute.cs, XmlAnyElementAttributes.cs, XmlArrayAttribute.cs,
XmlArrayItemAttribute.cs, XmlArrayItemAttributes.cs, XmlAttributeAttribute.cs,
XmlAttributeOverrides.cs, XmlChoiceIdentifierAttribute.cs, XmlRootAttribute.cs,
XmlElementAttribute.cs, XmlElementAttributes.cs, XmlEnumAttribute.cs,
XmlReflectionMember.cs, XmlTextAttribute.cs, XmlTypeAttribute.cs:
Added InternalEquals method.
* XmlAttributes.cs: Removed a lot of unused code. Added InternalEquals method.
* SoapReflectionImporter.cs: Set SerializationSource to generated maps.
* XmlCustomFormatter.cs: Fixed little bug.
* XmlMapping.cs: Added Source property. This a global identifier of the map.
* XmlReflectionImporter.cs: Set SerializationSource to generated maps.
* XmlSchemaImporter.cs: Set the correct value for IsNillable when importing
mapping members.
* XmlSerializationReaderInterpreter.cs, XmlSerializationWriter.cs: Minor fixes.
* XmlSerializationWriterInterpreter.cs: WriteObject and WriteEnum were not
correctly used.
* XmlSerializer.cs: Added support for generation of serializers.

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

Lluis Sanchez 22 éve
szülő
commit
95d2d48bb3
33 módosított fájl, 1006 hozzáadás és 502 törlés
  1. 25 0
      mcs/class/System.XML/System.Xml.Serialization/ChangeLog
  2. 412 177
      mcs/class/System.XML/System.Xml.Serialization/SerializationCodeGenerator.cs
  3. 8 0
      mcs/class/System.XML/System.Xml.Serialization/SoapAttributeAttribute.cs
  4. 12 0
      mcs/class/System.XML/System.Xml.Serialization/SoapAttributeOverrides.cs
  5. 33 0
      mcs/class/System.XML/System.Xml.Serialization/SoapAttributes.cs
  6. 8 0
      mcs/class/System.XML/System.Xml.Serialization/SoapElementAttribute.cs
  7. 5 0
      mcs/class/System.XML/System.Xml.Serialization/SoapEnumAttribute.cs
  8. 2 0
      mcs/class/System.XML/System.Xml.Serialization/SoapReflectionImporter.cs
  9. 8 2
      mcs/class/System.XML/System.Xml.Serialization/SoapTypeAttribute.cs
  10. 4 7
      mcs/class/System.XML/System.Xml.Serialization/XmlAnyElementAttribute.cs
  11. 10 0
      mcs/class/System.XML/System.Xml.Serialization/XmlAnyElementAttributes.cs
  12. 7 7
      mcs/class/System.XML/System.Xml.Serialization/XmlArrayAttribute.cs
  13. 11 7
      mcs/class/System.XML/System.Xml.Serialization/XmlArrayItemAttribute.cs
  14. 10 0
      mcs/class/System.XML/System.Xml.Serialization/XmlArrayItemAttributes.cs
  15. 11 1
      mcs/class/System.XML/System.Xml.Serialization/XmlAttributeAttribute.cs
  16. 13 1
      mcs/class/System.XML/System.Xml.Serialization/XmlAttributeOverrides.cs
  17. 56 238
      mcs/class/System.XML/System.Xml.Serialization/XmlAttributes.cs
  18. 3 7
      mcs/class/System.XML/System.Xml.Serialization/XmlChoiceIdentifierAttribute.cs
  19. 1 1
      mcs/class/System.XML/System.Xml.Serialization/XmlCustomFormatter.cs
  20. 11 7
      mcs/class/System.XML/System.Xml.Serialization/XmlElementAttribute.cs
  21. 10 0
      mcs/class/System.XML/System.Xml.Serialization/XmlElementAttributes.cs
  22. 5 0
      mcs/class/System.XML/System.Xml.Serialization/XmlEnumAttribute.cs
  23. 7 0
      mcs/class/System.XML/System.Xml.Serialization/XmlMapping.cs
  24. 6 1
      mcs/class/System.XML/System.Xml.Serialization/XmlReflectionImporter.cs
  25. 22 0
      mcs/class/System.XML/System.Xml.Serialization/XmlReflectionMember.cs
  26. 7 0
      mcs/class/System.XML/System.Xml.Serialization/XmlRootAttribute.cs
  27. 4 4
      mcs/class/System.XML/System.Xml.Serialization/XmlSchemaImporter.cs
  28. 1 2
      mcs/class/System.XML/System.Xml.Serialization/XmlSerializationReaderInterpreter.cs
  29. 1 1
      mcs/class/System.XML/System.Xml.Serialization/XmlSerializationWriter.cs
  30. 5 5
      mcs/class/System.XML/System.Xml.Serialization/XmlSerializationWriterInterpreter.cs
  31. 276 26
      mcs/class/System.XML/System.Xml.Serialization/XmlSerializer.cs
  32. 4 8
      mcs/class/System.XML/System.Xml.Serialization/XmlTextAttribute.cs
  33. 8 0
      mcs/class/System.XML/System.Xml.Serialization/XmlTypeAttribute.cs

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

@@ -1,3 +1,28 @@
+2004-02-24  Lluis Sanchez Gual  <[email protected]>
+
+	* SerializationCodeGenerator.cs: Added support for generation of readers
+	  and writers for several maps in a single class. Added support for
+	  XmlMemberMapping. Fixed generation of serializers that use encoded format.
+	* SoapAttributeAttribute.cs, SoapAttributeOverrides.cs, SoapAttributes.cs,
+	  SoapElementAttribute.cs, SoapEnumAttribute.cs, SoapTypeAttribute.cs, 
+	  XmlAnyElementAttribute.cs, XmlAnyElementAttributes.cs, XmlArrayAttribute.cs,
+	  XmlArrayItemAttribute.cs, XmlArrayItemAttributes.cs, XmlAttributeAttribute.cs,
+	  XmlAttributeOverrides.cs, XmlChoiceIdentifierAttribute.cs, XmlRootAttribute.cs,
+	  XmlElementAttribute.cs, XmlElementAttributes.cs, XmlEnumAttribute.cs,
+	  XmlReflectionMember.cs, XmlTextAttribute.cs, XmlTypeAttribute.cs:
+	  Added InternalEquals method.
+	* XmlAttributes.cs: Removed a lot of unused code. Added InternalEquals method.
+	* SoapReflectionImporter.cs: Set SerializationSource to generated maps.
+	* XmlCustomFormatter.cs: Fixed little bug.
+	* XmlMapping.cs: Added Source property. This a global identifier of the map.
+	* XmlReflectionImporter.cs: Set SerializationSource to generated maps.
+	* XmlSchemaImporter.cs: Set the correct value for IsNillable when importing
+	  mapping members.
+	* XmlSerializationReaderInterpreter.cs, XmlSerializationWriter.cs: Minor fixes.
+	* XmlSerializationWriterInterpreter.cs: WriteObject and WriteEnum were not
+	  correctly used.
+	* XmlSerializer.cs: Added support for generation of serializers.
+
 2004-02-18  Atsushi Enomoto  <[email protected]>
 
 	* SerializationCodeGenerator.cs,

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 412 - 177
mcs/class/System.XML/System.Xml.Serialization/SerializationCodeGenerator.cs


+ 8 - 0
mcs/class/System.XML/System.Xml.Serialization/SoapAttributeAttribute.cs

@@ -57,5 +57,13 @@ namespace System.Xml.Serialization
 				ns = value;
 			}
 		}
+		
+		internal bool InternalEquals (SoapAttributeAttribute other)
+		{
+			if (other == null) return false;
+			return (attrName == other.attrName &&
+					dataType == other.dataType &&
+					ns == other.ns);
+		}
 	}
 }

+ 12 - 0
mcs/class/System.XML/System.Xml.Serialization/SoapAttributeOverrides.cs

@@ -68,5 +68,17 @@ namespace System.Xml.Serialization
 			return new TypeMember(type, member);
 		}
 
+		internal bool InternalEquals (SoapAttributeOverrides other)
+		{
+			if (other == null) return false;
+			if (overrides.Count != other.overrides.Count) return false;
+			
+			foreach (DictionaryEntry entry in overrides)
+			{
+				SoapAttributes val = (SoapAttributes) other.overrides [entry.Key];
+				if (val == null || !val.InternalEquals ((SoapAttributes) entry.Value)) return false;
+			}
+			return true;
+		}
 	}
 }

+ 33 - 0
mcs/class/System.XML/System.Xml.Serialization/SoapAttributes.cs

@@ -84,5 +84,38 @@ namespace System.Xml.Serialization
 			get { return  soapType; } 
 			set { soapType = value; }
 		}
+		
+		internal bool InternalEquals (SoapAttributes other)
+		{
+			if (other == null) return false;
+			if (soapIgnore != other.soapIgnore) return false;
+			
+			if (soapAttribute == null) {
+				if (other.soapAttribute != null) return false; }
+			else
+				if (!soapAttribute.InternalEquals (other.soapAttribute)) return false;
+				
+			if (soapElement == null) {
+				if (other.soapElement != null) return false; }
+			else
+				if (!soapElement.InternalEquals (other.soapElement)) return false;
+				
+			if (soapEnum == null) {
+				if (other.soapEnum != null) return false; }
+			else
+				if (!soapEnum.InternalEquals (other.soapEnum)) return false;
+				
+			if (soapType == null) {
+				if (other.soapType != null) return false; }
+			else
+				if (!soapType.InternalEquals (other.soapType)) return false;
+				
+			if (soapDefaultValue == null) {
+				if (other.soapDefaultValue != null) return false; }
+			else
+				if (!soapDefaultValue.Equals (other.soapDefaultValue)) return false;
+				
+			return true;
+		}	
 	}
 }

+ 8 - 0
mcs/class/System.XML/System.Xml.Serialization/SoapElementAttribute.cs

@@ -56,5 +56,13 @@ namespace System.Xml.Serialization
 				isNullable = value; 
 			}
 		}
+		
+		internal bool InternalEquals (SoapElementAttribute other)
+		{
+			if (other == null) return false;
+			return (elementName == other.elementName &&
+					dataType == other.dataType &&
+					isNullable == other.isNullable);
+		}
 	}
 }

+ 5 - 0
mcs/class/System.XML/System.Xml.Serialization/SoapEnumAttribute.cs

@@ -36,5 +36,10 @@ namespace System.Xml.Serialization
 				name = value; 
 			}
 		}
+		
+		internal bool InternalEquals (SoapEnumAttribute other)
+		{
+			return (other == null && name == other.name);
+		}
 	}
 }

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

@@ -69,6 +69,7 @@ namespace System.Xml.Serialization {
 			XmlMembersMapping mps = new XmlMembersMapping (elementName, ns, hasWrapperElement, writeAccessors, mapping);
 			mps.RelatedMaps = relatedMaps;
 			mps.Format = SerializationFormat.Encoded;
+			mps.Source = new MembersSerializationSource (elementName, hasWrapperElement, members, writeAccessors, false, null, includedTypes);
 			return mps;
 		}
 
@@ -101,6 +102,7 @@ namespace System.Xml.Serialization {
 			}
 			map.RelatedMaps = relatedMaps;
 			map.Format = SerializationFormat.Encoded;
+			map.Source = new SoapTypeSerializationSource (type, attributeOverrides, defaultNamespace, includedTypes);
 			return map;
 		}
 

+ 8 - 2
mcs/class/System.XML/System.Xml.Serialization/SoapTypeAttribute.cs

@@ -53,7 +53,13 @@ namespace System.Xml.Serialization
 			set { typeName = value;
 			}
 		}
-
-
+		
+		internal bool InternalEquals (SoapTypeAttribute other)
+		{
+			return (other != null &&
+					ns == other.ns &&
+					typeName == other.typeName &&
+					includeInSchema == other.includeInSchema);
+		}
 	}
 }

+ 4 - 7
mcs/class/System.XML/System.Xml.Serialization/XmlAnyElementAttribute.cs

@@ -21,7 +21,6 @@ namespace System.Xml.Serialization
 	{
 		private string elementName;
 		private string ns;
-		private int order;
 
 		public XmlAnyElementAttribute ()
 		{
@@ -54,13 +53,11 @@ namespace System.Xml.Serialization
 				ns = value;
 			}
 		}
-		/// <summary>
-		/// Specifies Order in which Memberswill be serialized as Elements.
-		/// </summary>
-		internal int Order
+		
+		internal bool InternalEquals (XmlAnyElementAttribute other)
 		{
-			get{ return  order; }
-			set{ order = value; }
+			if (other == null) return false;
+			return (elementName == other.elementName && ns == other.ns);
 		}
 	}
 }

+ 10 - 0
mcs/class/System.XML/System.Xml.Serialization/XmlAnyElementAttributes.cs

@@ -61,6 +61,16 @@ namespace System.Xml.Serialization
 		{
 			List.CopyTo(array, index);
 		}
+		
+		internal bool InternalEquals (XmlAnyElementAttributes other)
+		{
+			if (other == null) return false;
+			
+			if (Count != other.Count) return false;
+			for (int n=0; n<Count; n++)
+				if (!this[n].InternalEquals (other[n])) return false;
+			return true;
+		}
 	}
 
 }

+ 7 - 7
mcs/class/System.XML/System.Xml.Serialization/XmlArrayAttribute.cs

@@ -23,7 +23,6 @@ namespace System.Xml.Serialization
 		private XmlSchemaForm form;
 		private bool isNullable;
 		private string ns;
-		private int order;
 
 		public XmlArrayAttribute()
 		{
@@ -78,13 +77,14 @@ namespace System.Xml.Serialization
 				ns = value;
 			}
 		}
-		/// <summary>
-		/// Specifies Order in which Memberswill be serialized as Elements.
-		/// </summary>
-		internal int Order
+		
+		internal bool InternalEquals (XmlArrayAttribute other)
 		{
-			get{ return  order; }
-			set{ order = value; }
+			if (other == null) return false;
+			return (elementName == other.elementName &&
+					form == other.form &&
+					isNullable == other.isNullable &&
+					ns == other.ns);
 		}
 	}
 }

+ 11 - 7
mcs/class/System.XML/System.Xml.Serialization/XmlArrayItemAttribute.cs

@@ -26,7 +26,6 @@ namespace System.Xml.Serialization
 		private bool isNullable = true;
 		private int nestingLevel;
 		private Type type;
-		private int order;
 
 		public XmlArrayItemAttribute ()
 		{
@@ -73,13 +72,18 @@ namespace System.Xml.Serialization
 			get { return nestingLevel; }
 			set { nestingLevel = value; }
 		}
-		/// <summary>
-		/// Specifies Order in which Memberswill be serialized as Elements.
-		/// </summary>
-		public int Order
+		
+		internal bool InternalEquals (XmlArrayItemAttribute other)
 		{
-			get{ return  order; }
-			set{ order = value; }
+			if (other == null) return false;
+			
+			return (dataType == other.dataType &&
+					elementName == other.elementName &&
+					form == other.form &&
+					ns == other.ns &&
+					isNullable == other.isNullable &&
+					nestingLevel == other.nestingLevel &&
+					type == other.type);
 		}
 	}
 }

+ 10 - 0
mcs/class/System.XML/System.Xml.Serialization/XmlArrayItemAttributes.cs

@@ -57,5 +57,15 @@ namespace System.Xml.Serialization
 		{
 			List.Remove(attribute);
 		}
+		
+		internal bool InternalEquals (XmlArrayItemAttributes other)
+		{
+			if (other == null) return false;
+			
+			if (Count != other.Count) return false;
+			for (int n=0; n<Count; n++)
+				if (!this[n].InternalEquals (other[n])) return false;
+			return true;
+		}
 	}
 }

+ 11 - 1
mcs/class/System.XML/System.Xml.Serialization/XmlAttributeAttribute.cs

@@ -89,6 +89,16 @@ namespace System.Xml.Serialization
 				type = value;
 			}
 		}
-
+		
+		internal bool InternalEquals (XmlAttributeAttribute other)
+		{
+			if (other == null) return false;
+			
+			return (attributeName == other.attributeName &&
+					dataType == other.dataType &&
+					type == other.type &&
+					form == other.form &&
+					ns == other.ns);
+		}
 	}
 }

+ 13 - 1
mcs/class/System.XML/System.Xml.Serialization/XmlAttributeOverrides.cs

@@ -56,5 +56,17 @@ namespace System.Xml.Serialization
 			return new TypeMember(type, member);
 		}
 
+		internal bool InternalEquals (XmlAttributeOverrides other)
+		{
+			if (other == null) return false;
+			if (overrides.Count != other.overrides.Count) return false;
+			
+			foreach (DictionaryEntry entry in overrides)
+			{
+				XmlAttributes val = (XmlAttributes) other.overrides [entry.Key];
+				if (val == null || !val.Equals ((XmlAttributes) entry.Value)) return false;
+			}
+			return true;
+		}
 	}
-}
+}

+ 56 - 238
mcs/class/System.XML/System.Xml.Serialization/XmlAttributes.cs

@@ -34,59 +34,10 @@ namespace System.Xml.Serialization
 		private XmlTextAttribute xmlText;
 		private XmlTypeAttribute xmlType;
 
-		private MemberInfo minfo;
-		private FieldInfo  finfo;
-		private PropertyInfo pinfo;
-		internal ArrayList XmlIncludes = new ArrayList();
-		//internal string ElementName;
-
-		//The element Order in serialization.
-		internal int order;
-		internal bool isAttribute;
-		internal static XmlAttributes.XmlAttributesComparer attrComparer;
-
-		//Sorting Order of Elements: XmlNs, XmlAttributes, XmlElement
-		internal class XmlAttributesComparer : IComparer
-		{
-			public int Compare(object x,object y)
-			{
-				if(x is XmlAttributes && y is XmlAttributes)
-				{
-					XmlAttributes attx = (XmlAttributes)x;
-					XmlAttributes atty = (XmlAttributes)y;
-					if(attx.xmlns)
-						return -1;
-					if(atty.xmlns)
-						return 1;
-					if(attx.isAttribute)
-						return -1;
-					if(atty.isAttribute)
-						return 1;
-					int diff = attx.order - atty.order;
-					if(diff == 0)
-						return 0;
-					if(diff > 0)
-						return 1;
-					if(diff < 0)
-						return -1;
-				}
-				if(x == null)
-					return -1;
-				if(y == null)
-					return 1;
-				throw new Exception("Should never occur. XmlAttributesComparer.Compare");
-			}
-		}
-
 		public XmlAttributes ()
 		{
 		}
 
-		static XmlAttributes ()
-		{
-			attrComparer = new XmlAttributes.XmlAttributesComparer();
-		}
-
 		public XmlAttributes (ICustomAttributeProvider provider)
 		{
 			object[] attributes = provider.GetCustomAttributes(false);
@@ -262,197 +213,64 @@ namespace System.Xml.Serialization
 			}
 		}
 		#endregion
-
-		#region internal properties
-		internal MemberInfo MemberInfo
-		{
-			get { return  minfo; }
-			set { minfo = value; }
-		}
-
-		internal FieldInfo FieldInfo 
-		{
-			get { return  finfo; }
-			set { finfo = value; }
-		}
-
-		internal PropertyInfo PropertyInfo
-		{
-			get { return  pinfo; }
-			set { pinfo = value; }
-		}
-		#endregion
-
-		//Only permissible attributes for a class type are: XmlRoot and XmlInclude
-		internal static XmlAttributes FromClass(Type classType)
-		{
-			XmlAttributes XmlAttr = new XmlAttributes();
-			object[] attributes = classType.GetCustomAttributes(false);
-			foreach(object obj in attributes)
-			{
-				if(obj is XmlRootAttribute)
-					XmlAttr.xmlRoot = (XmlRootAttribute) obj;
-				else if(obj is XmlIncludeAttribute)
-					XmlAttr.XmlIncludes.Add(obj);
-			}
-			return XmlAttr;
-		}
-
-		internal static XmlAttributes FromField(MemberInfo member, FieldInfo finfo)
-		{
-			XmlAttributes XmlAttr = new XmlAttributes();
-			object[] attributes = member.GetCustomAttributes(false);
-			XmlAttr.AddMemberAttributes(attributes);
-
-			XmlAttr.minfo = member;
-			XmlAttr.finfo = finfo;
-
-			return XmlAttr;
-		}
-
 		
-		internal static XmlAttributes FromProperty(MemberInfo member, PropertyInfo pinfo)
-		{
-
-			XmlAttributes XmlAttr = new XmlAttributes();
-			object[] attributes = member.GetCustomAttributes(false);
-			XmlAttr.AddMemberAttributes(attributes);
-
-			XmlAttr.minfo = member;
-			XmlAttr.pinfo = pinfo;
-			return XmlAttr;
-		}
-
-		internal void AddMemberAttributes(object[] attributes)
-		{
-			foreach(object obj in attributes)
-			{
-				if(obj is XmlAnyAttributeAttribute)
-				{
-					xmlAnyAttribute = (XmlAnyAttributeAttribute) obj;
-					isAttribute = true;	
-				}
-				else if(obj is XmlAttributeAttribute)
-				{
-					xmlAttribute = (XmlAttributeAttribute) obj;
-					isAttribute = true;
-				}
-				else if(obj is XmlNamespaceDeclarationsAttribute)
-				{
-					xmlns = true;
-					isAttribute = true;
-				}
-				else if(obj is XmlAnyElementAttribute)
-				{
-					xmlAnyElements.Add((XmlAnyElementAttribute) obj);
-					order = ((XmlAnyElementAttribute) obj).Order;
-				}
-				else if(obj is XmlArrayAttribute)
-				{
-					xmlArray = (XmlArrayAttribute) obj;
-					order = ((XmlArrayAttribute) obj).Order;
-				}
-				else if(obj is XmlArrayItemAttribute)
-				{
-					xmlArrayItems.Add((XmlArrayItemAttribute) obj);
-					order = ((XmlArrayItemAttribute) obj).Order;
-				}
-				else if(obj is XmlChoiceIdentifierAttribute)
-				{
-					xmlChoiceIdentifier = (XmlChoiceIdentifierAttribute) obj;
-					order = ((XmlChoiceIdentifierAttribute) obj).Order;
-				}
-				else if(obj is XmlTextAttribute)
-				{
-					xmlText = (XmlTextAttribute) obj;
-					order = ((XmlTextAttribute) obj).Order;
-				}
-				else if(obj is XmlElementAttribute )
-				{
-					xmlElements.Add((XmlElementAttribute ) obj);
-					order = ((XmlElementAttribute ) obj).Order;
-				}
-				else if(obj is DefaultValueAttribute)
-				{
-					xmlDefaultValue = ((DefaultValueAttribute ) obj).Value;
-				}
-				else if(obj is XmlEnumAttribute)
-				{
-					xmlEnum = (XmlEnumAttribute) obj;
-				}
-				else if(obj is XmlIgnoreAttribute)
-				{
-					xmlIgnore = true;
-				}
-				else if(obj is XmlRootAttribute)
-				{
-					throw new Exception("should never happen. XmlRoot on a member");
-				}
-				else if(obj is XmlTypeAttribute)
-				{
-					xmlType = (XmlTypeAttribute) obj;
-				}
-			}
-		}
-
-		internal string GetAttributeName(Type type, string defaultName)
-		{
-			if(XmlAttribute != null && XmlAttribute.AttributeName != null && XmlAttribute.AttributeName != "")
-				return XmlAttribute.AttributeName;
-			else if (XmlType != null && XmlType.TypeName != null && XmlType.TypeName != "")
-				return XmlType.TypeName;
-			return defaultName;
-		}
-
-		internal string GetElementName(Type type, string defaultName)
-		{
-			string anonymousElemAttrName = null;
-			foreach(XmlElementAttribute elem in XmlElements)
-			{
-				if(elem.Type == type && elem.ElementName != null && elem.ElementName != "")
-					return elem.ElementName;
-				else if(elem.Type == null && elem.ElementName != null && elem.ElementName != "")
-					anonymousElemAttrName = elem.ElementName;
-			}
-			if (anonymousElemAttrName != null)
-				return anonymousElemAttrName;
-
-			if (XmlType != null && XmlType.TypeName != null && XmlType.TypeName != "")
-				return XmlType.TypeName;
-			return defaultName;
-		}
-
-		internal string GetAttributeNamespace(Type type)
-		{
-			if(XmlAttribute != null)
-				return XmlAttribute.Namespace;
-			return null;
-		}
-
-		internal string GetElementNamespace(Type type)
+		internal bool InternalEquals (XmlAttributes other)
 		{
-			string defaultNS = null;
-			foreach(XmlElementAttribute elem in XmlElements)
-			{
-				if(elem.Type == type )
-					return elem.Namespace;
-				else if(elem.Type == null)
-					defaultNS = elem.Namespace;
-			}
-			return defaultNS;
-		}
-
-		internal bool GetElementIsNullable (Type type)
-		{
-			bool defaultIsNullable = false;
-			foreach(XmlElementAttribute elem in XmlElements)
-			{
-				if(elem.Type == type)
-					return elem.IsNullable;
-				else if(elem.Type == null)
-					defaultIsNullable = elem.IsNullable;
-			}
-			return defaultIsNullable;
+			if (other == null) return false;
+			
+			if (xmlIgnore != other.xmlIgnore) return false;
+			if (xmlns != other.xmlns) return false;
+			
+			if (xmlAnyAttribute == null) {
+				if (other.xmlAnyAttribute != null) return false; }
+			else
+				if (other.xmlAnyAttribute == null) return false;
+			
+			if (!xmlAnyElements.Equals (other.xmlAnyElements)) return false; 
+			if (!xmlArrayItems.Equals (other.xmlArrayItems)) return false;
+			if (!xmlElements.Equals (other.xmlElements)) return false;
+				
+			if (xmlArray == null) {
+				if (other.xmlArray != null) return false; }
+			else
+				if (!xmlArray.InternalEquals (other.xmlArray)) return false;
+				
+			if (xmlAttribute == null) {
+				if (other.xmlAttribute != null) return false; }
+			else
+				if (!xmlAttribute.InternalEquals (other.xmlAttribute)) return false;
+				
+			if (xmlDefaultValue == null) {
+				if (other.xmlDefaultValue != null) return false; }
+			else
+				if (!xmlDefaultValue.Equals (other.xmlDefaultValue)) return false;
+				
+			if (xmlEnum == null) {
+				if (other.xmlEnum != null) return false; }
+			else
+				if (!xmlEnum.InternalEquals (other.xmlEnum)) return false;
+				
+			if (xmlRoot == null) {
+				if (other.xmlRoot != null) return false; }
+			else
+				if (!xmlRoot.InternalEquals (other.xmlRoot)) return false;
+				
+			if (xmlText == null) {
+				if (other.xmlText != null) return false; }
+			else
+				if (!xmlText.InternalEquals (other.xmlText)) return false;
+				
+			if (xmlType == null) {
+				if (other.xmlType != null) return false; }
+			else
+				if (!xmlType.InternalEquals (other.xmlType)) return false;
+				
+			if (xmlChoiceIdentifier == null) {
+				if (other.xmlChoiceIdentifier != null) return false; }
+			else
+				if (!xmlChoiceIdentifier.InternalEquals (other.xmlChoiceIdentifier)) return false;
+				
+			return true;
 		}
 	}
 }

+ 3 - 7
mcs/class/System.XML/System.Xml.Serialization/XmlChoiceIdentifierAttribute.cs

@@ -19,7 +19,6 @@ namespace System.Xml.Serialization
 	public class XmlChoiceIdentifierAttribute : Attribute
 	{
 		private string memberName;
-		private int order;
 
 		public XmlChoiceIdentifierAttribute ()
 		{
@@ -38,13 +37,10 @@ namespace System.Xml.Serialization
 			}
 		}
 		
-		/// <summary>
-		/// Specifies Order in which Memberswill be serialized as Elements.
-		/// </summary>
-		internal int Order
+		internal bool InternalEquals (XmlChoiceIdentifierAttribute ob)
 		{
-			get{ return  order; }
-			set{ order = value; }
+			if (ob == null) return false;
+			return memberName == ob.memberName;
 		}
 
 	}

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

@@ -255,7 +255,7 @@ namespace System.Xml.Serialization {
 			switch (type.XmlType)
 			{
 				case "boolean": return "XmlConvert.ToBoolean (" + value + ")";
-				case "unsignedByte": return "SByte.Parse(" + value + ")";
+				case "unsignedByte": return "byte.Parse(" + value + ")";
 				case "char": return "(char)Int32.Parse (" + value + ")";
 				case "dateTime": return "XmlConvert.ToDateTime (" + value + ")";
 				case "date": return "DateTime.ParseExact (" + value + ", \"yyyy-MM-dd\", null)";

+ 11 - 7
mcs/class/System.XML/System.Xml.Serialization/XmlElementAttribute.cs

@@ -25,7 +25,6 @@ namespace System.Xml.Serialization
 		private string ns;
 		private bool isNullable;
 		private Type type;
-		private int order;
 
 		public XmlElementAttribute ()
 		{	
@@ -92,13 +91,18 @@ namespace System.Xml.Serialization
 				type = value;
 			}
 		}
-		/// <summary>
-		/// Specifies Order in which Memberswill be serialized as Elements.
-		/// </summary>
-		internal int Order
+		
+		internal bool InternalEquals (XmlElementAttribute other)
 		{
-			get{ return  order; }
-			set{ order = value; }
+			if (other == null) return false;
+			
+			return (elementName == other.elementName &&
+					dataType == other.dataType &&
+					type == other.type &&
+					form == other.form &&
+					ns == other.ns &&
+					isNullable == other.isNullable);
 		}
+			
 	}
 }

+ 10 - 0
mcs/class/System.XML/System.Xml.Serialization/XmlElementAttributes.cs

@@ -55,5 +55,15 @@ namespace System.Xml.Serialization
 		{
 			List.CopyTo(array, index);
 		}
+		
+		internal bool InternalEquals (XmlElementAttributes other)
+		{
+			if (other == null) return false;
+			
+			if (Count != other.Count) return false;
+			for (int n=0; n<Count; n++)
+				if (!this[n].InternalEquals (other[n])) return false;
+			return true;
+		}
 	}
 }

+ 5 - 0
mcs/class/System.XML/System.Xml.Serialization/XmlEnumAttribute.cs

@@ -37,5 +37,10 @@ namespace System.Xml.Serialization
 			}
 		}
 
+		internal bool InternalEquals (XmlEnumAttribute other)
+		{
+			if (other == null) return false;
+			return name == other.name;
+		}
 	}
 }

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

@@ -18,6 +18,7 @@ namespace System.Xml.Serialization
 		ObjectMap map;
 		ArrayList relatedMaps;
 		SerializationFormat format;
+		SerializationSource source;
 
 		internal XmlMapping ()
 		{
@@ -40,6 +41,12 @@ namespace System.Xml.Serialization
 			get { return format; }
 			set { format = value; }
 		}
+		
+		internal SerializationSource Source
+		{
+			get { return source; }
+			set { source = value; }
+		}
 	}
 
 	internal class ObjectMap

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

@@ -93,6 +93,8 @@ namespace System.Xml.Serialization {
 			XmlMembersMapping mps = new XmlMembersMapping (elementName, ns, hasWrapperElement, false, mapping);
 			mps.RelatedMaps = relatedMaps;
 			mps.Format = SerializationFormat.Literal;
+			mps.Source = new MembersSerializationSource (elementName, hasWrapperElement, members, false, true, ns, includedTypes);
+			if (allowPrivateTypes) mps.Source.CanBeGenerated = false;
 			return mps;
 		}
 
@@ -137,6 +139,8 @@ namespace System.Xml.Serialization {
 
 			map.RelatedMaps = relatedMaps;
 			map.Format = SerializationFormat.Literal;
+			map.Source = new XmlTypeSerializationSource (type, root, attributeOverrides, defaultNamespace, includedTypes);
+			if (allowPrivateTypes) map.Source.CanBeGenerated = false;
 			return map;
 		}
 
@@ -263,6 +267,7 @@ namespace System.Xml.Serialization {
 				XmlTypeMapMember mem = classMap.XmlTextCollector;
 				if (mem.TypeData.Type != typeof(string) && 
 				   mem.TypeData.Type != typeof(string[]) && 
+				   mem.TypeData.Type != typeof(object[]) && 
 				   mem.TypeData.Type != typeof(XmlNode[]))
 				   
 					throw new InvalidOperationException (String.Format (errSimple2, map.TypeData.TypeName, mem.Name, mem.TypeData.TypeName));
@@ -695,7 +700,7 @@ namespace System.Xml.Serialization {
 				elem.IsNullable = att.IsNullable;
 				
 				if (elem.IsNullable && elem.TypeData.IsValueType)
-					throw new InvalidOperationException ("IsNullable may not be 'true' for value type " + elem.TypeData.FullTypeName);
+					throw new InvalidOperationException ("IsNullable may not be 'true' for value type " + elem.TypeData.FullTypeName + " in member '" + defaultName + "'");
 					
 				if (elem.TypeData.IsComplexType)
 				{

+ 22 - 0
mcs/class/System.XML/System.Xml.Serialization/XmlReflectionMember.cs

@@ -80,6 +80,28 @@ namespace System.Xml.Serialization {
 			}
 			set { xmlAttributes = value; }
 		}
+		
+		internal bool InternalEquals (XmlReflectionMember other)
+		{
+			if (other == null) return false;
+			
+			if (isReturnValue != other.isReturnValue) return false;
+			if (memberName != other.memberName) return false;
+			if (memberType != other.memberType) return false;
+			if (overrideIsNullable != other.overrideIsNullable) return false;
+			
+			if (soapAttributes == null) {
+				if (other.soapAttributes != null) return false; }
+			else
+				if (!soapAttributes.InternalEquals (other.soapAttributes)) return false;
+			
+			if (xmlAttributes == null) {
+				if (other.xmlAttributes != null) return false; }
+			else
+				if (!xmlAttributes.InternalEquals (other.xmlAttributes)) return false;
+				
+			return true;
+		}
 
 		#endregion // Properties
 	}

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

@@ -69,5 +69,12 @@ namespace System.Xml.Serialization
 				ns = value; 
 			}
 		}
+		
+		internal bool InternalEquals (XmlRootAttribute other)
+		{
+			if (other == null) return false;
+			return (dataType == other.dataType && elementName == other.elementName &&
+				    isNullable == other.isNullable && ns == other.ns);
+		}
 	}
 }

+ 4 - 4
mcs/class/System.XML/System.Xml.Serialization/XmlSchemaImporter.cs

@@ -183,7 +183,7 @@ namespace System.Xml.Serialization {
 				XmlTypeMapping tmap;
 				TypeData td = GetElementTypeData (typeQName, elem, out tmap);
 				
-				mapping[n] = ImportMemberMapping (elem.Name, typeQName.Namespace, td, tmap);
+				mapping[n] = ImportMemberMapping (elem.Name, typeQName.Namespace, elem.IsNillable, td, tmap);
 			}
 			BuildPendingMaps ();
 			return new XmlMembersMapping (mapping);
@@ -196,7 +196,7 @@ namespace System.Xml.Serialization {
 			{
 				TypeData td = GetTypeData (members[n].MemberType, null);
 				XmlTypeMapping tmap = GetTypeMapping (td);
-				mapping[n] = ImportMemberMapping (members[n].MemberName, members[n].MemberType.Namespace, td, tmap);
+				mapping[n] = ImportMemberMapping (members[n].MemberName, members[n].MemberType.Namespace, true, td, tmap);
 			}
 			BuildPendingMaps ();
 			return new XmlMembersMapping (name, ns, hasWrapperElement, false, mapping);
@@ -235,7 +235,7 @@ namespace System.Xml.Serialization {
 			return mapping;
 		}
 		
-		XmlMemberMapping ImportMemberMapping (string name, string ns, TypeData type, XmlTypeMapping emap)
+		XmlMemberMapping ImportMemberMapping (string name, string ns, bool isNullable, TypeData type, XmlTypeMapping emap)
 		{
 			XmlTypeMapMemberElement mapMem;
 			
@@ -246,7 +246,7 @@ namespace System.Xml.Serialization {
 			
 			mapMem.Name = name;
 			mapMem.TypeData = type;
-			mapMem.ElementInfo.Add (CreateElementInfo (ns, mapMem, name, type, true, XmlSchemaForm.None, emap));
+			mapMem.ElementInfo.Add (CreateElementInfo (ns, mapMem, name, type, isNullable, XmlSchemaForm.None, emap));
 			return new XmlMemberMapping (name, ns, mapMem, encodedFormat);
 		}
 		

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

@@ -55,7 +55,7 @@ namespace System.Xml.Serialization
 			throw new InvalidOperationException ("Type " + type + " not mapped");
 		}
 
-		public object ReadObject ()
+		public object ReadRoot ()
 		{
 			Reader.MoveToContent();
 			if (_typeMap is XmlTypeMapping)
@@ -291,7 +291,6 @@ namespace System.Xml.Serialization
 				FixupCallbackInfo info = new FixupCallbackInfo (this, map, isValueList);
 				fixup = new Fixup(ob, new XmlSerializationFixupCallback(info.FixupMembers), map.ElementMembers.Count);
 				AddFixup (fixup);
-				if (readByOrder) maxInd = map.ElementMembers.Count;
 			}
 
 			while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && (ind < maxInd)) 

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

@@ -70,7 +70,7 @@ namespace System.Xml.Serialization {
 		#endregion // Properties
 
 		#region Methods
-
+		
 		protected void AddWriteCallback (Type type, string typeName, string typeNs, XmlSerializationWriteCallback callback)
 		{
 			WriteCallbackInfo info = new WriteCallbackInfo ();

+ 5 - 5
mcs/class/System.XML/System.Xml.Serialization/XmlSerializationWriterInterpreter.cs

@@ -33,13 +33,13 @@ namespace System.Xml.Serialization
 			{
 				foreach (XmlTypeMapping map in maps)  {
 					CallbackInfo info = new CallbackInfo (this, map);
-					if (map.TypeData.SchemaType == SchemaTypes.Enum) AddWriteCallback(map.TypeData.Type, map.XmlType, map.Namespace, new XmlSerializationWriteCallback (info.WriteObject));
-					else AddWriteCallback(map.TypeData.Type, map.XmlType, map.Namespace, new XmlSerializationWriteCallback (info.WriteEnum));
+					if (map.TypeData.SchemaType == SchemaTypes.Enum) AddWriteCallback(map.TypeData.Type, map.XmlType, map.Namespace, new XmlSerializationWriteCallback (info.WriteEnum));
+					else AddWriteCallback(map.TypeData.Type, map.XmlType, map.Namespace, new XmlSerializationWriteCallback (info.WriteObject));
 				}
 			}
 		}
 
-		public void WriteObject (object ob)
+		public void WriteRoot (object ob)
 		{
 			WriteStartDocument ();
 
@@ -488,12 +488,12 @@ namespace System.Xml.Serialization
 
 			internal void WriteObject (object ob)
 			{
-				_swi.WriteObject (_typeMap, ob, _typeMap.ElementName, _typeMap.Namespace, false, true, false);
+				_swi.WriteObject (_typeMap, ob, _typeMap.ElementName, _typeMap.Namespace, false, false, false);
 			}
 
 			internal void WriteEnum (object ob)
 			{
-				_swi.WriteObject (_typeMap, ob, _typeMap.ElementName, _typeMap.Namespace, false, false, false);
+				_swi.WriteObject (_typeMap, ob, _typeMap.ElementName, _typeMap.Namespace, false, true, false);
 			}
 		}
 

+ 276 - 26
mcs/class/System.XML/System.Xml.Serialization/XmlSerializer.cs

@@ -8,12 +8,17 @@
 //
 
 using System;
+using System.Threading;
 using System.Collections;
 using System.IO;
 using System.Reflection;
 using System.Xml;
 using System.Xml.Schema;
 using System.Text;
+using System.CodeDom;
+using System.CodeDom.Compiler;
+using Microsoft.CSharp;
+using System.Configuration;
 
 namespace System.Xml.Serialization
 {
@@ -22,17 +27,67 @@ namespace System.Xml.Serialization
 	{
 		internal const string WsdlNamespace = "http://schemas.xmlsoap.org/wsdl/";
 		internal const string EncodingNamespace = "http://schemas.xmlsoap.org/soap/encoding/";
+		static int generationThreshold;
+		static bool backgroundGeneration = true;
+		static bool deleteTempFiles = true;
 
-#region Fields
-
+		bool customSerializer;
 		XmlMapping typeMapping;
-
-#endregion // Fields
+		
+		SerializerData serializerData;
+		Type writerType;
+		Type readerType;
+		
+		static Hashtable serializerTypes = new Hashtable ();
+		
+		internal class SerializerData
+		{
+			public int UsageCount;
+			public Type ReaderType;
+			public MethodInfo ReaderMethod;
+			public Type WriterType;
+			public MethodInfo WriterMethod;
+			public GenerationBatch Batch;
+		}
+		
+		internal class GenerationBatch
+		{
+			public bool Done;
+			public XmlMapping[] Maps;
+			public SerializerData[] Datas;
+		}
+		
+		static XmlSerializer ()
+		{
+			IDictionary table = (IDictionary) ConfigurationSettings.GetConfig("system.diagnostics");
+			if (table != null) {
+				table = (IDictionary) table["switches"];
+				if (table != null) {
+					string val = (string) table ["XmlSerialization.Compilation"];
+					if (val == "1") deleteTempFiles = false;
+				}
+			}
+			
+			string th = Environment.GetEnvironmentVariable ("MONO_XMLSERIALIZER_THS");
+			
+			if (th == null) {
+				generationThreshold = -1;
+				backgroundGeneration = false;
+			}
+			else if (th.ToLower() == "no") 
+				generationThreshold = -1;
+			else {
+				generationThreshold = int.Parse (th);
+				backgroundGeneration = (generationThreshold != 0);
+				if (generationThreshold < 1) generationThreshold = 1;
+			}
+		}
 
 #region Constructors
 
 		protected XmlSerializer ()
 		{
+			customSerializer = true;
 		}
 
 		public XmlSerializer (Type type)
@@ -45,9 +100,10 @@ namespace System.Xml.Serialization
 			typeMapping = xmlTypeMapping;
 		}
 
-		internal XmlSerializer (XmlMapping mapping)
+		internal XmlSerializer (XmlMapping mapping, SerializerData data)
 		{
 			typeMapping = mapping;
+			serializerData = data;
 		}
 
 		public XmlSerializer (Type type, string defaultNamespace)
@@ -182,10 +238,10 @@ namespace System.Xml.Serialization
 		public object Deserialize (XmlReader xmlReader)
 		{
 			XmlSerializationReader xsReader;
-			if (typeMapping == null)
+			if (customSerializer)
 				xsReader = CreateReader ();
 			else
-				xsReader = new XmlSerializationReaderInterpreter (typeMapping);
+				xsReader = CreateReader (typeMapping);
 				
 			xsReader.Initialize (xmlReader, this);
 			return Deserialize (xsReader);
@@ -193,24 +249,35 @@ namespace System.Xml.Serialization
 
 		protected virtual object Deserialize (XmlSerializationReader reader)
 		{
-			if (typeMapping != null)
-			{
-				XmlSerializationReaderInterpreter rd = reader as XmlSerializationReaderInterpreter;
-				if (rd == null) throw new InvalidOperationException ();
-				return rd.ReadObject ();
-			}
-			else
+			if (customSerializer)
 				// Must be implemented in derived class
 				throw new NotImplementedException ();
+			
+			if (reader is XmlSerializationReaderInterpreter)
+				return ((XmlSerializationReaderInterpreter)reader).ReadRoot ();
+			else
+				return serializerData.ReaderMethod.Invoke (reader, null);
 		}
 
 		public static XmlSerializer [] FromMappings (XmlMapping	[] mappings)
 		{
-			XmlSerializer [] sers = new XmlSerializer [mappings.Length];
+			XmlSerializer[] sers = new XmlSerializer [mappings.Length];
+			SerializerData[] datas = new SerializerData [mappings.Length];
+			GenerationBatch batch = new GenerationBatch ();
+			batch.Maps = mappings;
+			batch.Datas = datas;
+			
 			for (int n=0; n<mappings.Length; n++)
+			{
 				if (mappings[n] != null)
-					sers[n] = new XmlSerializer (mappings[n]);
-					
+				{
+					SerializerData data = new SerializerData ();
+					data.Batch = batch;
+					sers[n] = new XmlSerializer (mappings[n], data);
+					datas[n] = data;
+				}
+			}
+			
 			return sers;
 		}
 
@@ -224,15 +291,14 @@ namespace System.Xml.Serialization
 
 		protected virtual void Serialize (object o, XmlSerializationWriter writer)
 		{
-			if (typeMapping != null)
-			{
-				XmlSerializationWriterInterpreter wr = writer as XmlSerializationWriterInterpreter;
-				if (wr == null) throw new InvalidOperationException ();
-				wr.WriteObject (o);
-			}
-			else
+			if (customSerializer)
 				// Must be implemented in derived class
 				throw new NotImplementedException ();
+				
+			if (writer is XmlSerializationWriterInterpreter)
+				((XmlSerializationWriterInterpreter)writer).WriteRoot (o);
+			else
+				serializerData.WriterMethod.Invoke (writer, new object[] {o});
 		}
 
 		public void Serialize (Stream stream, object o)
@@ -273,10 +339,10 @@ namespace System.Xml.Serialization
 		{
 			XmlSerializationWriter xsWriter;
 			
-			if (typeMapping == null)
+			if (customSerializer)
 				xsWriter = CreateWriter ();
 			else
-				xsWriter = new XmlSerializationWriterInterpreter (typeMapping);
+				xsWriter = CreateWriter (typeMapping);
 				
 			if (namespaces == null || namespaces.Count == 0)
 			{
@@ -289,6 +355,190 @@ namespace System.Xml.Serialization
 			Serialize (o, xsWriter);
 			writer.Flush ();
 		}
+		
+		XmlSerializationWriter CreateWriter (XmlMapping typeMapping)
+		{
+			lock (this) {
+				if (serializerData != null && serializerData.WriterType != null)
+					return (XmlSerializationWriter) Activator.CreateInstance (serializerData.WriterType);
+			}
+			
+			if (!typeMapping.Source.CanBeGenerated || generationThreshold == -1)
+				return new XmlSerializationWriterInterpreter (typeMapping);
+
+			CheckGeneratedTypes (typeMapping);
+			
+			lock (this) {
+				if (serializerData.WriterType != null)
+					return (XmlSerializationWriter) Activator.CreateInstance (serializerData.WriterType);
+			}
+			
+			return new XmlSerializationWriterInterpreter (typeMapping);
+		}
+		
+		XmlSerializationReader CreateReader (XmlMapping typeMapping)
+		{
+			lock (this) {
+				if (serializerData != null && serializerData.ReaderType != null)
+					return (XmlSerializationReader) Activator.CreateInstance (serializerData.ReaderType);
+			}
+			
+			if (!typeMapping.Source.CanBeGenerated || generationThreshold == -1)
+				return new XmlSerializationReaderInterpreter (typeMapping);
+
+			CheckGeneratedTypes (typeMapping);
+			
+			lock (this) {
+				if (serializerData.ReaderType != null)
+					return (XmlSerializationReader) Activator.CreateInstance (serializerData.ReaderType);
+			}
+			
+			return new XmlSerializationReaderInterpreter (typeMapping);
+		}
+		
+		void CheckGeneratedTypes (XmlMapping typeMapping)
+		{
+			lock (this)
+			{
+				if (serializerData == null) 
+				{
+					lock (serializerTypes)
+					{
+						serializerData = (SerializerData) serializerTypes [typeMapping.Source];
+						if (serializerData == null) {
+							serializerData = new SerializerData();
+							serializerTypes [typeMapping.Source] = serializerData;
+						}
+					}
+				}
+			}
+			
+			bool generate = false;
+			lock (serializerData)
+			{
+				generate = (++serializerData.UsageCount == generationThreshold);
+			}
+			
+			if (generate)
+			{
+				if (serializerData.Batch != null)
+					GenerateSerializers (serializerData.Batch);
+				else
+				{
+					GenerationBatch batch = new GenerationBatch ();
+					batch.Maps = new XmlMapping[] {typeMapping};
+					batch.Datas = new SerializerData[] {serializerData};
+					GenerateSerializers (batch);
+				}
+			}
+		}
+		
+		void GenerateSerializers (GenerationBatch batch)
+		{
+			if (batch.Maps.Length != batch.Datas.Length)
+				throw new ArgumentException ("batch");
+
+			lock (batch)
+			{
+				if (batch.Done) return;
+				batch.Done = true;
+			}
+			
+			if (backgroundGeneration)
+				ThreadPool.QueueUserWorkItem (new WaitCallback (RunSerializerGeneration), batch);
+			else
+				RunSerializerGeneration (batch);
+		}
+		
+		void RunSerializerGeneration (object obj)
+		{
+			try
+			{
+				RunSerializerGenerationAux (obj);
+			}
+			catch (Exception ex)
+			{
+				Console.WriteLine (ex);
+			}
+		}
+		
+		void RunSerializerGenerationAux (object obj)
+		{
+			DateTime tim = DateTime.Now;
+			
+			GenerationBatch batch = (GenerationBatch) obj;
+			XmlMapping[] maps = batch.Maps;
+			
+			string file = Path.GetTempFileName ();
+			StreamWriter sw = new StreamWriter (file);
+//			Console.WriteLine ("Generating " + file);
+			
+			SerializationCodeGenerator gen = new SerializationCodeGenerator (maps);
+			
+			try
+			{
+				gen.GenerateSerializers (sw);
+			}
+			catch (Exception ex)
+			{
+				Console.WriteLine ("Serializer could not be generated");
+				Console.WriteLine (ex);
+				
+				if (deleteTempFiles)
+					File.Delete (file);
+				return;
+			}
+			sw.Close ();
+			
+			CSharpCodeProvider provider = new CSharpCodeProvider();
+			ICodeCompiler comp = provider.CreateCompiler ();
+			
+			CompilerParameters cp = new CompilerParameters();
+		    cp.GenerateExecutable = false;
+			cp.IncludeDebugInformation = false;
+		    cp.GenerateInMemory = true;
+		    cp.ReferencedAssemblies.Add ("System.dll");
+			cp.ReferencedAssemblies.Add ("System.Xml");
+			
+			foreach (Type rtype in gen.ReferencedTypes)
+			{
+				if (!cp.ReferencedAssemblies.Contains (rtype.Assembly.Location))
+					cp.ReferencedAssemblies.Add (rtype.Assembly.Location);
+			}
+
+			CompilerResults res = comp.CompileAssemblyFromFile (cp, file);
+			if (res.Errors.Count > 0)
+			{
+				Console.WriteLine ("Error while compiling generated serializer");
+				foreach (CompilerError error in res.Errors)
+					Console.WriteLine (error);
+					
+				if (deleteTempFiles)
+					File.Delete (file);
+				return;
+			}
+			
+			GenerationResult[] results = gen.GenerationResults;
+			for (int n=0; n<results.Length; n++)
+			{
+				GenerationResult gres = results[n];
+				SerializerData sd = batch.Datas [n];
+				lock (sd)
+				{
+					sd.WriterType = res.CompiledAssembly.GetType (gres.Namespace + "." + gres.WriterClassName);
+					sd.ReaderType = res.CompiledAssembly.GetType (gres.Namespace + "." + gres.ReaderClassName);
+					sd.WriterMethod = sd.WriterType.GetMethod (gres.WriteMethodName);
+					sd.ReaderMethod = sd.ReaderType.GetMethod (gres.ReadMethodName);
+					sd.Batch = null;
+				}
+			}
+			
+			if (deleteTempFiles)
+				File.Delete (file);
+
+//			Console.WriteLine ("Generation finished - " + (DateTime.Now - tim).TotalMilliseconds + " ms");
+		}
+		
 #endregion // Methods
 	}
 }

+ 4 - 8
mcs/class/System.XML/System.Xml.Serialization/XmlTextAttribute.cs

@@ -20,7 +20,6 @@ namespace System.Xml.Serialization
 	{
 		private string dataType;
 		private Type type;
-		private int order;
 
 		public XmlTextAttribute ()
 		{
@@ -48,14 +47,11 @@ namespace System.Xml.Serialization
 				type = value; 
 			}
 		}
-		/// <summary>
-		/// Specifies Order in which Memberswill be serialized as Elements.
-		/// </summary>
-		internal int Order
+		
+		internal bool InternalEquals (XmlTextAttribute ob)
 		{
-			get{ return  order; }
-			set{ order = value; }
+			if (ob == null) return false;
+			return (dataType == ob.dataType && type == ob.type);
 		}
-
 	}
 }

+ 8 - 0
mcs/class/System.XML/System.Xml.Serialization/XmlTypeAttribute.cs

@@ -56,5 +56,13 @@ namespace System.Xml.Serialization
 				typeName = value; 
 			}
 		}
+		
+		internal bool InternalEquals (XmlTypeAttribute other)
+		{
+			if (other == null) return false;
+			return (includeInSchema == other.includeInSchema && 
+					typeName == other.typeName &&
+				    ns != other.ns);
+		}
 	}
 }

Nem az összes módosított fájl került megjelenítésre, mert túl sok fájl változott