瀏覽代碼

move to from olive to mcs

svn path=/trunk/mcs/; revision=111184
Jb Evain 17 年之前
父節點
當前提交
8b9722d103
共有 100 個文件被更改,包括 11003 次插入0 次删除
  1. 71 0
      mcs/class/System.Runtime.Serialization/Assembly/AssemblyInfo.cs
  2. 8 0
      mcs/class/System.Runtime.Serialization/Assembly/ChangeLog
  3. 77 0
      mcs/class/System.Runtime.Serialization/ChangeLog
  4. 32 0
      mcs/class/System.Runtime.Serialization/Makefile
  5. 7 0
      mcs/class/System.Runtime.Serialization/System.Runtime.Serialization.Configuration/ChangeLog
  6. 42 0
      mcs/class/System.Runtime.Serialization/System.Runtime.Serialization.Configuration/DeclaredTypeElement.cs
  7. 54 0
      mcs/class/System.Runtime.Serialization/System.Runtime.Serialization.Configuration/DeclaredTypeElementCollection.cs
  8. 42 0
      mcs/class/System.Runtime.Serialization/System.Runtime.Serialization.Configuration/ParameterElement.cs
  9. 54 0
      mcs/class/System.Runtime.Serialization/System.Runtime.Serialization.Configuration/ParameterElementCollection.cs
  10. 42 0
      mcs/class/System.Runtime.Serialization/System.Runtime.Serialization.Configuration/SerializationSectionGroup.cs
  11. 42 0
      mcs/class/System.Runtime.Serialization/System.Runtime.Serialization.Configuration/TypeElement.cs
  12. 54 0
      mcs/class/System.Runtime.Serialization/System.Runtime.Serialization.Configuration/TypeElementCollection.cs
  13. 42 0
      mcs/class/System.Runtime.Serialization/System.Runtime.Serialization.Configuration/XmlFormatterSection.cs
  14. 134 0
      mcs/class/System.Runtime.Serialization/System.Runtime.Serialization.csproj
  15. 60 0
      mcs/class/System.Runtime.Serialization/System.Runtime.Serialization.dll.sources
  16. 423 0
      mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/ChangeLog
  17. 69 0
      mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/CollectionDataContractAttribute.cs
  18. 54 0
      mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/ContractNamespaceAttribute.cs
  19. 56 0
      mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/DataContractAttribute.cs
  20. 408 0
      mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/DataContractSerializer.cs
  21. 67 0
      mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/DataMemberAttribute.cs
  22. 49 0
      mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/EnumMemberAttribute.cs
  23. 52 0
      mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/ExportOptions.cs
  24. 44 0
      mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/ExtensionDataObject.cs
  25. 60 0
      mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/IDataContractSurrogate.cs
  26. 36 0
      mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/IExtensibleDataObject.cs
  27. 97 0
      mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/ImportOptions.cs
  28. 59 0
      mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/InvalidDataContractException.cs
  29. 59 0
      mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/KnownTypeAttribute.cs
  30. 659 0
      mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/KnownTypeCollection.cs
  31. 274 0
      mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/NetDataContractSerializer.cs
  32. 740 0
      mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/SerializationMap.cs
  33. 142 0
      mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlFormatterDeserializer.cs
  34. 140 0
      mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlFormatterSerializer.cs
  35. 136 0
      mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlObjectSerializer.cs
  36. 77 0
      mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlSerializableServices.cs
  37. 180 0
      mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XsdDataContractExporter.cs
  38. 325 0
      mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XsdDataContractImporter.cs
  39. 17 0
      mcs/class/System.Runtime.Serialization/System.Runtime.Serialization_test.dll.sources
  40. 365 0
      mcs/class/System.Runtime.Serialization/System.Xml/ChangeLog
  41. 39 0
      mcs/class/System.Runtime.Serialization/System.Xml/IStreamProvider.cs
  42. 50 0
      mcs/class/System.Runtime.Serialization/System.Xml/IXmlBinaryReaderInitializer.cs
  43. 42 0
      mcs/class/System.Runtime.Serialization/System.Xml/IXmlBinaryWriterInitializer.cs
  44. 39 0
      mcs/class/System.Runtime.Serialization/System.Xml/IXmlDictionary.cs
  45. 50 0
      mcs/class/System.Runtime.Serialization/System.Xml/IXmlMtomReaderInitializer.cs
  46. 42 0
      mcs/class/System.Runtime.Serialization/System.Xml/IXmlMtomWriterInitializer.cs
  47. 48 0
      mcs/class/System.Runtime.Serialization/System.Xml/IXmlUTF8ReaderInitializer.cs
  48. 40 0
      mcs/class/System.Runtime.Serialization/System.Xml/IXmlUTF8WriterInitializer.cs
  49. 34 0
      mcs/class/System.Runtime.Serialization/System.Xml/OnXmlDictionaryReaderClose.cs
  50. 168 0
      mcs/class/System.Runtime.Serialization/System.Xml/UniqueId.cs
  51. 1114 0
      mcs/class/System.Runtime.Serialization/System.Xml/XmlBinaryDictionaryReader.cs
  52. 934 0
      mcs/class/System.Runtime.Serialization/System.Xml/XmlBinaryDictionaryWriter.cs
  53. 145 0
      mcs/class/System.Runtime.Serialization/System.Xml/XmlBinaryFormat.cs
  54. 69 0
      mcs/class/System.Runtime.Serialization/System.Xml/XmlBinaryReaderSession.cs
  55. 74 0
      mcs/class/System.Runtime.Serialization/System.Xml/XmlBinaryWriterSession.cs
  56. 187 0
      mcs/class/System.Runtime.Serialization/System.Xml/XmlC14NWriter.cs
  57. 92 0
      mcs/class/System.Runtime.Serialization/System.Xml/XmlCanonicalWriter.cs
  58. 129 0
      mcs/class/System.Runtime.Serialization/System.Xml/XmlDictionary.cs
  59. 597 0
      mcs/class/System.Runtime.Serialization/System.Xml/XmlDictionaryReader.cs
  60. 522 0
      mcs/class/System.Runtime.Serialization/System.Xml/XmlDictionaryReaderAutoGen.cs
  61. 106 0
      mcs/class/System.Runtime.Serialization/System.Xml/XmlDictionaryReaderQuotas.cs
  62. 74 0
      mcs/class/System.Runtime.Serialization/System.Xml/XmlDictionaryString.cs
  63. 309 0
      mcs/class/System.Runtime.Serialization/System.Xml/XmlDictionaryWriter.cs
  64. 202 0
      mcs/class/System.Runtime.Serialization/System.Xml/XmlDictionaryWriterAutoGen.cs
  65. 302 0
      mcs/class/System.Runtime.Serialization/System.Xml/XmlSimpleDictionaryReader.cs
  66. 212 0
      mcs/class/System.Runtime.Serialization/System.Xml/XmlSimpleDictionaryWriter.cs
  67. 1 0
      mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.AccessViolationException.xml
  68. 1 0
      mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.ActivationContext+ContextForm.xml
  69. 1 0
      mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.AppDomainManagerInitializationOptions.xml
  70. 1 0
      mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.AppDomainSetup.xml
  71. 1 0
      mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.AppDomainUnloadedException.xml
  72. 1 0
      mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.ApplicationException.xml
  73. 1 0
      mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.ArgumentException.xml
  74. 1 0
      mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.ArgumentNullException.xml
  75. 1 0
      mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.ArgumentOutOfRangeException.xml
  76. 1 0
      mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.ArithmeticException.xml
  77. 1 0
      mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.ArrayTypeMismatchException.xml
  78. 1 0
      mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.AttributeTargets.xml
  79. 1 0
      mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.BadImageFormatException.xml
  80. 1 0
      mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.Base64FormattingOptions.xml
  81. 1 0
      mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.Boolean.xml
  82. 1 0
      mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.Byte.xml
  83. 1 0
      mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.CannotUnloadAppDomainException.xml
  84. 1 0
      mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.Char.xml
  85. 1 0
      mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.Collections.ArrayList.xml
  86. 1 0
      mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.Collections.CaseInsensitiveComparer.xml
  87. 1 0
      mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.Collections.CaseInsensitiveHashCodeProvider.xml
  88. 1 0
      mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.Collections.DictionaryEntry.xml
  89. 1 0
      mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.Collections.Generic.KeyNotFoundException.xml
  90. 1 0
      mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.Collections.Hashtable.xml
  91. 1 0
      mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.Collections.Queue.xml
  92. 1 0
      mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.Collections.SortedList.xml
  93. 1 0
      mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.Collections.Specialized.HybridDictionary.xml
  94. 1 0
      mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.Collections.Specialized.ListDictionary.xml
  95. 1 0
      mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.Collections.Specialized.OrderedDictionary.xml
  96. 1 0
      mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.Collections.Specialized.StringCollection.xml
  97. 1 0
      mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.Collections.Specialized.StringDictionary.xml
  98. 1 0
      mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.Collections.Stack.xml
  99. 1 0
      mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.ComponentModel.BindableSupport.xml
  100. 1 0
      mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.ComponentModel.BindingDirection.xml

+ 71 - 0
mcs/class/System.Runtime.Serialization/Assembly/AssemblyInfo.cs

@@ -0,0 +1,71 @@
+//
+// AssemblyInfo.cs
+//
+// Author:
+//   Andreas Nahr ([email protected])
+//
+// (C) 2003 Ximian, Inc.  http://www.ximian.com
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Reflection;
+using System.Resources;
+using System.Security;
+using System.Security.Permissions;
+using System.Diagnostics;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about the System.Runtime.Serialization assembly
+// v3.0 Assembly
+
+[assembly: AssemblyTitle ("System.Runtime.Serialization.dll")]
+[assembly: AssemblyDescription ("System.Runtime.Serialization.dll")]
+[assembly: AssemblyDefaultAlias ("System.Runtime.Serialization.dll")]
+
+[assembly: AssemblyCompany (Consts.MonoCompany)]
+[assembly: AssemblyProduct (Consts.MonoProduct)]
+[assembly: AssemblyCopyright (Consts.MonoCopyright)]
+[assembly: AssemblyVersion (Consts.FxVersion)]
+[assembly: SatelliteContractVersion (Consts.FxVersion)]
+[assembly: AssemblyInformationalVersion (Consts.FxFileVersion)]
+[assembly: AssemblyFileVersion (Consts.FxFileVersion)]
+
+[assembly: NeutralResourcesLanguage ("en-US")]
+[assembly: CLSCompliant (true)]
+[assembly: AssemblyDelaySign (true)]
+[assembly: AssemblyKeyFile ("../ecma.pub")]
+
+[assembly: ComVisible (false)]
+[assembly: ComCompatibleVersion (1, 0, 3300, 0)]
+[assembly: AllowPartiallyTrustedCallers]
+
+[assembly: CompilationRelaxations (CompilationRelaxations.NoStringInterning)]
+[assembly: Debuggable (DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
+[assembly: RuntimeCompatibility (WrapNonExceptionThrows = true)]
+[assembly: SecurityCritical (SecurityCriticalScope.Explicit)]
+[assembly: SecurityPermission (SecurityAction.RequestMinimum, SkipVerification = true)]
+
+// FIXME: We get collisions with this internalsVisibleTo because of Consts.cs and MonoTodo
+//[assembly: InternalsVisibleTo ("System.ServiceModel.Web, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]

+ 8 - 0
mcs/class/System.Runtime.Serialization/Assembly/ChangeLog

@@ -0,0 +1,8 @@
+2008-04-25  Andreas Nahr <[email protected]>
+
+	* AssemblyInfo.cs: Added missing attributes
+
+2005-09-22  Atsushi Enomoto  <[email protected]>
+
+	* AssemblyInfo.cs : new file.
+

+ 77 - 0
mcs/class/System.Runtime.Serialization/ChangeLog

@@ -0,0 +1,77 @@
+2008-03-31  Igor Zelmanovich <[email protected]>
+
+	* Makefile : add reference to System.Data.dll, 
+	required for test suite.
+	* System.Runtime.Serialization_test.dll.sources : added
+	DataContractSerializerTest_FrameworkTypes_System.Data.cs
+
+2008-03-31  Atsushi Enomoto  <[email protected]>
+
+	* Makefile : Fix EXTRA_DISTFILES.
+
+2008-03-21  Atsushi Enomoto  <[email protected]>
+
+	* Makefile : added missing EXTRA_DISTFILES.
+
+2008-02-27 Eyal Alaluf <[email protected]>
+
+	* Makefile: Filter out some warnings.
+	* System.Runtime.Serialization_test.dll.sources: Added tests for
+	  System.Runtime.Serialization attributes.
+
+2007-12-05  Atsushi Enomoto  <[email protected]>
+
+	* Makefile : add net_3_5 profile as a target profile.
+
+2007-03-30  Atsushi Enomoto  <[email protected]>
+
+	* reader-method-gen.cs : changed ReadElementContentAsXxx() 
+	  implementation to rather call ReadContentAsXxx() so that binary
+	  reader implementation could be implemented easily.
+
+2007-03-16  Atsushi Enomoto  <[email protected]>
+
+	(oops, I forgot to add entry for it last time)
+	* reader-method-gen.cs : added ReadElementContentAsXxx() support.
+
+2007-02-27  Wade Berrier  <[email protected]>
+
+	* Makefile: Include resource files in EXTRA_DISTFILES
+
+2006-09-05  Ankit Jain  <[email protected]>
+
+	* resources/mstypes.schema: New.
+	* Makefile (RESOURCE_FILES): Add resources/mstypes.schema
+
+2006-09-01  Ankit Jain  <[email protected]>
+
+	* System.Runtime.Serialization_test.dll.sources : Added
+	XsdDataContractExporterTest.cs
+
+2006-07-27  Ankit Jain  <[email protected]>
+
+	* Makefile (TEST_MCS_FLAGS): Add /r:System.ServiceModel.dll
+	* System.Runtime.Serialization_test.dll.sources : Added
+	XsdDataContractImporterTest.cs
+
+2005-10-20  Atsushi Enomoto  <[email protected]>
+
+	* System.Runtime.Serialization_test.dll.sources : added. However
+	  run-test is not working fine due to appdomain problem(?).
+
+2005-10-03  Atsushi Enomoto  <[email protected]>
+
+	* Makefile : added /r:System.Configuration.dll.
+	* System.Runtime.Serialization.dll.sources : added new files.
+
+2005-09-27  Atsushi Enomoto  <[email protected]>
+
+	* System.Runtime.Serialization.dll.sources :
+	  added XmlSimpleDictionaryReader.cs (slightly boring implementation).
+	  Now it is autogenerated by "make update-dll-sources".
+
+2005-09-22  Atsushi Enomoto  <[email protected]>
+
+	* Makefile,
+	  System.Runtime.Serialization.dll.sources : new files.
+

+ 32 - 0
mcs/class/System.Runtime.Serialization/Makefile

@@ -0,0 +1,32 @@
+thisdir = class/System.Runtime.Serialization
+SUBDIRS = 
+include ../../build/rules.make
+
+RESOURCE_FILES = \
+	resources/mstypes.schema
+
+LIBRARY = System.Runtime.Serialization.dll
+LIB_MCS_FLAGS = \
+			/nowarn:168,169,219,414 \
+	        /r:System.dll \
+	        /r:System.Xml.dll \
+	        /r:System.Data.dll \
+		/r:System.Configuration.dll \
+		$(RESOURCE_FILES:%=/resource:%)
+
+TEST_MCS_FLAGS = $(LIB_MCS_FLAGS) /r:System.ServiceModel.dll
+
+EXTRA_DISTFILES = $(RESOURCE_FILES) \
+	Test/Resources/FrameworkTypes/* \
+	Test/System.Runtime.Serialization/one.xml
+
+# This assembly is .NET 3.0 or later only
+VALID_PROFILE := $(filter net_3_0 net_3_5, $(PROFILE))
+ifndef VALID_PROFILE
+LIBRARY_NAME = dummy-System.Runtime.Serialization.dll
+NO_INSTALL = yes
+NO_SIGN_ASSEMBLY = yes
+NO_TEST = yes
+endif
+
+include ../../build/library.make

+ 7 - 0
mcs/class/System.Runtime.Serialization/System.Runtime.Serialization.Configuration/ChangeLog

@@ -0,0 +1,7 @@
+2005-10-03  Atsushi Enomoto  <[email protected]>
+
+	* DeclaredTypeElementCollection.cs, TypeElement.cs,
+	  DeclaredTypeElement.cs, SerializationSectionGroup.cs,
+	  ParameterElementCollection.cs, TypeElementCollection.cs,
+	  XmlFormatterSection.cs, ParameterElement.cs : new files.
+

+ 42 - 0
mcs/class/System.Runtime.Serialization/System.Runtime.Serialization.Configuration/DeclaredTypeElement.cs

@@ -0,0 +1,42 @@
+//
+// DeclaredTypeElement.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+using System;
+using System.Configuration;
+
+namespace System.Runtime.Serialization.Configuration
+{
+	[MonoTODO]
+	public sealed class DeclaredTypeElement : ConfigurationElement
+	{
+		public DeclaredTypeElement ()
+		{
+		}
+	}
+}
+#endif

+ 54 - 0
mcs/class/System.Runtime.Serialization/System.Runtime.Serialization.Configuration/DeclaredTypeElementCollection.cs

@@ -0,0 +1,54 @@
+//
+// DeclaredTypeElementCollection.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+using System;
+using System.Configuration;
+
+namespace System.Runtime.Serialization.Configuration
+{
+	[MonoTODO]
+	public sealed class DeclaredTypeElementCollection
+		: ConfigurationElementCollection
+	{
+		public DeclaredTypeElementCollection ()
+		{
+		}
+
+		protected override ConfigurationElement CreateNewElement ()
+		{
+			throw new NotImplementedException ();
+		}
+
+		protected override Object GetElementKey (
+			ConfigurationElement element)
+		{
+			throw new NotImplementedException ();
+		}
+	}
+}
+#endif

+ 42 - 0
mcs/class/System.Runtime.Serialization/System.Runtime.Serialization.Configuration/ParameterElement.cs

@@ -0,0 +1,42 @@
+//
+// ParameterElement.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+using System;
+using System.Configuration;
+
+namespace System.Runtime.Serialization.Configuration
+{
+	[MonoTODO]
+	public sealed class ParameterElement : ConfigurationElement
+	{
+		public ParameterElement ()
+		{
+		}
+	}
+}
+#endif

+ 54 - 0
mcs/class/System.Runtime.Serialization/System.Runtime.Serialization.Configuration/ParameterElementCollection.cs

@@ -0,0 +1,54 @@
+//
+// ParameterElementCollection.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+using System;
+using System.Configuration;
+
+namespace System.Runtime.Serialization.Configuration
+{
+	[MonoTODO]
+	public sealed class ParameterElementCollection
+		: ConfigurationElementCollection
+	{
+		public ParameterElementCollection ()
+		{
+		}
+
+		protected override ConfigurationElement CreateNewElement ()
+		{
+			throw new NotImplementedException ();
+		}
+
+		protected override Object GetElementKey (
+			ConfigurationElement element)
+		{
+			throw new NotImplementedException ();
+		}
+	}
+}
+#endif

+ 42 - 0
mcs/class/System.Runtime.Serialization/System.Runtime.Serialization.Configuration/SerializationSectionGroup.cs

@@ -0,0 +1,42 @@
+//
+// SerializationSectionGroup.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+using System;
+using System.Configuration;
+
+namespace System.Runtime.Serialization.Configuration
+{
+	[MonoTODO]
+	public sealed class SerializationSectionGroup : ConfigurationSectionGroup
+	{
+		public SerializationSectionGroup ()
+		{
+		}
+	}
+}
+#endif

+ 42 - 0
mcs/class/System.Runtime.Serialization/System.Runtime.Serialization.Configuration/TypeElement.cs

@@ -0,0 +1,42 @@
+//
+// TypeElement.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+using System;
+using System.Configuration;
+
+namespace System.Runtime.Serialization.Configuration
+{
+	[MonoTODO]
+	public sealed class TypeElement : ConfigurationElement
+	{
+		public TypeElement ()
+		{
+		}
+	}
+}
+#endif

+ 54 - 0
mcs/class/System.Runtime.Serialization/System.Runtime.Serialization.Configuration/TypeElementCollection.cs

@@ -0,0 +1,54 @@
+//
+// TypeElementCollection.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+using System;
+using System.Configuration;
+
+namespace System.Runtime.Serialization.Configuration
+{
+	[MonoTODO]
+	public sealed class TypeElementCollection
+		: ConfigurationElementCollection
+	{
+		public TypeElementCollection ()
+		{
+		}
+
+		protected override ConfigurationElement CreateNewElement ()
+		{
+			throw new NotImplementedException ();
+		}
+
+		protected override Object GetElementKey (
+			ConfigurationElement element)
+		{
+			throw new NotImplementedException ();
+		}
+	}
+}
+#endif

+ 42 - 0
mcs/class/System.Runtime.Serialization/System.Runtime.Serialization.Configuration/XmlFormatterSection.cs

@@ -0,0 +1,42 @@
+//
+// XmlFormatterSection.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+using System;
+using System.Configuration;
+
+namespace System.Runtime.Serialization.Configuration
+{
+	[MonoTODO]
+	public sealed class XmlFormatterSection : ConfigurationSection
+	{
+		public XmlFormatterSection ()
+		{
+		}
+	}
+}
+#endif

+ 134 - 0
mcs/class/System.Runtime.Serialization/System.Runtime.Serialization.csproj

@@ -0,0 +1,134 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProductVersion>9.0.21022</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{A9DA8BA0-BEE0-4C51-AE51-BC67583337A9}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>System.Runtime.Serialization</RootNamespace>
+    <AssemblyName>System.Runtime.Serialization</AssemblyName>
+    <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent>
+    <SignAssembly>false</SignAssembly>
+    <AssemblyOriginatorKeyFile>
+    </AssemblyOriginatorKeyFile>
+    <DelaySign>false</DelaySign>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>TRACE;DEBUG;NET_2_0,TARGET_DOTNET</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE;NET_2_0,TARGET_DOTNET</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.configuration" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="..\..\build\common\Locale.cs">
+      <Link>Locale.cs</Link>
+    </Compile>
+    <Compile Include="..\..\build\common\MonoTODOAttribute.cs">
+      <Link>MonoTODOAttribute.cs</Link>
+    </Compile>
+    <Compile Include="Assembly\AssemblyInfo.cs" />
+    <Compile Include="System.Runtime.Serialization.Configuration\DeclaredTypeElement.cs" />
+    <Compile Include="System.Runtime.Serialization.Configuration\DeclaredTypeElementCollection.cs" />
+    <Compile Include="System.Runtime.Serialization.Configuration\ParameterElement.cs" />
+    <Compile Include="System.Runtime.Serialization.Configuration\ParameterElementCollection.cs" />
+    <Compile Include="System.Runtime.Serialization.Configuration\SerializationSectionGroup.cs" />
+    <Compile Include="System.Runtime.Serialization.Configuration\TypeElement.cs" />
+    <Compile Include="System.Runtime.Serialization.Configuration\TypeElementCollection.cs" />
+    <Compile Include="System.Runtime.Serialization.Configuration\XmlFormatterSection.cs" />
+    <Compile Include="System.Runtime.Serialization\CollectionDataContractAttribute.cs" />
+    <Compile Include="System.Runtime.Serialization\ContractNamespaceAttribute.cs" />
+    <Compile Include="System.Runtime.Serialization\DataContractAttribute.cs" />
+    <Compile Include="System.Runtime.Serialization\DataContractSerializer.cs" />
+    <Compile Include="System.Runtime.Serialization\DataMemberAttribute.cs" />
+    <Compile Include="System.Runtime.Serialization\EnumMemberAttribute.cs" />
+    <Compile Include="System.Runtime.Serialization\ExportOptions.cs" />
+    <Compile Include="System.Runtime.Serialization\ExtensionDataObject.cs" />
+    <Compile Include="System.Runtime.Serialization\IDataContractSurrogate.cs" />
+    <Compile Include="System.Runtime.Serialization\IExtensibleDataObject.cs" />
+    <Compile Include="System.Runtime.Serialization\ImportOptions.cs" />
+    <Compile Include="System.Runtime.Serialization\InvalidDataContractException.cs" />
+    <Compile Include="System.Runtime.Serialization\KnownTypeAttribute.cs" />
+    <Compile Include="System.Runtime.Serialization\KnownTypeCollection.cs" />
+    <Compile Include="System.Runtime.Serialization\NetDataContractSerializer.cs" />
+    <Compile Include="System.Runtime.Serialization\SerializationMap.cs" />
+    <Compile Include="System.Runtime.Serialization\XmlFormatterDeserializer.cs" />
+    <Compile Include="System.Runtime.Serialization\XmlFormatterSerializer.cs" />
+    <Compile Include="System.Runtime.Serialization\XmlObjectSerializer.cs" />
+    <Compile Include="System.Runtime.Serialization\XmlSerializableServices.cs" />
+    <Compile Include="System.Runtime.Serialization\XsdDataContractExporter.cs" />
+    <Compile Include="System.Runtime.Serialization\XsdDataContractImporter.cs" />
+    <Compile Include="System.Xml\IStreamProvider.cs" />
+    <Compile Include="System.Xml\IXmlBinaryReaderInitializer.cs" />
+    <Compile Include="System.Xml\IXmlBinaryWriterInitializer.cs" />
+    <Compile Include="System.Xml\IXmlDictionary.cs" />
+    <Compile Include="System.Xml\IXmlMtomReaderInitializer.cs" />
+    <Compile Include="System.Xml\IXmlMtomWriterInitializer.cs" />
+    <Compile Include="System.Xml\IXmlUTF8ReaderInitializer.cs" />
+    <Compile Include="System.Xml\IXmlUTF8WriterInitializer.cs" />
+    <Compile Include="System.Xml\OnXmlDictionaryReaderClose.cs" />
+    <Compile Include="System.Xml\UniqueId.cs" />
+    <Compile Include="System.Xml\XmlBinaryDictionaryReader.cs" />
+    <Compile Include="System.Xml\XmlBinaryDictionaryWriter.cs" />
+    <Compile Include="System.Xml\XmlBinaryFormat.cs" />
+    <Compile Include="System.Xml\XmlBinaryReaderSession.cs" />
+    <Compile Include="System.Xml\XmlBinaryWriterSession.cs" />
+    <Compile Include="System.Xml\XmlC14NWriter.cs" />
+    <Compile Include="System.Xml\XmlCanonicalWriter.cs" />
+    <Compile Include="System.Xml\XmlDictionary.cs" />
+    <Compile Include="System.Xml\XmlDictionaryReader.cs" />
+    <Compile Include="System.Xml\XmlDictionaryReaderAutoGen.cs" />
+    <Compile Include="System.Xml\XmlDictionaryReaderQuotas.cs" />
+    <Compile Include="System.Xml\XmlDictionaryString.cs" />
+    <Compile Include="System.Xml\XmlDictionaryWriter.cs" />
+    <Compile Include="System.Xml\XmlDictionaryWriterAutoGen.cs" />
+    <Compile Include="System.Xml\XmlSimpleDictionaryReader.cs" />
+    <Compile Include="System.Xml\XmlSimpleDictionaryWriter.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="..\..\build\common\Consts.cs.in">
+      <Link>Consts.cs.in</Link>
+    </Compile>
+  </ItemGroup>
+  <ItemGroup>
+	  <EmbeddedResource Include="resources\mstypes.schema" >
+		  <LogicalName>mstypes.schema</LogicalName>
+	  </EmbeddedResource>
+  </ItemGroup>
+  <ItemGroup>
+    <Folder Include="Properties\" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+  <PropertyGroup>
+    <PostBuildEvent>@rem "C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\gacutil.exe" /i "$(TargetPath)" /f
+@rem "C:\Program Files\Mono-1.2.6\bin\gacutil.bat" -i "$(TargetPath)"</PostBuildEvent>
+  </PropertyGroup>
+</Project>

+ 60 - 0
mcs/class/System.Runtime.Serialization/System.Runtime.Serialization.dll.sources

@@ -0,0 +1,60 @@
+../../build/common/Consts.cs
+../../build/common/Locale.cs
+../../build/common/MonoTODOAttribute.cs
+Assembly/AssemblyInfo.cs
+System.Runtime.Serialization.Configuration/DeclaredTypeElement.cs
+System.Runtime.Serialization.Configuration/DeclaredTypeElementCollection.cs
+System.Runtime.Serialization.Configuration/ParameterElement.cs
+System.Runtime.Serialization.Configuration/ParameterElementCollection.cs
+System.Runtime.Serialization.Configuration/SerializationSectionGroup.cs
+System.Runtime.Serialization.Configuration/TypeElement.cs
+System.Runtime.Serialization.Configuration/TypeElementCollection.cs
+System.Runtime.Serialization.Configuration/XmlFormatterSection.cs
+System.Runtime.Serialization/CollectionDataContractAttribute.cs
+System.Runtime.Serialization/ContractNamespaceAttribute.cs
+System.Runtime.Serialization/DataContractAttribute.cs
+System.Runtime.Serialization/DataContractSerializer.cs
+System.Runtime.Serialization/DataMemberAttribute.cs
+System.Runtime.Serialization/EnumMemberAttribute.cs
+System.Runtime.Serialization/ExportOptions.cs
+System.Runtime.Serialization/ExtensionDataObject.cs
+System.Runtime.Serialization/IDataContractSurrogate.cs
+System.Runtime.Serialization/IExtensibleDataObject.cs
+System.Runtime.Serialization/ImportOptions.cs
+System.Runtime.Serialization/InvalidDataContractException.cs
+System.Runtime.Serialization/KnownTypeAttribute.cs
+System.Runtime.Serialization/KnownTypeCollection.cs
+System.Runtime.Serialization/NetDataContractSerializer.cs
+System.Runtime.Serialization/SerializationMap.cs
+System.Runtime.Serialization/XmlFormatterDeserializer.cs
+System.Runtime.Serialization/XmlFormatterSerializer.cs
+System.Runtime.Serialization/XmlObjectSerializer.cs
+System.Runtime.Serialization/XmlSerializableServices.cs
+System.Runtime.Serialization/XsdDataContractExporter.cs
+System.Runtime.Serialization/XsdDataContractImporter.cs
+System.Xml/IStreamProvider.cs
+System.Xml/IXmlBinaryReaderInitializer.cs
+System.Xml/IXmlBinaryWriterInitializer.cs
+System.Xml/IXmlDictionary.cs
+System.Xml/IXmlMtomReaderInitializer.cs
+System.Xml/IXmlMtomWriterInitializer.cs
+System.Xml/IXmlUTF8ReaderInitializer.cs
+System.Xml/IXmlUTF8WriterInitializer.cs
+System.Xml/OnXmlDictionaryReaderClose.cs
+System.Xml/UniqueId.cs
+System.Xml/XmlBinaryDictionaryReader.cs
+System.Xml/XmlBinaryDictionaryWriter.cs
+System.Xml/XmlBinaryFormat.cs
+System.Xml/XmlBinaryReaderSession.cs
+System.Xml/XmlBinaryWriterSession.cs
+System.Xml/XmlC14NWriter.cs
+System.Xml/XmlCanonicalWriter.cs
+System.Xml/XmlDictionary.cs
+System.Xml/XmlDictionaryReader.cs
+System.Xml/XmlDictionaryReaderAutoGen.cs
+System.Xml/XmlDictionaryReaderQuotas.cs
+System.Xml/XmlDictionaryString.cs
+System.Xml/XmlDictionaryWriter.cs
+System.Xml/XmlDictionaryWriterAutoGen.cs
+System.Xml/XmlSimpleDictionaryReader.cs
+System.Xml/XmlSimpleDictionaryWriter.cs

+ 423 - 0
mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/ChangeLog

@@ -0,0 +1,423 @@
+2008-06-19  Noam Lampert <[email protected]>
+	
+	* KnownTypeCollection.cs: Support anyUri type
+
+2008-06-05  Noam Lampert <[email protected]>
+	
+	* KnownTypeCollection.cs: Support XmlRoot attribute
+
+2008-06-01  Noam Lampert <[email protected]>
+	
+	* KnownTypeCollection.cs: Implement byte[] serialization.
+
+2008-05-19  Noam Lampert <[email protected]>
+	
+	* KnownTypeCollection.cs: Implement char serialization.
+	   
+2008-05-19  Noam Lampert <[email protected]>
+	
+	* KnownTypeCollection.cs, XmlFormatterDeserializer.cs: Imporve support for 
+	   Nullable types in contracts.
+	   
+2008-04-29  Eyal Alaluf <[email protected]>
+
+	* KnownTypeCollection.cs: Fixed a typo in long conversion.
+
+2008-04-17  Eyal Alaluf <[email protected]>
+
+	* SerializationMap.cs: Implement partially collections deserialization.
+	  Supports arrays and types derived from IList. Needs support for calling
+	  'Add' method and for dictionaries.
+	* SerializationMap.cs XmlFormatterSerializer.cs DataContractSerializer.cs:
+	  Serialize namespaces for base members according to base class namespace.
+
+2008-04-14  Eyal Alaluf <[email protected]>
+
+	* SerializationMap.cs: Use FormatterServices.GetUninitializedObject instead
+	  of Activator.CreateInstance.
+
+2008-04-10  Eyal Alaluf <[email protected]>
+
+	* DataContractSerializer.cs: Write and register the current type namespace
+	  within the writer.
+	* XmlObjectSerializer.cs: ReadObject verifies by default.
+	* XmlFormatterSerializer.cs: Write and register XML namespaces.
+	* XmlFormatterDeserializer.cs: Refactored so Deserialize instance method can
+	  be used from SerializationMap deserialization logic recursively.
+	* SerializationMap.cs: Reimplemented main deserialization logic. Now it
+	  handles better missing entries, consumes the XmlReader until the end
+	  element and handles XML namespaces correctly.
+	  Enabled checks for required fields.
+
+2008-02-27  Eyal Alaluf <[email protected]>
+
+	* SerializationMap.cs: Fix namespace logic at least in simple case where
+	  there are several unknown elements before the current element.
+	* ContractNamespaceAttribute.cs: The ClrNamespace is not set by the ctor.
+	* XmlObjectSerializer.cs: Dispose the XmlWriter created in WriteObject
+	  to a stream.
+	* DataMemberAttribute.cs: Added the EmitDefaultValue property.
+	* XsdDataContractImporter.cs: Handle null arguments in Import methods.
+	* KnownTypeCollection.cs: Use XmlConvert.ToDateTime with roundtrip style.
+
+2007-12-05  Atsushi Enomoto  <[email protected]>
+
+	* XmlObjectSerializer.cs : some methods became virtual (in Redbits).
+	* DataContractSerializer.cs : added some overriden methods in Redbits.
+	  knownTypes can be null in .ctor().
+
+2007-08-17  Atsushi Enomoto  <[email protected]>
+
+	* SerializationMap.cs : for void it cannot be instantiated. Return
+	  null instead.
+
+2007-08-17  Atsushi Enomoto  <[email protected]>
+
+	* XmlFormatterDeserializer.cs DataContractSerializer.cs :
+	  uhoh, the semantic of bool parameter in ReadObject() has
+	  changed in the RTM. Implemented it as verifyObjectName.
+
+2007-03-27  Atsushi Enomoto  <[email protected]>
+
+	* SerializationMap.cs
+	  XmlFormatterSerializer.cs
+	  DataContractSerializer.cs :
+	  now it needs some mess to handle serialization namespaces.
+	  Collection items are serialized in its own xml namespace. Others,
+	  (including the collection member itself) is serialized in its
+	  parent xml namespace. Collection items are serialized with its
+	  wrapping element.
+	* XsdDataContractImporter.cs : use constant.
+
+2007-03-26  Atsushi Enomoto  <[email protected]>
+
+	* KnownTypeCollection.cs : added support for Guid serialization.
+
+2006-10-20  Atsushi Enomoto  <[email protected]>
+
+	* KnownTypeCollection.cs : (RemoveItem) don't remove items while 
+	  iterating.
+
+2006-09-06  Ankit Jain  <[email protected]>
+
+	* SerializationMap.cs (SerializationMap.GetSequence): Set minOccurs = 0
+
+2006-09-05  Ankit Jain  <[email protected]>
+
+	* XsdDataContractExporter.cs (XsdDataContractExporter.MSTypesSchema):
+	Load resource mstypes.schema
+	(XsdDataContractExporter.Schemas): Add MSTypesSchema by default.
+
+2006-09-05  Ankit Jain  <[email protected]>
+
+	* SerializationMap.cs (SerializationMap.AddImport): New.
+	(SerializationMap.GetSequence): Use AddImport.
+
+2006-09-04  Ankit Jain  <[email protected]>
+
+	* SerializationMap.cs (SerializationMap.GetSchemaSet): Remove.
+	(SerializationMap.GetSchemaType):
+	(SerializationMap.GetSequence):
+	(SerializationMap.GetSchema): Change XmlSchemas param to XmlSchemaSet.
+	Call XmlSchemaSet.Reprocess whenever an existing schema is modified.
+	* XsdDataContractExporter.cs (XsdDataContractExporter.Export): Update to
+	changes in SerializationMap.
+	(XsdDataContractExporter.CanExport): Implement.
+	(XsdDataContractExporter.GetSchemaType): Implement.
+	(XsdDataContractExporter.GetSchemaTypeName): Implement.
+	(XsdDataContractExporter.KnownTypes): New.
+	(XsdDataContractExporter.GeneratedTypes): New.
+
+2006-09-01  Ankit Jain  <[email protected]>
+
+	* SerializationMap.cs (SerializationMap.GetSchemaSet): New.
+	(SerializationMap.IsPrimitive): New.
+	(SerializationMap.GetSchemaType): New.
+	(SerializationMap.GetSequence): New.
+	(SerializationMap.GetMembers): New.
+	(SerializationMap.GetSchemaElement): New.
+	(SerializationMap.GetSchema): New.
+	(SerializationMap.GetQualifiedName): New.
+	New methods for exporting schema for the type.
+
+	(SharedContractMap.ctor): Move code for building Members list to ..
+	(SharedContractMap.GetMembers): .. here.
+
+	(CollectionTypeMap.Serialize): Mark 'override'.
+	(CollectionTypeMap.GetMembers): 'override' and throw
+	NotImplementedException.
+	(CollectionTypeMap.GetSchemaType): Implement.
+
+	(SharedTypeMap..ctor): Move code to ..
+	(SharedTypeMap.GetMembers): .. here.
+	(EnumMap.GetSchemaType): Implement.
+
+	* XsdDataContractExporter.cs (XsdDataContractExporter.Export):
+	Implement.
+	* KnownTypeCollection.cs (KnownTypeCollection.GetCollectionQName): Use
+	GetQName instead of GetXmlName. Set Namespace for collections of
+	primitive types to MSArraysNamespace
+
+2006-08-31  Ankit Jain  <[email protected]>
+
+	* SerializationMap.cs (EnumMap): New. For de/serializing enums.
+	(EnumMemberInfo): New.
+	(SerializationMap.DeserializeContent): Made protected virtual from private.
+	* DataContractSerializer.cs (WriteStartObject):
+	Ensure that "i:type" is not emitted for enums.
+	* KnownTypeCollection.cs (GetPrimitiveTypeName): Don't treat enum as a
+	primitive type.
+	(GetQName): Likewise. Use GetEnumQName for enums.
+	(GetEnumQName): New.
+	(IsPrimitiveNotEnum): New.
+	(TryRegister): Add support for enums.
+	(RegisterEnum): New.
+
+2006-08-14  Atsushi Enomoto  <[email protected]>
+
+	* XmlFormatterSerializer.cs : (contd from my previous change)
+	  ... and don't complain at WriteObject(). It is somehow required
+	  in S.SM.D.WSTrustContract (soon to be committed).
+
+2006-07-27  Ankit Jain  <[email protected]>
+
+	* XsdDataContractImporter.cs (Compile): Remove, thanks to eno
+	XmlSchemaSet.Compile () works now.
+	Update to directly use XmlSchemaSet.Compile ()
+
+2006-07-27  Ankit Jain  <[email protected]>
+
+	* XsdDataContractImporter.cs (ImportInternal): New.
+	Update various overloads of Import to use this.
+	(ImportFromTypeMapping): New. Emits code for a DataContract from a
+	XmlTypeMapping. Code is duplicate of
+	ServiceContractGenerator.ExportDataContract .
+	(GetNamespace): New. Duplicate like above.
+	(Compile): New. Temporary hack, will XmlSchemaSet.Compile is not
+	working.
+
+2006-07-18  Atsushi Enomoto  <[email protected]>
+
+	* XmlFormatterSerializer.cs, KnownTypeCollection.cs :
+	  don't raise an error at DataContractSerializer..ctor(). Raise
+	  InvalidDataContractException on WriteObject().
+
+2006-07-12  Ankit Jain  <[email protected]>
+
+	* SerializationMap.cs (XmlSerializableMap): New. Map for classes which
+	implement IXmlSerializable interface.
+	* KnownTypeCollection.cs (KnownTypeCollection.GetQName): Add support for
+	types which implement IXmlSerializable interface. Change the order in
+	which DataContractAttribute/IXmlSerializable/SerializableAttribute get
+	selected.
+	(KnownTypeCollection.TryRegister): Change the order like above.
+	(KnownTypeCollection.RegisterIXmlSerializable): New.
+
+2006-07-04  Atsushi Enomoto  <[email protected]>
+
+	* XsdDataContractExporter.cs, XmlObjectSerializer.cs,
+	  InvalidDataContractException.cs : some June CTP updates.
+
+2006-07-04  Atsushi Enomoto  <[email protected]>
+
+	* IDataContractSurrogate.cs, ExportOptions.cs,
+	  DataContractSerializer.cs, KnownTypeCollection.cs :
+	  June CTP updates.
+
+2006-05-09  Atsushi Enomoto  <[email protected]>
+
+	* DataContractSerializer.cs : null knownTypes argument is allowed.
+	* KnownTypeCollection.cs : Type.Namespace could be null.
+
+2006-05-09  Atsushi Enomoto  <[email protected]>
+
+	* KnownTypeCollection.cs : for nested classes, treat localName of
+	  the QName as "Parent.Child", not "Child".
+	  Don't encode name here (to pass ".").
+
+2006-05-09  Atsushi Enomoto  <[email protected]>
+
+	* DataContractSerializer.cs :
+	  Added maxObjectsInGraph range check.
+	  interface type has BaseType as null, so end base type check when
+	  it is null (I don't think this check is required btw).
+
+2006-04-05  Atsushi Enomoto  <[email protected]>
+
+	* DataContractSerializer.cs : xmlns:xsi is not written when the
+	  target type is string.
+
+2006-03-22  Ankit Jain  <[email protected]>
+
+	* SerializationMap.cs (CheckDataContractEqual): Remove.
+	(Deserialize): Allows expected type to be a derived one from actual
+	type.
+	(DeserializeInternal): Handle DataMember of type 'object'.
+	* XmlFormatterSerializer.cs (SerializeNonPrimitive): Serialize types not
+	already known.
+	* DataContractSerializer.cs (.ctor): Use KnownTypeCollection.GetQName
+	instead of doing it manually.
+	(PopulateTypes): Change return type from KnownTypeCollection to void.
+	Scan the base types to ensure that all have DataContract or Serializable
+	attributes.
+	Add all (including inherited) KnownTypeAttribute values to the
+	collection.
+
+2006-03-18  Ankit Jain  <[email protected]>
+
+	* SerializationMap.cs (SerializationMap.GetEmptyInstance): Rename to ..
+	(SerializationMap.GetInstance): .. this. Gets the instance or null if nil=true.
+	(SerializationMap.DeserializeInternal): New. Renamed from .. 
+	(SerializationMap.Deserialize): .. this. Check DataContract equivalence, and use new
+	DeserializeInternal for rest of the work.
+	(DeserializeContent): Cleanup and handle various "null" cases.
+	* XmlFormatterSerializer.cs (Write_i_type): New. Write i:type=".."
+	(SerializeNonPrimitive): Update to use Write_i_type.
+	* DataContractSerializer.cs (WriteStartObject): Add rootType to known_types.
+
+2006-03-16  Ankit Jain  <[email protected]>
+
+	* SerializationMap.cs (SerializationMap.Deserialize): Use NameTable.Get
+	before reader.LookupNamespace.
+	(DataMemberInfo.Compare): Use String.CompareOrdinal instead of
+	String.Compare.
+
+2006-03-16  Ankit Jain  <[email protected]>
+
+	* SerializationMap.cs (SerializationMap.GetEmptyInstance): New.
+	(SerializationMap.Deserialize): Refactor, handle primitive types and nils.
+	(SerializationMap.DeserializeContent): Handle nils and nested DataContracts.
+	(SharedContractMap.ctor): Include inherited properties and fields, in
+	the correct order.
+
+2006-03-15  Ankit Jain  <[email protected]>
+
+	* KnownTypeCollection.cs (IsPrimitiveType): New.
+	* SerializationMap.cs (Deserialize): Handle primitive types.
+
+2006-03-15  Ankit Jain  <[email protected]>
+
+	* DataContractSerializer.cs (WriteObjectContent): Handle null.
+	(WriteStartObject): Rewritten.
+	* KnownTypeCollection.cs (GetQName): New. Return QName for a given type.	
+	(GetContractQName):
+	(GetSerializableQName):
+	(GetCollectionQName): New.
+	(RegisterContract):
+	(RegisterSerializable):
+	(RegisterCollection): Update to use new Get* methods.
+	* SerializationMap.cs (CheckDataContractEqual): New.
+	(Deserialize): Split into this and ..
+	(DeserializeContent): .. this.
+	* XmlDictionaryWriter.cs (CreateTextWriter): Use UTF8Encoding.
+
+2006-03-09  Atsushi Enomoto  <[email protected]>
+
+	* DataContractSerializer.cs : xmlns output should be done at
+	  WriteStartObject().
+
+2006-03-08  Ankit Jain  <[email protected]>
+
+	* DataContractSerializer.cs (.ctor): Use name & namespace specified (if any) 
+	with the DataContractAttribute for non-primitive types.
+	(DataContractSerializer.WriteStartObject): DataContractAttribute.Name
+	cannot be "".
+
+2006-03-03  Atsushi Enomoto  <[email protected]>
+
+	* DataContractSerializer.cs : Handle primitive type name rather than
+	  raw type name in constructors that don't receive root QName.
+	  In case the actual graph is not of root type, write xsi:type.
+
+2006-03-02  Atsushi Enomoto  <[email protected]>
+
+	* KnownTypeCollection.cs : default namespace contains common MS base
+	  URI fragment.
+	* XmlObjectSerializer.cs : added internal common utility field.
+	* DataContractSerializer.cs : Fixed constructors to fill fields and
+	  make it work.
+	* NetDataContractSerializer.cs : just leave it unimplemented until
+	  we find how it works. It looks different from what
+	  DataContractSerializer does.
+
+2006-01-17  Atsushi Enomoto  <[email protected]>
+
+	* XmlFormatter.cs : extra namespaces are not written in Dec.CTP.
+
+2005-11-28  Atsushi Enomoto  <[email protected]>
+
+	* KnownTypeCollection.cs : override.
+
+2005-11-02  Atsushi Enomoto  <[email protected]>
+
+	* SerializationMap.cs, XmlFormatterSerializer.cs, XmlFormatter.cs
+	  XmlFormatterDeserializer.cs, KnownTypeCollection.cs :
+	  several changes. Partial support for collection serialization.
+	  SerializationMap now contains its own Deserialize()/Serialize()
+	  methods.
+
+2005-10-20  Atsushi Enomoto  <[email protected]>
+
+	* XmlFormatterDeserializer.cs : new file.
+	* SerializationMap.cs, XmlFormatter.cs, KnownTypeCollection.cs :
+	  several changes for pretty primitive Deserialize() implementation.
+
+2005-10-07  Atsushi Enomoto  <[email protected]>
+
+	Added hacky serialization feature. Actually it should be rewritten to
+	be based on IDataContractSurrogate.
+	* SerializationMap.cs, XmlFormatterSerializer.cs :
+	  new files for Serialize() implementation.
+	* KnownTypeCollection.cs : use serialization maps to check contracts.
+	* XmlFormatter.cs : implemented hacky Serialize().
+	* DataMemberAttribute.cs : default Order is -1.
+	* DataContractAttribute.cs : added tiny comment.
+
+2005-10-03  Atsushi Enomoto  <[email protected]>
+
+	* XmlFormatter.cs : Added implementation switch between
+	  BinaryFormatter and internal DataContractFormatter.
+	* XmlSerializableServices.cs : WriteNodes() impl.
+
+2005-10-03  Atsushi Enomoto  <[email protected]>
+
+	* XmlSerializableServices.cs : ReadNodes() impl.
+
+2005-09-28  Atsushi Enomoto  <[email protected]>
+
+	* KnownTypeAttribute.cs : fixed attribute usage.
+
+2005-09-22  Atsushi Enomoto  <[email protected]>
+
+	* IDataContractSurrogate.cs, ContractNamespaceAttribute.cs,
+	  XsdDataContractExporter.cs, KnownTypeAttribute.cs,
+	  SerializationMode.cs, XmlFormatter.cs, DataMemberAttribute.cs,
+	  ImportOptions.cs, UnknownSerializationData.cs,
+	  SerializationFactoryMethodAttribute.cs, XmlSerializableServices.cs,
+	  DataContractAttribute.cs, ExportOptions.cs,
+	  InvalidDataContractException.cs, IUnknownSerializationData.cs,
+	  CollectionDataContractAttribute.cs, XsdDataContractImporter.cs,
+	  KnownTypeCollection.cs :
+	  #if NET_2_0. coding style was updated.
+
+2005-09-22  Atsushi Enomoto  <[email protected]>
+
+	* CollectionDataContractAttribute.cs
+	  ContractNamespaceAttribute.cs
+	  DataContractAttribute.cs
+	  DataMemberAttribute.cs
+	  ExportOptions.cs
+	  IDataContractSurrogate.cs
+	  InvalidDataContractException.cs
+	  IUnknownSerializationData.cs
+	  ImportOptions.cs
+	  KnownTypeAttribute.cs
+	  KnownTypeCollection.cs
+	  SerializationFactoryMethodAttribute.cs
+	  SerializationMode.cs
+	  UnknownSerializationData.cs
+	  XmlFormatter.cs
+	  XmlSerializableServices.cs
+	  XsdDataContractExporter.cs
+	  XsdDataContractImporter.cs : new files.
+

+ 69 - 0
mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/CollectionDataContractAttribute.cs

@@ -0,0 +1,69 @@
+//
+// CollectionDataContractAttribute.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+using System;
+
+namespace System.Runtime.Serialization
+{
+	[AttributeUsage (AttributeTargets.Class | AttributeTargets.Struct, 
+		Inherited = false, AllowMultiple = false)]
+	public sealed class CollectionDataContractAttribute : Attribute
+	{
+		string name, ns, item_name, key_name, value_name;
+
+		public CollectionDataContractAttribute ()
+		{
+		}
+
+		public string Name {
+			get { return name; }
+			set { name = value; }
+		}
+
+		public string Namespace {
+			get { return ns; }
+			set { ns = value; }
+		}
+
+		public string ItemName {
+			get { return item_name; }
+			set { item_name = value; }
+		}
+
+		public string KeyName {
+			get { return key_name; }
+			set { key_name = value; }
+		}
+
+		public string ValueName {
+			get { return value_name; }
+			set { value_name = value; }
+		}
+	}
+}
+#endif

+ 54 - 0
mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/ContractNamespaceAttribute.cs

@@ -0,0 +1,54 @@
+//
+// ContractNamespaceAttribute.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+using System;
+
+namespace System.Runtime.Serialization
+{
+	[AttributeUsage (AttributeTargets.Assembly | AttributeTargets.Module,
+		Inherited = false, AllowMultiple = true)]
+	public sealed class ContractNamespaceAttribute : Attribute
+	{
+		string clr_ns, contract_ns;
+
+		public ContractNamespaceAttribute (string ns)
+		{
+			contract_ns = ns;
+		}
+
+		public string ClrNamespace {
+			get { return clr_ns; }
+			set { clr_ns = value; }
+		}
+
+		public string ContractNamespace {
+			get { return contract_ns; }
+		}
+	}
+}
+#endif

+ 56 - 0
mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/DataContractAttribute.cs

@@ -0,0 +1,56 @@
+//
+// DataContractAttribute.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+using System;
+
+namespace System.Runtime.Serialization
+{
+	[AttributeUsage (AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum, 
+		Inherited = false, AllowMultiple = false)]
+	public sealed class DataContractAttribute : Attribute
+	{
+		string name, ns;
+
+		public DataContractAttribute ()
+		{
+		}
+
+		public string Name {
+			get { return name; }
+			set { name = value; }
+		}
+
+		// the default namespace for XmlFormatter (with SharedSchema) is
+		// http://schemas.datacontract.org/2004/07/ .
+		public string Namespace {
+			get { return ns; }
+			set { ns = value; }
+		}
+	}
+}
+#endif

+ 408 - 0
mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/DataContractSerializer.cs

@@ -0,0 +1,408 @@
+//
+// DataContractSerializer.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//
+// Copyright (C) 2005-2007 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.IO;
+using System.Reflection;
+using System.Runtime.Serialization.Formatters.Binary;
+using System.Xml;
+using System.Xml.Schema;
+
+using QName = System.Xml.XmlQualifiedName;
+
+namespace System.Runtime.Serialization
+{
+	public sealed class DataContractSerializer : XmlObjectSerializer
+	{
+		const string xmlns = "http://www.w3.org/2000/xmlns/";
+
+		Type type;
+		bool ignore_ext, preserve_refs;
+
+		// This is only for compatible mode.
+		StreamingContext context;
+		ReadOnlyCollection<Type> known_runtime_types;
+		KnownTypeCollection known_types;
+		IDataContractSurrogate surrogate;
+
+		int max_items = 0x10000; // FIXME: could be from config.
+
+		XmlDictionaryString root_name, root_ns;
+
+		public DataContractSerializer (Type type)
+			: this (type, Type.EmptyTypes)
+		{
+			// nothing to do here.
+		}
+
+		public DataContractSerializer (Type type,
+			IEnumerable<Type> knownTypes)
+		{
+			if (type == null)
+				throw new ArgumentNullException ("type");
+			this.type = type;
+			known_types = new KnownTypeCollection ();
+			QName qname = known_types.GetQName (type);
+
+			FillDictionaryString (qname.Name, qname.Namespace);
+			
+			PopulateTypes (knownTypes);
+		}
+
+		public DataContractSerializer (Type type, string rootName,
+			string rootNamespace)
+			: this (type, rootName, rootNamespace, Type.EmptyTypes)
+		{
+			// nothing to do here.
+		}
+
+		public DataContractSerializer (Type type,
+			XmlDictionaryString rootName,
+			XmlDictionaryString rootNamespace)
+			: this (type, rootName, rootNamespace, Type.EmptyTypes)
+		{
+			// nothing to do here.
+		}
+
+		public DataContractSerializer (Type type, string rootName,
+			string rootNamespace, IEnumerable<Type> knownTypes)
+		{
+			if (type == null)
+				throw new ArgumentNullException ("type");
+			if (rootName == null)
+				throw new ArgumentNullException ("rootName");
+			if (rootNamespace == null)
+				throw new ArgumentNullException ("rootNamespace");
+			this.type = type;
+			PopulateTypes (knownTypes);
+			FillDictionaryString (rootName, rootNamespace);
+		}
+
+		public DataContractSerializer (Type type,
+			XmlDictionaryString rootName,
+			XmlDictionaryString rootNamespace,
+			IEnumerable<Type> knownTypes)
+		{
+			if (type == null)
+				throw new ArgumentNullException ("type");
+			if (rootName == null)
+				throw new ArgumentNullException ("rootName");
+			if (rootNamespace == null)
+				throw new ArgumentNullException ("rootNamespace");
+			this.type = type;
+			PopulateTypes (knownTypes);
+			root_name = rootName;
+			root_ns = rootNamespace;
+		}
+
+		public DataContractSerializer (Type type,
+			IEnumerable<Type> knownTypes,
+			int maxObjectsInGraph,
+			bool ignoreExtensionDataObject,
+			bool preserveObjectReferences,
+			IDataContractSurrogate dataContractSurrogate)
+			: this (type, knownTypes)
+		{
+			Initialize (maxObjectsInGraph,
+				ignoreExtensionDataObject,
+				preserveObjectReferences,
+				dataContractSurrogate);
+		}
+
+		public DataContractSerializer (Type type,
+			string rootName,
+			string rootNamespace,
+			IEnumerable<Type> knownTypes,
+			int maxObjectsInGraph,
+			bool ignoreExtensionDataObject,
+			bool preserveObjectReferences,
+			IDataContractSurrogate dataContractSurrogate)
+			: this (type, rootName, rootNamespace, knownTypes)
+		{
+			Initialize (maxObjectsInGraph,
+				ignoreExtensionDataObject,
+				preserveObjectReferences,
+				dataContractSurrogate);
+		}
+
+		public DataContractSerializer (Type type,
+			XmlDictionaryString rootName,
+			XmlDictionaryString rootNamespace,
+			IEnumerable<Type> knownTypes,
+			int maxObjectsInGraph,
+			bool ignoreExtensionDataObject,
+			bool preserveObjectReferences,
+			IDataContractSurrogate dataContractSurrogate)
+			: this (type, rootName, rootNamespace, knownTypes)
+		{
+			Initialize (maxObjectsInGraph,
+				ignoreExtensionDataObject,
+				preserveObjectReferences,
+				dataContractSurrogate);
+		}
+
+		void PopulateTypes (IEnumerable<Type> knownTypes)
+		{
+			if (known_types == null)
+				known_types= new KnownTypeCollection ();
+
+			// Ensure that everyone in the heirarchy has a DataContract/Serializable
+			// FIXME: Use TryRegister (w/o actual registration) for this?
+			//
+			// Hmm, why do we need this check? .NET does not do this check.
+			Type baseType = type;
+			while (baseType != null && baseType != typeof (object)) {
+				known_types.GetQName (baseType);
+				baseType = baseType.BaseType;
+			}
+
+			if (knownTypes != null) {
+				foreach (Type t in knownTypes)
+					known_types.TryRegister (t);
+			}
+
+			Type elementType = type;
+			if (type.HasElementType)
+				elementType = type.GetElementType ();
+
+			/* Get all KnownTypeAttribute-s, including inherited ones */
+			object [] attrs = elementType.GetCustomAttributes (typeof (KnownTypeAttribute), true);
+			for (int i = 0; i < attrs.Length; i ++) {
+				KnownTypeAttribute kt = (KnownTypeAttribute) attrs [i];
+				known_types.TryRegister (kt.Type);
+			}
+		}
+
+		void FillDictionaryString (string name, string ns)
+		{
+			XmlDictionary d = new XmlDictionary ();
+			root_name = d.Add (name);
+			root_ns = d.Add (ns);
+		}
+
+		void Initialize (
+			int maxObjectsInGraph,
+			bool ignoreExtensionDataObject,
+			bool preserveObjectReferences,
+			IDataContractSurrogate dataContractSurrogate)
+		{
+			if (maxObjectsInGraph < 0)
+				throw new ArgumentOutOfRangeException ("maxObjectsInGraph must not be negative.");
+			max_items = maxObjectsInGraph;
+			ignore_ext = ignoreExtensionDataObject;
+			preserve_refs = preserveObjectReferences;
+			surrogate = dataContractSurrogate;
+
+			PopulateTypes (Type.EmptyTypes);
+		}
+
+		public bool IgnoreExtensionDataObject {
+			get { return ignore_ext; }
+		}
+
+		public ReadOnlyCollection<Type> KnownTypes {
+			get { return known_runtime_types; }
+		}
+
+		public IDataContractSurrogate DataContractSurrogate {
+			get { return surrogate; }
+		}
+
+		public int MaxItemsInObjectGraph {
+			get { return max_items; }
+		}
+
+		public bool PreserveObjectReferences {
+			get { return preserve_refs; }
+		}
+
+		[MonoTODO]
+		public override bool IsStartObject (XmlDictionaryReader reader)
+		{
+			throw new NotImplementedException ();
+		}
+
+		// SP1
+		public override bool IsStartObject (XmlReader reader)
+		{
+			return IsStartObject (XmlDictionaryReader.CreateDictionaryReader (reader));
+		}
+
+		// SP1
+		public override object ReadObject (XmlReader reader)
+		{
+			return ReadObject (XmlDictionaryReader.CreateDictionaryReader (reader));
+		}
+
+		[MonoTODO]
+		public override object ReadObject (XmlDictionaryReader reader, bool verifyObjectName)
+		{
+			int startTypeCount = known_types.Count;
+			known_types.Add (type);
+
+			bool isEmpty = reader.IsEmptyElement;
+
+			object ret = XmlFormatterDeserializer.Deserialize (reader, type,
+				known_types, surrogate, root_name.Value, root_ns.Value, verifyObjectName);
+
+			// remove temporarily-added known types for
+			// rootType and object graph type.
+			while (known_types.Count > startTypeCount)
+				known_types.RemoveAt (startTypeCount);
+
+			return ret;
+		}
+
+		private void ReadRootStartElement (XmlReader reader, Type type)
+ 		{
+			SerializationMap map =
+				known_types.FindUserMap (type);
+			QName name = map != null ? map.XmlName :
+				KnownTypeCollection.GetPredefinedTypeName (type);
+			reader.MoveToContent ();
+			reader.ReadStartElement (name.Name, name.Namespace);
+			// FIXME: could there be any attributes to handle here?
+			reader.Read ();
+		}
+
+		// SP1
+		public override void WriteObject (XmlWriter writer, object graph)
+		{
+			XmlDictionaryWriter w = XmlDictionaryWriter.CreateDictionaryWriter (writer);
+			WriteObject (w, graph);
+		}
+
+		[MonoTODO ("support arrays; support Serializable; support SharedType; use DataContractSurrogate")]
+		/*
+			when writeContentOnly is true, then the input XmlWriter
+			must be at element state. This is to write possible
+			xsi:nil.
+
+			rootType determines the top-level element QName (thus
+			it is ignored when writeContentOnly is true).
+
+			preserveObjectReferences indicates that whether the
+			output should contain ms:Id or not.
+			(http://schemas.microsoft.com/2003/10/Serialization/)
+		*/
+		public override void WriteObjectContent (XmlDictionaryWriter writer, object graph)
+		{
+			if (graph == null)
+				return;
+
+			int startTypeCount = known_types.Count;
+
+			XmlFormatterSerializer.Serialize (writer, graph,
+				known_types,
+				ignore_ext, max_items, root_ns.Value);
+
+			// remove temporarily-added known types for
+			// rootType and object graph type.
+			while (known_types.Count > startTypeCount)
+				known_types.RemoveAt (startTypeCount);
+		}
+
+		// SP1
+		public override void WriteStartObject (
+			XmlWriter writer, object graph)
+		{
+			WriteStartObject (XmlDictionaryWriter.CreateDictionaryWriter (writer), graph);
+		}
+
+		public override void WriteStartObject (
+			XmlDictionaryWriter writer, object graph)
+		{
+			Type rootType = type;
+			
+			if (root_name.Value == "")
+				throw new InvalidDataContractException ("Type '" + type.ToString () +
+					"' cannot have a DataContract attribute Name set to null or empty string.");
+
+
+			if (graph == null) {
+				writer.WriteStartElement (root_name.Value, root_ns.Value);
+				writer.WriteAttributeString ("i", "nil", XmlSchema.InstanceNamespace, "true");
+				writer.WriteAttributeString ("xmlns", xmlns, root_ns.Value);
+
+				return;
+			}
+
+			QName instName = null;
+			QName root_qname = known_types.GetQName (rootType);
+			QName graph_qname = known_types.GetQName (graph.GetType ());
+
+			known_types.Add (graph.GetType ());
+
+			writer.WriteStartElement (root_name.Value, root_ns.Value);
+			if (root_ns.Value != root_qname.Namespace)
+				if (root_qname.Namespace != KnownTypeCollection.MSSimpleNamespace)
+					writer.WriteXmlnsAttribute (null, root_qname.Namespace);
+
+			if (root_qname == graph_qname) {
+				if (root_qname.Namespace != KnownTypeCollection.MSSimpleNamespace &&
+					!rootType.IsEnum)
+					//FIXME: Hack, when should the "i:type" be written?
+					//Not used in case of enums
+					writer.WriteXmlnsAttribute ("i", XmlSchema.InstanceNamespace);
+
+				return;
+			}
+
+			/* Different names */
+			known_types.Add (rootType);
+			
+			instName = KnownTypeCollection.GetPredefinedTypeName (graph.GetType ());
+			if (instName == QName.Empty)
+				/* Not a primitive type */
+				instName = graph_qname;
+			else
+				/* FIXME: Hack, .. see test WriteObject7 () */
+				instName = new QName (instName.Name, XmlSchema.Namespace);
+
+			// output xsi:type as rootType is not equivalent to the graph's type.
+			writer.WriteStartAttribute ("i", "type", XmlSchema.InstanceNamespace);
+			writer.WriteQualifiedName (instName.Name, instName.Namespace);
+			writer.WriteEndAttribute ();
+		}
+
+		public override void WriteEndObject (XmlDictionaryWriter writer)
+		{
+			writer.WriteEndElement ();
+		}
+
+		// SP1
+		public override void WriteEndObject (XmlWriter writer)
+		{
+			WriteEndObject (XmlDictionaryWriter.CreateDictionaryWriter (writer));
+		}
+	}
+}
+#endif

+ 67 - 0
mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/DataMemberAttribute.cs

@@ -0,0 +1,67 @@
+//
+// DataMemberAttribute.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+using System;
+
+namespace System.Runtime.Serialization
+{
+	[AttributeUsage (AttributeTargets.Property | AttributeTargets.Field,
+		Inherited = false, AllowMultiple = false)]
+	public sealed class DataMemberAttribute : Attribute
+	{
+		bool is_required;
+		bool emit_default = true;
+		string name;
+		int order = -1;
+
+		public DataMemberAttribute ()
+		{
+		}
+
+		public bool EmitDefaultValue {
+			get { return emit_default; }
+			set { emit_default = value; }
+		}
+
+		public bool IsRequired {
+			get { return is_required; }
+			set { is_required = value; }
+		}
+
+		public string Name {
+			get { return name; }
+			set { name = value; }
+		}
+
+		public int Order {
+			get { return order; }
+			set { order = value; }
+		}
+	}
+}
+#endif

+ 49 - 0
mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/EnumMemberAttribute.cs

@@ -0,0 +1,49 @@
+//
+// EnumMemberAttribute.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+using System;
+
+namespace System.Runtime.Serialization
+{
+	[AttributeUsage (AttributeTargets.Field,
+		Inherited = false, AllowMultiple = false)]
+	public sealed class EnumMemberAttribute : Attribute
+	{
+		string value;
+
+		public EnumMemberAttribute ()
+		{
+		}
+
+		public string Value {
+			get { return value; }
+			set { this.value = value; }
+		}
+	}
+}
+#endif

+ 52 - 0
mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/ExportOptions.cs

@@ -0,0 +1,52 @@
+//
+// ExportOptions.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+using System.Collections.ObjectModel;
+
+namespace System.Runtime.Serialization
+{
+	public class ExportOptions
+	{
+		IDataContractSurrogate surrogate;
+		KnownTypeCollection known_types;
+
+		public ExportOptions ()
+		{
+		}
+
+		public IDataContractSurrogate DataContractSurrogate {
+			get { return surrogate; }
+			set { surrogate = value; }
+		}
+
+		public Collection<Type> KnownTypes {
+			get { return known_types; }
+		}
+	}
+}
+#endif

+ 44 - 0
mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/ExtensionDataObject.cs

@@ -0,0 +1,44 @@
+//
+// ExtensionDataObject.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+using System;
+using System.Collections.ObjectModel;
+
+namespace System.Runtime.Serialization
+{
+	public sealed class ExtensionDataObject
+	{
+		object target;
+
+		internal ExtensionDataObject (object target)
+		{
+			this.target = target;
+		}
+	}
+}
+#endif

+ 60 - 0
mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/IDataContractSurrogate.cs

@@ -0,0 +1,60 @@
+//
+// IDataContractSurrogate.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+using System;
+using System.CodeDom;
+using System.Collections.ObjectModel;
+using System.Reflection;
+
+namespace System.Runtime.Serialization
+{
+	public interface IDataContractSurrogate
+	{
+		object GetCustomDataToExport (MemberInfo memberInfo,
+			Type dataContractType);
+		object GetCustomDataToExport (Type clrType,
+			Type dataContractType);
+
+		Type GetDataContractType (Type type);
+
+		object GetDeserializedObject (object obj, Type targetType);
+
+		void GetKnownCustomDataTypes (Collection<Type> customDataTypes);
+
+		object GetObjectToSerialize (object obj, Type targetType);
+
+		Type GetReferencedTypeOnImport (string typeName,
+			string typeNamespace, object customData);
+
+		CodeTypeDeclaration ProcessImportedType (
+			CodeTypeDeclaration typeDeclaration,
+			CodeCompileUnit compileUnit);
+
+	}
+}
+#endif

+ 36 - 0
mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/IExtensibleDataObject.cs

@@ -0,0 +1,36 @@
+//
+// IExtensibleDataObject.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+namespace System.Runtime.Serialization
+{
+	public interface IExtensibleDataObject
+	{
+		ExtensionDataObject ExtensionData { get; set; }
+	}
+}
+#endif

+ 97 - 0
mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/ImportOptions.cs

@@ -0,0 +1,97 @@
+//
+// ImportOptions.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+
+using System.CodeDom.Compiler;
+using System.Collections.Generic;
+
+namespace System.Runtime.Serialization
+{
+	public class ImportOptions
+	{
+		IDataContractSurrogate surrogate;
+		ICollection<Type> referenced_collection_types =
+			new List<Type> ();
+		ICollection<Type> referenced_types = new List<Type> ();
+		bool enable_data_binding;
+		bool generate_internal;
+		bool generate_serializable;
+		bool import_xml_type;
+		IDictionary<string, string> namespaces =
+			new Dictionary<string, string> ();
+		CodeDomProvider code_provider;
+
+		public ImportOptions ()
+		{
+		}
+
+		public CodeDomProvider CodeProvider {
+			get { return code_provider; }
+			set { code_provider = value; }
+		}
+
+		public IDataContractSurrogate DataContractSurrogate {
+			get { return surrogate; }
+			set { surrogate = value; }
+		}
+
+		public bool EnableDataBinding {
+			get { return enable_data_binding; }
+			set { enable_data_binding = value; }
+		}
+
+		public bool GenerateInternal {
+			get { return generate_internal; }
+			set { generate_internal = value; }
+		}
+
+		public bool GenerateSerializable {
+			get { return generate_serializable; }
+			set { generate_serializable = value; }
+		}
+
+		public bool ImportXmlType {
+			get { return import_xml_type; }
+			set { import_xml_type = value; }
+		}
+
+		public IDictionary<string, string> Namespaces {
+			get { return namespaces; }
+		}
+
+		public ICollection<Type> ReferencedCollectionTypes {
+			get { return referenced_collection_types; }
+		}
+
+		public ICollection<Type> ReferencedTypes {
+			get { return referenced_types; }
+		}
+	}
+}
+
+#endif

+ 59 - 0
mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/InvalidDataContractException.cs

@@ -0,0 +1,59 @@
+//
+// InvalidDataContractException.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+using System;
+using System.Xml;
+
+namespace System.Runtime.Serialization
+{
+	[Serializable]
+	public class InvalidDataContractException : Exception
+	{
+		public InvalidDataContractException ()
+			: base ()
+		{
+		}
+
+		public InvalidDataContractException (string message)
+			: base (message)
+		{
+		}
+
+		protected InvalidDataContractException (SerializationInfo info,
+			StreamingContext context)
+			: base (info, context)
+		{
+		}
+
+		public InvalidDataContractException (string message, Exception innerException)
+			: base (message, innerException)
+		{
+		}
+	}
+}
+#endif

+ 59 - 0
mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/KnownTypeAttribute.cs

@@ -0,0 +1,59 @@
+//
+// KnownTypeAttribute.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+using System;
+
+namespace System.Runtime.Serialization
+{
+	[AttributeUsage (AttributeTargets.Class | AttributeTargets.Struct,
+		Inherited = true, AllowMultiple = true)]
+	public sealed class KnownTypeAttribute : Attribute
+	{
+		string method_name;
+		Type type;
+
+		public KnownTypeAttribute (string methodName)
+		{
+			method_name = methodName;
+		}
+
+		public KnownTypeAttribute (Type type)
+		{
+			this.type = type;
+		}
+
+		public string MethodName {
+			get { return method_name; }
+		}
+
+		public Type Type {
+			get { return type; }
+		}
+	}
+}
+#endif

+ 659 - 0
mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/KnownTypeCollection.cs

@@ -0,0 +1,659 @@
+//
+// KnownTypeCollection.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Reflection;
+using System.Xml;
+using System.Xml.Schema;
+
+using QName = System.Xml.XmlQualifiedName;
+using System.Xml.Serialization;
+
+namespace System.Runtime.Serialization
+{
+/*
+	XmlFormatter implementation design inference:
+
+	type definitions:
+	- No XML Schema types are directly used. There are some maps from
+	  xs:blahType to ms:blahType where the namespaceURI for prefix "ms" is
+	  "http://schemas.microsoft.com/2003/10/Serialization/" .
+
+	serializable types:
+	- An object being serialized 1) must be of type System.Object, or
+	  2) must be null, or 3) must have either a [DataContract] attribute
+	  or a [Serializable] attribute to be serializable.
+	- When the object is either of type System.Object or null, then the
+	  XML type is "anyType".
+	- When the object is [Serializable], then the runtime-serialization
+	  compatible object graph is written.
+	- Otherwise the serialization is based on contract attributes.
+	  ([Serializable] takes precedence).
+
+	type derivation:
+	- For type A to be serializable, the base type B of A must be
+	  serializable.
+	- If a type which is [Serializable] and whose base type has a
+	  [DataContract], then for base type members [DataContract] is taken.
+	- It is vice versa i.e. if the base type is [Serializable] and the
+	  derived type has a [DataContract], then [Serializable] takes place
+	  for base members.
+
+	known type collection:
+	- It internally manages mapping store keyed by contract QNames.
+	  KnownTypeCollection.Add() checks if the same QName contract already
+	  exists (and raises InvalidOperationException if required).
+
+*/
+	internal sealed class KnownTypeCollection : Collection<Type>
+	{
+		internal const string MSSimpleNamespace =
+			"http://schemas.microsoft.com/2003/10/Serialization/";
+		internal const string MSArraysNamespace =
+			"http://schemas.microsoft.com/2003/10/Serialization/Arrays";
+
+		static QName any_type, bool_type,
+			byte_type, date_type, decimal_type, double_type,
+			float_type, string_type,
+			short_type, int_type, long_type,
+			ubyte_type, ushort_type, uint_type, ulong_type,
+			// non-TypeCode
+			any_uri_type, base64_type, duration_type, qname_type,
+			// custom in ms nsURI schema
+			char_type, guid_type,
+			// not in ms nsURI schema
+			dbnull_type;
+
+		static KnownTypeCollection ()
+		{
+			//any_type, bool_type,	byte_type, date_type, decimal_type, double_type,	float_type, string_type,
+			// short_type, int_type, long_type, 	ubyte_type, ushort_type, uint_type, ulong_type,
+			// 	any_uri_type, base64_type, duration_type, qname_type,
+			// 	char_type, guid_type,	dbnull_type;
+			string s = MSSimpleNamespace;
+			any_type = new QName ("anyType", s);
+			any_uri_type = new QName ("anyURI", s);
+			bool_type = new QName ("boolean", s);
+			base64_type = new QName ("base64Binary", s);
+			date_type = new QName ("dateTime", s);
+			duration_type = new QName ("duration", s);
+			qname_type = new QName ("QName", s);
+			decimal_type = new QName ("decimal", s);
+			double_type = new QName ("double", s);
+			float_type = new QName ("float", s);
+			byte_type = new QName ("byte", s);
+			short_type = new QName ("short", s);
+			int_type = new QName ("int", s);
+			long_type = new QName ("long", s);
+			ubyte_type = new QName ("unsignedByte", s);
+			ushort_type = new QName ("unsignedShort", s);
+			uint_type = new QName ("unsignedInt", s);
+			ulong_type = new QName ("unsignedLong", s);
+			string_type = new QName ("string", s);
+			guid_type = new QName ("guid", s);
+			char_type = new QName ("char", s);
+
+			dbnull_type = new QName ("DBNull", MSSimpleNamespace + "System");
+		}
+
+		// FIXME: find out how QName and guid are processed
+
+		internal QName GetXmlName (Type type)
+		{
+			SerializationMap map = FindUserMap (type);
+			if (map != null)
+				return map.XmlName;
+			return GetPredefinedTypeName (type);
+		}
+
+		internal static QName GetPredefinedTypeName (Type type)
+		{
+			QName name = GetPrimitiveTypeName (type);
+			if (name != QName.Empty)
+				return name;
+			if (type == typeof (DBNull))
+				return dbnull_type;
+			return QName.Empty;
+		}
+
+		internal static QName GetPrimitiveTypeName (Type type)
+		{
+			if (type.IsGenericType && type.GetGenericTypeDefinition () == typeof (Nullable<>))
+				return GetPrimitiveTypeName (type.GetGenericArguments () [0]);
+
+			if (type.IsEnum)
+				return QName.Empty;
+
+			switch (Type.GetTypeCode (type)) {
+			case TypeCode.Object: // other than System.Object
+			case TypeCode.DBNull: // it is natively mapped, but not in ms serialization namespace.
+			case TypeCode.Empty:
+			default:
+				if (type == typeof (object))
+					return any_type;
+				if (type == typeof (Guid))
+					return guid_type;
+				if (type == typeof (TimeSpan))
+					return duration_type;
+				if (type == typeof (byte []))
+					return base64_type;
+				if (type == typeof (Uri))
+					return any_uri_type;
+				return QName.Empty;
+			case TypeCode.Boolean:
+				return bool_type;
+			case TypeCode.Byte:
+				return ubyte_type;
+			case TypeCode.Char:
+				return char_type;
+			case TypeCode.DateTime:
+				return date_type;
+			case TypeCode.Decimal:
+				return decimal_type;
+			case TypeCode.Double:
+				return double_type;
+			case TypeCode.Int16:
+				return short_type;
+			case TypeCode.Int32:
+				return int_type;
+			case TypeCode.Int64:
+				return long_type;
+			case TypeCode.SByte:
+				return byte_type;
+			case TypeCode.Single:
+				return float_type;
+			case TypeCode.String:
+				return string_type;
+			case TypeCode.UInt16:
+				return ushort_type;
+			case TypeCode.UInt32:
+				return uint_type;
+			case TypeCode.UInt64:
+				return ulong_type;
+			}
+		}
+
+		internal static string PredefinedTypeObjectToString (object obj)
+		{
+			Type type = obj.GetType ();
+			switch (Type.GetTypeCode (type)) {
+			case TypeCode.Object: // other than System.Object
+			case TypeCode.Empty:
+			default:
+				if (type == typeof (object))
+					return String.Empty;
+				if (type == typeof (Guid))
+					return XmlConvert.ToString ((Guid) obj);
+				if (type == typeof (TimeSpan))
+					return XmlConvert.ToString ((TimeSpan) obj);
+				if (type == typeof (byte []))
+					return Convert.ToBase64String ((byte []) obj);
+				if (type == typeof (Uri))
+					return ((Uri) obj).ToString ();
+				throw new Exception ("Internal error: missing predefined type serialization for type " + type.FullName);
+			case TypeCode.DBNull: // predefined, but not primitive
+				return String.Empty;
+			case TypeCode.Boolean:
+				return XmlConvert.ToString ((bool) obj);
+			case TypeCode.Byte:
+				return XmlConvert.ToString ((byte) obj);
+			case TypeCode.Char:
+				return XmlConvert.ToString ((uint) (char) obj);
+			case TypeCode.DateTime:
+				return XmlConvert.ToString ((DateTime) obj, XmlDateTimeSerializationMode.RoundtripKind);
+			case TypeCode.Decimal:
+				return XmlConvert.ToString ((decimal) obj);
+			case TypeCode.Double:
+				return XmlConvert.ToString ((double) obj);
+			case TypeCode.Int16:
+				return XmlConvert.ToString ((short) obj);
+			case TypeCode.Int32:
+				return XmlConvert.ToString ((int) obj);
+			case TypeCode.Int64:
+				return XmlConvert.ToString ((long) obj);
+			case TypeCode.SByte:
+				return XmlConvert.ToString ((sbyte) obj);
+			case TypeCode.Single:
+				return XmlConvert.ToString ((float) obj);
+			case TypeCode.String:
+				return (string) obj;
+			case TypeCode.UInt16:
+				return XmlConvert.ToString ((ushort) obj);
+			case TypeCode.UInt32:
+				return XmlConvert.ToString ((uint) obj);
+			case TypeCode.UInt64:
+				return XmlConvert.ToString ((ulong) obj);
+			}
+		}
+
+		internal static bool IsPrimitiveType (QName qname)
+		{
+			/* FIXME: qname.Namespace ? */
+			switch (qname.Name) {
+			case "anyURI":
+			case "boolean":
+			case "base64Binary":
+			case "dateTime":
+			case "duration":
+			case "QName":
+			case "decimal":
+			case "double":
+			case "float":
+			case "byte":
+			case "short":
+			case "int":
+			case "long":
+			case "unsignedByte":
+			case "unsignedShort":
+			case "unsignedInt":
+			case "unsignedLong":
+			case "string":
+			case "anyType":
+			case "guid":
+			case "char":
+				return true;
+			default:
+				return false;
+			}
+		}
+
+
+		internal static object PredefinedTypeStringToObject (string s,
+			string name, XmlReader reader)
+		{
+			switch (name) {
+			case "anyURI":
+				return new Uri(s,UriKind.RelativeOrAbsolute);
+			case "boolean":
+				return XmlConvert.ToBoolean (s);
+			case "base64Binary":
+				return Convert.FromBase64String (s);
+			case "dateTime":
+				return XmlConvert.ToDateTime (s, XmlDateTimeSerializationMode.RoundtripKind);
+			case "duration":
+				return XmlConvert.ToTimeSpan (s);
+			case "QName":
+				int idx = s.IndexOf (':');
+				string l = idx < 0 ? s : s.Substring (idx + 1);
+				return idx < 0 ? new QName (l) :
+					new QName (l, reader.LookupNamespace (
+						s.Substring (0, idx)));
+			case "decimal":
+				return XmlConvert.ToDecimal (s);
+			case "double":
+				return XmlConvert.ToDouble (s);
+			case "float":
+				return XmlConvert.ToSingle (s);
+			case "byte":
+				return XmlConvert.ToSByte (s);
+			case "short":
+				return XmlConvert.ToInt16 (s);
+			case "int":
+				return XmlConvert.ToInt32 (s);
+			case "long":
+				return XmlConvert.ToInt64 (s);
+			case "unsignedByte":
+				return XmlConvert.ToByte (s);
+			case "unsignedShort":
+				return XmlConvert.ToUInt16 (s);
+			case "unsignedInt":
+				return XmlConvert.ToUInt32 (s);
+			case "unsignedLong":
+				return XmlConvert.ToUInt64 (s);
+			case "string":
+				return s;
+			case "guid":
+				return XmlConvert.ToGuid (s);
+			case "anyType":
+				return s;
+			case "char":
+				return (char) XmlConvert.ToUInt32 (s);
+			default:
+				throw new Exception ("Unanticipated primitive type: " + name);
+			}
+		}
+
+		List<SerializationMap> contracts = new List<SerializationMap> ();
+
+		public KnownTypeCollection ()
+		{
+		}
+
+		protected override void ClearItems ()
+		{
+			base.Clear ();
+		}
+
+		protected override void InsertItem (int index, Type type)
+		{
+			if (TryRegister (type))
+				base.InsertItem (index, type);
+		}
+
+		// FIXME: it could remove other types' dependencies.
+		protected override void RemoveItem (int index)
+		{
+			Type t = base [index];
+			List<SerializationMap> l = new List<SerializationMap> ();
+			foreach (SerializationMap m in contracts) {
+				if (m.RuntimeType == t)
+					l.Add (m);
+			}
+			foreach (SerializationMap m in l) {
+				contracts.Remove (m);
+				base.RemoveItem (index);
+			}
+		}
+
+		protected override void SetItem (int index, Type type)
+		{
+			if (index == Count)
+				InsertItem (index, type);
+			else {
+				RemoveItem (index);
+				if (TryRegister (type))
+					base.InsertItem (index - 1, type);
+			}
+		}
+
+		internal SerializationMap FindUserMap (QName qname)
+		{
+			for (int i = 0; i < contracts.Count; i++)
+				if (qname == contracts [i].XmlName)
+					return contracts [i];
+			return null;
+		}
+
+		internal SerializationMap FindUserMap (Type type)
+		{
+			for (int i = 0; i < contracts.Count; i++)
+				if (type == contracts [i].RuntimeType)
+					return contracts [i];
+			return null;
+		}
+
+		internal QName GetQName (Type type)
+		{
+			if (IsPrimitiveNotEnum (type))
+				return GetPrimitiveTypeName (type);
+
+			SerializationMap map = FindUserMap (type);
+			if (map != null)
+				// already mapped.
+				return map.XmlName; 
+
+			if (type.IsEnum)
+				return GetEnumQName (type);
+
+			QName qname = GetContractQName (type);
+			if (qname != null)
+				return qname;
+
+			if (type.GetInterface ("System.Xml.Serialization.IXmlSerializable") != null)
+				//FIXME: Reusing GetSerializableQName here, since we just 
+				//need name of the type..
+				return GetSerializableQName (type);
+
+			Type element = GetCollectionElementType (type);
+			if (element != null)
+				return GetCollectionQName (element);
+
+			if (type.GetCustomAttributes (typeof (SerializableAttribute), false).Length == 1)
+				return GetSerializableQName (type);
+
+			// FIXME: it needs in-depth check.
+			return QName.Empty;
+		}
+		
+		private QName GetContractQName (Type type)
+		{
+			object [] atts = type.GetCustomAttributes (
+				typeof (DataContractAttribute), false);
+			if (atts.Length == 0)
+				return null;
+
+			string name = ((DataContractAttribute) atts [0]).Name;
+			if (name == null)
+				// FIXME: there could be decent ways to get 
+				// the same result...
+				name = type.Namespace == null || type.Namespace.Length == 0 ? type.Name : type.FullName.Substring (type.Namespace.Length + 1).Replace ('+', '.');
+
+			string ns = ((DataContractAttribute) atts [0]).Namespace;
+			if (ns == null)
+				ns = XmlObjectSerializer.DefaultNamespaceBase + type.Namespace;
+
+			return new QName (name, ns);
+		}
+
+		private QName GetEnumQName (Type type)
+		{
+			string name = null, ns = null;
+
+			if (!type.IsEnum)
+				return null;
+
+			object [] atts = type.GetCustomAttributes (
+				typeof (DataContractAttribute), false);
+
+			if (atts.Length != 0) {
+				ns = ((DataContractAttribute) atts [0]).Namespace;
+				name = ((DataContractAttribute) atts [0]).Name;
+			}
+
+			if (ns == null)
+				ns = XmlObjectSerializer.DefaultNamespaceBase + type.Namespace;
+
+			if (name == null)
+				name = type.Namespace == null || type.Namespace.Length == 0 ? type.Name : type.FullName.Substring (type.Namespace.Length + 1).Replace ('+', '.');
+
+			return new QName (name, ns);
+		}
+
+		private QName GetCollectionQName (Type element)
+		{
+			QName eqname = GetQName (element);
+			
+			string ns = eqname.Namespace;
+			if (eqname.Namespace == MSSimpleNamespace)
+				//Arrays of Primitive types
+				ns = MSArraysNamespace;
+
+			return new QName (
+				"ArrayOf" + XmlConvert.EncodeLocalName (eqname.Name),
+				ns);
+		}
+
+		private QName GetSerializableQName (Type type)
+		{
+			string xmlName = type.Name;
+			string xmlNamespace = XmlObjectSerializer.DefaultNamespaceBase + type.Namespace;
+			object [] xmlRootAttributes = type.GetCustomAttributes (typeof (XmlRootAttribute), false);
+			if (xmlRootAttributes.Length > 1)
+				throw new Exception ("Only one XmlRoot namespace allowed on type " + type.Name);
+			if (xmlRootAttributes.Length == 1) {
+				XmlRootAttribute rootAttribute = (XmlRootAttribute) xmlRootAttributes [0];
+				xmlName = rootAttribute.ElementName;
+				xmlNamespace = rootAttribute.Namespace;
+			}
+			return new QName (XmlConvert.EncodeLocalName (xmlName),	xmlNamespace);
+		}
+
+		internal bool IsPrimitiveNotEnum (Type type)
+		{
+			if (type.IsEnum)
+				return false;
+			if (Type.GetTypeCode (type) != TypeCode.Object) // explicitly primitive
+				return true;
+			if (type == typeof (Guid) || type == typeof (object) || type == typeof(TimeSpan) || type == typeof(byte[]) || type==typeof(Uri)) // special primitives
+				return true;
+			// nullable
+			if (type.IsGenericType && type.GetGenericTypeDefinition () == typeof (Nullable<>))
+				return IsPrimitiveNotEnum (type.GetGenericArguments () [0]);
+			return false;
+		}
+
+		internal bool TryRegister (Type type)
+		{
+			// exclude predefined maps
+			if (IsPrimitiveNotEnum (type))
+				return false;
+
+			if (FindUserMap (type) != null)
+				return false;
+
+			if (RegisterEnum (type) != null)
+				return true;
+
+			if (RegisterContract (type) != null)
+				return true;
+
+			if (RegisterIXmlSerializable (type) != null)
+				return true;
+			
+			Type element = GetCollectionElementType (type);
+			if (element != null) {
+				TryRegister (element);
+				RegisterCollection (type, element);
+				return true;
+			}
+
+			if (type.GetCustomAttributes (typeof (SerializableAttribute), false).Length == 1) {
+				RegisterSerializable (type);
+				return true;
+			}
+
+			throw new InvalidDataContractException (String.Format ("Type {0} has neither Serializable nor DataContract attributes.", type));
+		}
+
+		static readonly Type genericIEnumerable =
+			typeof (IEnumerable<object>).GetGenericTypeDefinition ();
+
+		internal static Type GetCollectionElementType (Type type)
+		{
+			if (type.IsArray)
+				return type.GetElementType ();
+
+			Type [] ifaces = type.GetInterfaces ();
+			foreach (Type iface in ifaces) {
+				Type t = iface;
+				Type gt = t.IsGenericType ? 
+					t.GetGenericTypeDefinition () : null;
+				if (gt == genericIEnumerable)
+					return t.GetGenericArguments () [0];
+				foreach (Type i in ifaces)
+					if (i == typeof (IEnumerable))
+						return typeof (object);
+			}
+			return null;
+		}
+
+		private CollectionTypeMap RegisterCollection (Type type, Type element)
+		{
+			QName qname = GetCollectionQName (element);
+
+			if (FindUserMap (qname) != null)
+				throw new InvalidOperationException (String.Format ("Failed to add type {0} to known type collection. There already is a registered type for XML name {1}", type, qname));
+
+			CollectionTypeMap ret =
+				new CollectionTypeMap (type, element, qname, this);
+			contracts.Add (ret);
+			return ret;
+		}
+
+		private SerializationMap RegisterSerializable (Type type)
+		{
+			QName qname = GetSerializableQName (type);
+
+			if (FindUserMap (qname) != null)
+				throw new InvalidOperationException (String.Format ("There is already a registered type for XML name {0}", qname));
+
+			SharedTypeMap ret =
+				new SharedTypeMap (type, qname, this);
+			contracts.Add (ret);
+			return ret;
+		}
+
+		private SerializationMap RegisterIXmlSerializable (Type type)
+		{
+			if (type.GetInterface ("System.Xml.Serialization.IXmlSerializable") == null)
+				return null;
+
+			QName qname = GetSerializableQName (type);
+
+			if (FindUserMap (qname) != null)
+				throw new InvalidOperationException (String.Format ("There is already a registered type for XML name {0}", qname));
+
+			XmlSerializableMap ret = new XmlSerializableMap (type, qname, this);
+			contracts.Add (ret);
+
+			return ret;
+		}
+
+		private SharedContractMap RegisterContract (Type type)
+		{
+			QName qname = GetContractQName (type);
+			if (qname == null)
+				return null;
+
+			switch (qname.Namespace) {
+			case XmlSchema.Namespace:
+			case XmlSchema.InstanceNamespace:
+			case MSSimpleNamespace:
+			case MSArraysNamespace:
+				throw new InvalidOperationException (String.Format ("Namespace {0} is reserved and cannot be used for user serialization", qname.Namespace));
+			}
+
+			if (FindUserMap (qname) != null)
+				throw new InvalidOperationException (String.Format ("There is already a registered type for XML name {0}", qname));
+
+			SharedContractMap ret =
+				new SharedContractMap (type, qname, this);
+			contracts.Add (ret);
+			return ret;
+		}
+
+		private EnumMap RegisterEnum (Type type)
+		{
+			QName qname = GetEnumQName (type);
+			if (qname == null)
+				return null;
+
+			if (FindUserMap (qname) != null)
+				throw new InvalidOperationException (String.Format ("There is already a registered type for XML name {0}", qname));
+
+			EnumMap ret =
+				new EnumMap (type, qname, this);
+			contracts.Add (ret);
+			return ret;
+		}
+	}
+}
+#endif

+ 274 - 0
mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/NetDataContractSerializer.cs

@@ -0,0 +1,274 @@
+//
+// NetDataContractSerializer.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+using System;
+using System.Collections;
+using System.IO;
+using System.Reflection;
+using System.Runtime.Serialization.Formatters;
+using System.Runtime.Serialization.Formatters.Binary;
+using System.Xml;
+using System.Xml.Schema;
+
+using QName = System.Xml.XmlQualifiedName;
+
+namespace System.Runtime.Serialization
+{
+	public sealed class NetDataContractSerializer
+		: XmlObjectSerializer, IFormatter
+	{
+		const string xmlns = "http://www.w3.org/2000/xmlns/";
+		const string default_ns = "http://schemas.datacontract.org/2004/07/";
+
+		// This is only for compatible mode.
+		StreamingContext context;
+//		KnownTypeCollection known_types;
+//		IDataContractSurrogate surrogate;
+
+		SerializationBinder binder;
+		ISurrogateSelector selector;
+
+		int max_items = 0x10000; // FIXME: could be from config.
+		bool ignore_extensions;
+		FormatterAssemblyStyle ass_style;
+
+		XmlDictionaryString root_name, root_ns;
+
+		public NetDataContractSerializer ()
+		{
+		}
+
+		public NetDataContractSerializer (StreamingContext context)
+		{
+			this.context = context;
+		}
+
+		public NetDataContractSerializer (string rootName,
+			string rootNamespace)
+		{
+			FillDictionaryString (rootName, rootNamespace);
+		}
+
+		public NetDataContractSerializer (XmlDictionaryString rootName,
+			XmlDictionaryString rootNamespace)
+		{
+			if (rootName == null)
+				throw new ArgumentNullException ("rootName");
+			if (rootNamespace == null)
+				throw new ArgumentNullException ("rootNamespace");
+			root_name = rootName;
+			root_ns = rootNamespace;
+		}
+
+		public NetDataContractSerializer (StreamingContext context, 
+			int maxItemsInObjectGraph,
+			bool ignoreExtensibleDataObject,
+			FormatterAssemblyStyle assemblyFormat,
+			ISurrogateSelector surrogateSelector)
+		{
+			this.context = context;
+			max_items = maxItemsInObjectGraph;
+			ignore_extensions = ignoreExtensibleDataObject;
+			ass_style = assemblyFormat;
+			selector = surrogateSelector;
+		}
+
+		public NetDataContractSerializer (
+			string rootName, string rootNamespace,
+			StreamingContext context, 
+			int maxItemsInObjectGraph,
+			bool ignoreExtensibleDataObject,
+			FormatterAssemblyStyle assemblyFormat,
+			ISurrogateSelector surrogateSelector)
+			: this (context, maxItemsInObjectGraph,
+				ignoreExtensibleDataObject, assemblyFormat,
+				surrogateSelector)
+		{
+			FillDictionaryString (rootName, rootNamespace);
+		}
+
+		public NetDataContractSerializer (
+			XmlDictionaryString rootName,
+			XmlDictionaryString rootNamespace,
+			StreamingContext context,
+			int maxItemsInObjectGraph,
+			bool ignoreExtensibleDataObject,
+			FormatterAssemblyStyle assemblyFormat,
+			ISurrogateSelector surrogateSelector)
+			: this (context, maxItemsInObjectGraph,
+				ignoreExtensibleDataObject, assemblyFormat,
+				surrogateSelector)
+		{
+			if (rootName == null)
+				throw new ArgumentNullException ("rootName");
+			if (rootNamespace == null)
+				throw new ArgumentNullException ("rootNamespace");
+			root_name = rootName;
+			root_ns = rootNamespace;
+		}
+
+		void FillDictionaryString (string rootName, string rootNamespace)
+		{
+			if (rootName == null)
+				throw new ArgumentNullException ("rootName");
+			if (rootNamespace == null)
+				throw new ArgumentNullException ("rootNamespace");
+			XmlDictionary d = new XmlDictionary ();
+			root_name = d.Add (rootName);
+			root_ns = d.Add (rootNamespace);
+		}
+
+		public FormatterAssemblyStyle AssemblyFormat {
+			get { return ass_style; }
+			set { ass_style = value; }
+		}
+
+		public SerializationBinder Binder {
+			get { return binder; }
+			set { binder = value; }
+		}
+
+		public bool IgnoreExtensionDataObject {
+			get { return ignore_extensions; }
+		}
+
+		public ISurrogateSelector SurrogateSelector {
+			get { return selector; }
+			set { selector = value; }
+		}
+
+		public StreamingContext Context {
+			get { return context; }
+			set { context = value; }
+		}
+
+		public int MaxItemsInObjectGraph {
+			get { return max_items; }
+		}
+
+		public object Deserialize (Stream stream)
+		{
+			return ReadObject (stream);
+		}
+
+		[MonoTODO]
+		public override bool IsStartObject (XmlDictionaryReader reader)
+		{
+			throw new NotImplementedException ();
+		}
+
+		public override object ReadObject (XmlDictionaryReader reader, bool readContentOnly)
+		{
+			/*
+			int startTypeCount = known_types.Count;
+
+			object ret = XmlFormatterDeserializer.Deserialize (
+				// FIXME: remove this second param.
+				reader, null, known_types, surrogate, readContentOnly);
+
+			if (!readContentOnly && reader.NodeType == XmlNodeType.EndElement)
+				reader.Read ();
+
+			// remove temporarily-added known types for
+			// rootType and object graph type.
+			while (known_types.Count > startTypeCount)
+				known_types.RemoveAt (startTypeCount);
+
+			return ret;
+			*/
+			throw new NotImplementedException ();
+		}
+
+		public void Serialize (Stream stream, Object graph)
+		{
+			using (XmlWriter w = XmlWriter.Create (stream)) {
+				WriteObject (w, graph);
+			}
+		}
+
+		[MonoTODO ("support arrays; support Serializable; support SharedType; use DataContractSurrogate")]
+		/*
+			when writeContentOnly is true, then the input XmlWriter
+			must be at element state. This is to write possible
+			xsi:nil.
+
+			rootType determines the top-level element QName (thus
+			it is ignored when writeContentOnly is true).
+
+			preserveObjectReferences indicates that whether the
+			output should contain ms:Id or not.
+			(http://schemas.microsoft.com/2003/10/Serialization/)
+		*/
+		public override void WriteObjectContent (
+			XmlDictionaryWriter writer, object graph)
+		{
+			/*
+			int startTypeCount = known_types.Count;
+
+			string ns = default_ns;
+
+			//writer.WriteAttributeString ("xmlns", "i", xmlns, XmlSchema.InstanceNamespace);
+			//writer.WriteAttributeString ("xmlns", "x", xmlns, XmlSchema.Namespace);
+			if (ns != null)
+				writer.WriteAttributeString ("xmlns", xmlns, ns);
+
+			XmlFormatterSerializer.Serialize (writer, graph,
+				known_types,
+				ignore_extensions, max_items);
+
+			// remove temporarily-added known types for
+			// rootType and object graph type.
+			while (known_types.Count > startTypeCount)
+				known_types.RemoveAt (startTypeCount);
+			*/
+			throw new NotImplementedException ();
+		}
+
+		public override void WriteStartObject (
+			XmlDictionaryWriter writer, object graph)
+		{
+			/*
+			Type rootType = graph.GetType ();
+			known_types.Add (rootType);
+			SerializationMap map =
+				known_types.FindUserMap (rootType);
+			QName name = map != null ? map.XmlName :
+				KnownTypeCollection.GetPredefinedTypeName (rootType);
+			writer.WriteStartElement (
+				name.Name, name.Namespace);
+			*/
+			throw new NotImplementedException ();
+		}
+
+		public override void WriteEndObject (XmlDictionaryWriter writer)
+		{
+			writer.WriteEndElement ();
+		}
+	}
+}
+#endif

+ 740 - 0
mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/SerializationMap.cs

@@ -0,0 +1,740 @@
+//
+// SerializationMap.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//	Ankit Jain <[email protected]>
+//	Duncan Mak ([email protected])
+//	Eyal Alaluf ([email protected])
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Reflection;
+using System.Xml;
+using System.Xml.Schema;
+using System.Xml.Serialization;
+
+using QName = System.Xml.XmlQualifiedName;
+
+namespace System.Runtime.Serialization
+{
+/*
+	XmlFormatter implementation design inference:
+
+	type definitions:
+	- No XML Schema types are directly used. There are some maps from
+	  xs:blahType to ms:blahType where the namespaceURI for prefix "ms" is
+	  "http://schemas.microsoft.com/2003/10/Serialization/" .
+
+	serializable types:
+	- An object being serialized 1) must be of type System.Object, or
+	  2) must be null, or 3) must have either a [DataContract] attribute
+	  or a [Serializable] attribute to be serializable.
+	- When the object is either of type System.Object or null, then the
+	  XML type is "anyType".
+	- When the object is [Serializable], then the runtime-serialization
+	  compatible object graph is written.
+	- Otherwise the serialization is based on contract attributes.
+	  ([Serializable] takes precedence).
+
+	type derivation:
+	- For type A to be serializable, the base type B of A must be
+	  serializable.
+	- If a type which is [Serializable] and whose base type has a
+	  [DataContract], then for base type members [DataContract] is taken.
+	- It is vice versa i.e. if the base type is [Serializable] and the
+	  derived type has a [DataContract], then [Serializable] takes place
+	  for base members.
+
+	known type collection:
+	- It internally manages mapping store keyed by contract QNames.
+	  KnownTypeCollection.Add() checks if the same QName contract already
+	  exists (and raises InvalidOperationException if required).
+
+*/
+	internal abstract class SerializationMap
+	{
+		public const BindingFlags AllInstanceFlags =
+			BindingFlags.Public | BindingFlags.NonPublic |
+			BindingFlags.Instance;
+
+		public readonly KnownTypeCollection KnownTypes;
+		public readonly Type RuntimeType;
+		public readonly QName XmlName;
+		public List<DataMemberInfo> Members;
+		XmlSchemaSet schema_set;
+ 
+		//FIXME FIXME
+		Dictionary<Type, QName> qname_table = new Dictionary<Type, QName> ();
+
+		protected SerializationMap (
+			Type type, QName qname, KnownTypeCollection knownTypes)
+		{
+			KnownTypes = knownTypes;
+			RuntimeType = type;
+			if (qname.Namespace == String.Empty)
+				qname = new QName (qname.Name,
+					"http://schemas.datacontract.org/2004/07/" + type.Namespace);
+
+			XmlName = qname;
+			Members = new List<DataMemberInfo> ();
+		}
+
+		public DataMemberAttribute GetDataMemberAttribute (
+			MemberInfo mi)
+		{
+			object [] atts = mi.GetCustomAttributes (
+				typeof (DataMemberAttribute), false);
+			if (atts.Length == 0)
+				return null;
+			return (DataMemberAttribute) atts [0];
+		}
+
+		bool IsPrimitive (Type type)
+		{
+			return (Type.GetTypeCode (type) != TypeCode.Object || type == typeof (object));
+		}
+
+		/* Returns the XmlSchemaType AND adds it to @schemas */
+		public virtual XmlSchemaType GetSchemaType (XmlSchemaSet schemas, Dictionary<QName, XmlSchemaType> generated_schema_types)
+		{
+			if (IsPrimitive (RuntimeType))
+				return null;
+
+			if (generated_schema_types.ContainsKey (XmlName)) // Caching  
+				return generated_schema_types [XmlName] as XmlSchemaType;
+
+			XmlSchemaComplexType complex_type = null;
+
+			complex_type = new XmlSchemaComplexType ();
+			complex_type.Name = XmlName.Name;
+			generated_schema_types [XmlName] = complex_type;
+
+			if (RuntimeType.BaseType == typeof (object)) {
+				complex_type.Particle = GetSequence (schemas, generated_schema_types);
+			} else {
+				//Has a non-System.Object base class
+				XmlSchemaComplexContentExtension extension = new XmlSchemaComplexContentExtension ();
+				XmlSchemaComplexContent content = new XmlSchemaComplexContent ();
+
+				complex_type.ContentModel = content;
+				content.Content = extension;
+
+				KnownTypes.Add (RuntimeType.BaseType);
+				SerializationMap map = KnownTypes.FindUserMap (RuntimeType.BaseType);
+				//FIXME: map == null ?
+				map.GetSchemaType (schemas, generated_schema_types);
+
+				extension.Particle = GetSequence (schemas, generated_schema_types);
+				extension.BaseTypeName = GetQualifiedName (RuntimeType.BaseType);
+			}
+			
+			XmlSchemaElement schemaElement = GetSchemaElement (XmlName, complex_type);
+			XmlSchema schema = GetSchema (schemas, XmlName.Namespace);
+			schema.Items.Add (complex_type);
+			schema.Items.Add (schemaElement);
+			schemas.Reprocess (schema);
+
+			return complex_type;
+		}
+
+		/* Returns the <xs:sequence> for the data members */
+		XmlSchemaSequence GetSequence (XmlSchemaSet schemas,
+				Dictionary<QName, XmlSchemaType> generated_schema_types)
+		{
+			List<DataMemberInfo> members = GetMembers ();
+
+			XmlSchema schema = GetSchema (schemas, XmlName.Namespace);
+			XmlSchemaSequence sequence = new XmlSchemaSequence ();
+			foreach (DataMemberInfo dmi in members) {
+				// delegates are not supported.
+				if (!dmi.MemberType.IsAbstract && typeof (System.Delegate).IsAssignableFrom (dmi.MemberType))
+					continue;
+
+				XmlSchemaElement element = new XmlSchemaElement ();
+				element.Name = dmi.XmlName;
+
+				KnownTypes.Add (dmi.MemberType);
+				SerializationMap map = KnownTypes.FindUserMap (dmi.MemberType);
+				if (map != null) {
+					XmlSchemaType schema_type = map.GetSchemaType (schemas, generated_schema_types);
+					if (schema_type is XmlSchemaComplexType)
+						element.IsNillable = true;
+				} else {
+					//Primitive type
+					if (dmi.MemberType == typeof (string))
+						element.IsNillable = true;
+				}
+
+				element.MinOccurs = 0;
+
+				element.SchemaTypeName = GetQualifiedName (dmi.MemberType);
+				AddImport (schema, element.SchemaTypeName.Namespace);
+
+				sequence.Items.Add (element);
+			}
+
+			schemas.Reprocess (schema);
+			return sequence;
+		}
+
+		//FIXME: Replace with a dictionary ?
+		void AddImport (XmlSchema schema, string ns)
+		{
+			if (ns == XmlSchema.Namespace || schema.TargetNamespace == ns)
+				return;
+
+			foreach (XmlSchemaObject o in schema.Includes) {
+				XmlSchemaImport import = o as XmlSchemaImport;
+				if (import == null)
+					continue;
+				if (import.Namespace == ns)
+					return;
+			}
+
+			XmlSchemaImport imp = new XmlSchemaImport ();
+			imp.Namespace = ns;
+			schema.Includes.Add (imp);
+		}
+
+		//Returns list of data members for this type ONLY
+		public virtual List<DataMemberInfo> GetMembers ()
+		{
+			throw new NotImplementedException (String.Format ("Implement me for {0}", this));
+		}
+
+		protected XmlSchemaElement GetSchemaElement (QName qname, XmlSchemaType schemaType)
+		{
+			XmlSchemaElement schemaElement = new XmlSchemaElement ();
+			schemaElement.Name = qname.Name;
+			schemaElement.SchemaTypeName = qname;
+
+			if (schemaType is XmlSchemaComplexType)
+				schemaElement.IsNillable = true;
+
+			return schemaElement;
+		}
+
+		protected XmlSchema GetSchema (XmlSchemaSet schemas, string ns)
+		{
+			ICollection colln = schemas.Schemas (ns);
+			if (colln.Count > 0) {
+				if (colln.Count > 1)
+					throw new Exception (String.Format (
+						"More than 1 schema for namespace '{0}' found.", ns));
+				foreach (object o in colln)
+					//return colln [0]
+					return (o as XmlSchema);
+			}
+
+			XmlSchema schema = new XmlSchema ();
+			schema.TargetNamespace = ns;
+			schema.ElementFormDefault = XmlSchemaForm.Qualified;
+			schemas.Add (schema);
+
+			return schema;
+		}
+
+		//FIXME: redundant?
+		protected XmlQualifiedName GetQualifiedName (Type type)
+		{
+			if (qname_table.ContainsKey (type))
+				return qname_table [type];
+
+			QName qname = KnownTypes.GetQName (type);
+			if (qname.Namespace == KnownTypeCollection.MSSimpleNamespace)
+				qname = new QName (qname.Name, XmlSchema.Namespace);
+
+			qname_table [type] = qname;
+			return qname;
+		}
+
+		public virtual void Serialize (object graph,
+			XmlFormatterSerializer serializer)
+		{
+			foreach (DataMemberInfo dmi in Members) {
+				FieldInfo fi = dmi.Member as FieldInfo;
+				PropertyInfo pi = fi == null ?
+					(PropertyInfo) dmi.Member : null;
+				Type type = fi != null ?
+					fi.FieldType : pi.PropertyType;
+				object value = fi != null ?
+					fi.GetValue (graph) :
+					pi.GetValue (graph, null);
+
+				serializer.WriteStartElement (dmi.XmlName, dmi.XmlRootNamespace, dmi.XmlNamespace);
+				serializer.Serialize (type, value);
+				serializer.WriteEndElement ();
+			}
+		}
+		
+		/* Deserialize non-primitive types */
+		public virtual object DeserializeContent (XmlReader reader,
+			XmlFormatterDeserializer deserializer)
+		{
+			object instance = FormatterServices.GetUninitializedObject (RuntimeType);
+			int depth = reader.NodeType == XmlNodeType.None ? reader.Depth : reader.Depth - 1;
+			bool [] filled = new bool [Members.Count];
+			int memberInd = -1;
+			while (reader.NodeType == XmlNodeType.Element && reader.Depth > depth) {
+				DataMemberInfo dmi = null;
+				for (int i = memberInd + 1; i < Members.Count; i++) {
+					if (reader.LocalName == Members [i].XmlName &&
+						reader.NamespaceURI == Members [i].XmlRootNamespace) {
+						memberInd = i;
+						dmi = Members [i];
+						break;
+					}
+				}
+
+				if (dmi == null) {
+					reader.Skip ();
+					continue;
+				}
+				SetValue (dmi, instance, deserializer.Deserialize (dmi.MemberType, reader));
+				filled [memberInd] = true;
+			}
+			for (int i = 0; i < Members.Count; i++)
+				if (!filled [i] && Members [i].IsRequired)
+					throw MissingRequiredMember (Members [i], reader);
+
+			return instance;
+		}
+
+		// For now it could be private.
+		protected Exception MissingRequiredMember (DataMemberInfo dmi, XmlReader reader)
+		{
+			return new ArgumentException (String.Format ("Data contract member {0} is required, but missing in the input XML.", new QName (dmi.XmlName, dmi.XmlNamespace)));
+		}
+
+		// For now it could be private.
+		protected void SetValue (DataMemberInfo dmi, object obj, object value)
+		{
+			if (dmi.Member is PropertyInfo)
+				((PropertyInfo) dmi.Member).SetValue (obj, value, null);
+			else
+				((FieldInfo) dmi.Member).SetValue (obj, value);
+		}
+
+		protected DataMemberInfo CreateDataMemberInfo (DataMemberAttribute dma, MemberInfo mi, Type type)
+		{
+			KnownTypes.Add (type);
+			QName qname = KnownTypes.GetQName (type);
+			string rootNamespace = KnownTypes.GetQName (mi.DeclaringType).Namespace;
+			if (KnownTypeCollection.IsPrimitiveType (qname))
+				return new DataMemberInfo (mi, dma, rootNamespace, null);
+			else
+				return new DataMemberInfo (mi, dma, rootNamespace, qname.Namespace);
+		}
+	}
+
+	internal class XmlSerializableMap : SerializationMap
+	{
+		public XmlSerializableMap (Type type, QName qname, KnownTypeCollection knownTypes)
+			: base (type, qname, knownTypes)
+		{
+		}
+
+		public override void Serialize (object graph, XmlFormatterSerializer serializer)
+		{
+			IXmlSerializable ixs = graph as IXmlSerializable;
+			if (ixs == null)
+				//FIXME: Throw what exception here?
+				throw new SerializationException ();
+
+			ixs.WriteXml (serializer.Writer);
+		}
+	}
+
+	internal class SharedContractMap : SerializationMap
+	{
+		public SharedContractMap (
+			Type type, QName qname, KnownTypeCollection knownTypes)
+			: base (type, qname, knownTypes)
+		{
+			Type baseType = type;
+			List <DataMemberInfo> members = new List <DataMemberInfo> ();
+			
+			while (baseType != null) {
+				QName bqname = knownTypes.GetQName (baseType);
+					
+				members = GetMembers (baseType, bqname, true);
+				Members.InsertRange (0, members);
+				members.Clear ();
+
+				baseType = baseType.BaseType;
+			}
+
+//			Members.Sort (delegate (
+//				DataMemberInfo d1, DataMemberInfo d2) {
+//					return d1.Order - d2.Order;
+//				});
+		}
+
+		List<DataMemberInfo> GetMembers (Type type, QName qname, bool declared_only)
+		{
+			List<DataMemberInfo> data_members = new List<DataMemberInfo> ();
+			BindingFlags flags = AllInstanceFlags;
+			if (declared_only)
+				flags |= BindingFlags.DeclaredOnly;
+
+			foreach (PropertyInfo pi in type.GetProperties (flags)) {
+				DataMemberAttribute dma =
+					GetDataMemberAttribute (pi);
+				if (dma == null)
+					continue;
+				if (!pi.CanRead || !pi.CanWrite)
+					throw new InvalidDataContractException (String.Format (
+							"DataMember property {0} must have both getter and setter.", pi));
+				data_members.Add (CreateDataMemberInfo (dma, pi, pi.PropertyType));
+			}
+
+			foreach (FieldInfo fi in type.GetFields (flags)) {
+				DataMemberAttribute dma =
+					GetDataMemberAttribute (fi);
+				if (dma == null)
+					continue;
+				if (fi.IsInitOnly)
+					throw new InvalidDataContractException (String.Format (
+							"DataMember field {0} must not be read-only.", fi));
+				data_members.Add (CreateDataMemberInfo (dma, fi, fi.FieldType));
+			}
+
+			data_members.Sort (DataMemberInfo.DataMemberInfoComparer.Instance);
+
+			return data_members;
+		}
+
+		public override List<DataMemberInfo> GetMembers ()
+		{
+			return GetMembers (RuntimeType, XmlName, true);
+		}
+	}
+
+	internal class CollectionTypeMap : SerializationMap
+	{
+		Type element_type;
+		QName element_qname;
+
+		public CollectionTypeMap (
+			Type type, Type elementType,
+			QName qname, KnownTypeCollection knownTypes)
+			: base (type, qname, knownTypes)
+		{
+			element_type = elementType;
+			element_qname = KnownTypes.GetQName (element_type);
+		}
+
+		public override void Serialize (object graph,
+			XmlFormatterSerializer serializer)
+		{
+			string ns = element_qname.Namespace;
+			if (ns == KnownTypeCollection.MSSimpleNamespace)
+				ns = KnownTypeCollection.MSArraysNamespace;
+
+			foreach (object o in (IEnumerable) graph) {
+				serializer.WriteStartElement (element_qname.Name, XmlName.Namespace, ns);
+				serializer.Serialize (element_type, o);
+				serializer.WriteEndElement ();
+			}
+		}
+
+        public override object DeserializeContent(XmlReader reader, XmlFormatterDeserializer deserializer)
+        {
+            object instance;
+            if (RuntimeType.IsArray)
+                instance = new ArrayList ();
+            else
+                instance = Activator.CreateInstance (RuntimeType, true);
+            int depth = reader.NodeType == XmlNodeType.None ? reader.Depth : reader.Depth - 1;
+            while (reader.NodeType == XmlNodeType.Element && reader.Depth > depth) {
+                object elem = deserializer.Deserialize (element_type, reader);
+                if (instance is IList)
+                    ((IList)instance).Add (elem);
+                else
+                    throw new NotImplementedException (String.Format ("Type {0} is not supported", RuntimeType));
+            }
+            if (RuntimeType.IsArray)
+                return ((ArrayList)instance).ToArray (element_type);
+            return instance;
+        }
+
+		public override List<DataMemberInfo> GetMembers ()
+		{
+			//Shouldn't come here at all!
+			throw new NotImplementedException ();
+		}
+		
+		public override XmlSchemaType GetSchemaType (XmlSchemaSet schemas, Dictionary<QName, XmlSchemaType> generated_schema_types)
+		{
+			if (generated_schema_types.ContainsKey (XmlName))
+				return null;
+
+			if (generated_schema_types.ContainsKey (XmlName))
+				return generated_schema_types [XmlName];
+
+			QName element_qname = GetQualifiedName (element_type);
+
+			XmlSchemaComplexType complex_type = new XmlSchemaComplexType ();
+			complex_type.Name = XmlName.Name;
+
+			XmlSchemaSequence sequence = new XmlSchemaSequence ();
+			XmlSchemaElement element = new XmlSchemaElement ();
+
+			element.MinOccurs = 0;
+			element.MaxOccursString = "unbounded";
+			element.Name = element_qname.Name;
+
+			KnownTypes.Add (element_type);
+			SerializationMap map = KnownTypes.FindUserMap (element_type);
+			if (map != null) {// non-primitive type
+				map.GetSchemaType (schemas, generated_schema_types);
+				element.IsNillable = true;
+			}
+
+			element.SchemaTypeName = element_qname;
+
+			sequence.Items.Add (element);
+			complex_type.Particle = sequence;
+
+			XmlSchema schema = GetSchema (schemas, XmlName.Namespace);
+			schema.Items.Add (complex_type);
+			schema.Items.Add (GetSchemaElement (XmlName, complex_type));
+			schemas.Reprocess (schema);
+
+			generated_schema_types [XmlName] = complex_type;
+
+			return complex_type;
+		}
+	}
+
+	internal class SharedTypeMap : SerializationMap
+	{
+		public SharedTypeMap (
+			Type type, QName qname, KnownTypeCollection knownTypes)
+			: base (type, qname, knownTypes)
+		{
+			Members = GetMembers (type, XmlName, false);
+		}
+
+		List<DataMemberInfo> GetMembers (Type type, QName qname, bool declared_only)
+		{
+			List<DataMemberInfo> data_members = new List<DataMemberInfo> ();
+			int order = 0;
+			BindingFlags flags = AllInstanceFlags;
+			if (declared_only)
+				flags |= BindingFlags.DeclaredOnly;
+			
+			foreach (FieldInfo fi in type.GetFields (flags)) {
+				if (fi.GetCustomAttributes (
+					typeof (NonSerializedAttribute),
+					false).Length > 0)
+					continue;
+
+				if (fi.IsInitOnly)
+					throw new InvalidDataContractException (String.Format ("DataMember field {0} must not be read-only.", fi));
+				DataMemberAttribute dma = new DataMemberAttribute ();
+				dma.Order = order++;
+				data_members.Add (CreateDataMemberInfo (dma, fi, fi.FieldType));
+			}
+
+			return data_members;
+		}
+
+		public override List<DataMemberInfo> GetMembers ()
+		{
+			return GetMembers (RuntimeType, XmlName, true);
+		}
+	}
+
+	internal class EnumMap : SerializationMap
+	{
+		List<EnumMemberInfo> enum_members;
+
+		public EnumMap (
+			Type type, QName qname, KnownTypeCollection knownTypes)
+			: base (type, qname, knownTypes)
+		{
+			bool has_dc = false;
+			object [] atts = RuntimeType.GetCustomAttributes (
+				typeof (DataContractAttribute), false);
+			if (atts.Length != 0)
+				has_dc = true;
+
+			enum_members = new List<EnumMemberInfo> ();
+			BindingFlags flags = BindingFlags.Public | BindingFlags.DeclaredOnly | BindingFlags.Static;
+			
+			foreach (FieldInfo fi in RuntimeType.GetFields (flags)) {
+				string name = fi.Name;
+				if (has_dc) {
+					EnumMemberAttribute ema =
+						GetEnumMemberAttribute (fi);
+					if (ema == null)
+						continue;
+
+					if (ema.Value != null)
+						name = ema.Value;
+				}
+
+				enum_members.Add (new EnumMemberInfo (name, fi.GetValue (null)));
+			}
+		}
+
+		private EnumMemberAttribute GetEnumMemberAttribute (
+			MemberInfo mi)
+		{
+			object [] atts = mi.GetCustomAttributes (
+				typeof (EnumMemberAttribute), false);
+			if (atts.Length == 0)
+				return null;
+			return (EnumMemberAttribute) atts [0];
+		}
+
+		public override XmlSchemaType GetSchemaType (XmlSchemaSet schemas, Dictionary<QName, XmlSchemaType> generated_schema_types)
+		{
+			if (generated_schema_types.ContainsKey (XmlName))
+				return generated_schema_types [XmlName];
+
+			XmlSchemaSimpleType simpleType = new XmlSchemaSimpleType ();
+			simpleType.Name = XmlName.Name;
+
+			XmlSchemaSimpleTypeRestriction simpleRestriction = new XmlSchemaSimpleTypeRestriction ();
+			simpleType.Content = simpleRestriction;
+			simpleRestriction.BaseTypeName = new XmlQualifiedName ("string", XmlSchema.Namespace);
+
+			foreach (EnumMemberInfo emi in enum_members) {
+				XmlSchemaEnumerationFacet e = new XmlSchemaEnumerationFacet ();
+				e.Value = emi.XmlName;
+				simpleRestriction.Facets.Add (e);
+			}
+
+			generated_schema_types [XmlName] = simpleType;
+			
+			XmlSchema schema = GetSchema (schemas, XmlName.Namespace);
+			XmlSchemaElement element = GetSchemaElement (XmlName, simpleType);
+			element.IsNillable = true;
+
+			schema.Items.Add (simpleType);
+			schema.Items.Add (element);
+
+			return simpleType;
+		}
+
+		public override void Serialize (object graph,
+			XmlFormatterSerializer serializer)
+		{
+			foreach (EnumMemberInfo emi in enum_members) {
+				if (Enum.Equals (emi.Value, graph)) {
+					serializer.Writer.WriteString (emi.XmlName);
+					return;
+				}
+			}
+
+			throw new SerializationException (String.Format (
+				"Enum value '{0}' is invalid for type '{1}' and cannot be serialized.", graph, RuntimeType));
+		}
+
+		public override object DeserializeContent (XmlReader reader,
+			XmlFormatterDeserializer deserializer)
+		{
+			string value = reader.NodeType != XmlNodeType.Text ? String.Empty : reader.ReadContentAsString ();
+
+			if (value != String.Empty) {
+				foreach (EnumMemberInfo emi in enum_members)
+					if (emi.XmlName == value)
+						return emi.Value;
+			}
+
+			throw new SerializationException (String.Format (
+				"Enum value '{0}' is invalid for type '{1}' and cannot be deserialized.", value, RuntimeType));
+		}
+	}
+
+	internal struct EnumMemberInfo
+	{
+		public readonly string XmlName;
+		public readonly object Value;
+
+		public EnumMemberInfo (string name, object value)
+		{
+			XmlName = name;
+			Value = value;
+		}
+	}
+
+	internal class DataMemberInfo //: KeyValuePair<int, MemberInfo>
+	{
+		public readonly int Order;
+		public readonly bool IsRequired;
+		public readonly string XmlName;
+		public readonly MemberInfo Member;
+		public readonly string XmlNamespace;
+		public readonly string XmlRootNamespace;
+		public readonly Type MemberType;
+
+		public DataMemberInfo (MemberInfo member, DataMemberAttribute dma, string rootNamespce, string ns)
+		{
+			if (dma == null)
+				throw new ArgumentNullException ("dma");
+			Order = dma.Order;
+			Member = member;
+			IsRequired = dma.IsRequired;
+			XmlName = dma.Name != null ? dma.Name : member.Name;
+			XmlNamespace = ns;
+			XmlRootNamespace = rootNamespce;
+			if (Member is FieldInfo)
+				MemberType = ((FieldInfo) Member).FieldType;
+			else
+				MemberType = ((PropertyInfo) Member).PropertyType;
+		}
+
+		public class DataMemberInfoComparer : IComparer<DataMemberInfo>
+			, IComparer // see bug #76361
+		{
+			public static readonly DataMemberInfoComparer Instance
+				= new DataMemberInfoComparer ();
+
+			private DataMemberInfoComparer () {}
+
+			public int Compare (object o1, object o2)
+			{
+				return Compare ((DataMemberInfo) o1,
+					(DataMemberInfo) o2);
+			}
+
+			public int Compare (DataMemberInfo d1, DataMemberInfo d2)
+			{
+				if (d1.Order == -1 || d2.Order == -1)
+					return String.CompareOrdinal (d1.XmlName, d2.XmlName);
+
+				return d1.Order - d2.Order;
+			}
+		}
+	}
+}
+#endif

+ 142 - 0
mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlFormatterDeserializer.cs

@@ -0,0 +1,142 @@
+//
+// XmlFormatterDeserializer.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+using System;
+using System.Collections;
+using System.IO;
+using System.Reflection;
+using System.Runtime.Serialization.Formatters.Binary;
+using System.Xml;
+using System.Xml.Schema;
+
+using QName = System.Xml.XmlQualifiedName;
+
+namespace System.Runtime.Serialization
+{
+	internal class XmlFormatterDeserializer
+	{
+		KnownTypeCollection types;
+		IDataContractSurrogate surrogate;
+
+		public static object Deserialize (XmlReader reader, Type type,
+			KnownTypeCollection knownTypes, IDataContractSurrogate surrogate,
+			string name, string Namespace, bool verifyObjectName)
+		{
+			reader.MoveToContent();
+			if (verifyObjectName)
+				Verify (knownTypes, type, name, Namespace, reader);
+			return new XmlFormatterDeserializer (knownTypes, surrogate).Deserialize (type, reader);
+		}
+
+		// Verify the top element name and namespace.
+		private static void Verify (KnownTypeCollection knownTypes, Type type, string name, string Namespace, XmlReader reader)
+		{
+			QName graph_qname = new QName (reader.Name, reader.NamespaceURI);
+			if (graph_qname.Name == name && graph_qname.Namespace == Namespace)
+				return;
+
+			// <BClass .. i:type="EClass" >..</BClass>
+			// Expecting type EClass : allowed
+			// See test Serialize1b, and Serialize1c (for
+			// negative cases)
+
+			// Run through inheritance heirarchy .. 
+			for (Type baseType = type; baseType != null; baseType = baseType.BaseType)
+				if (knownTypes.GetQName (baseType) == graph_qname)
+					return;
+
+			QName typeQName = knownTypes.GetQName (type);
+			throw new SerializationException (String.Format (
+				"Expecting element '{0}' from namespace '{1}'. Encountered 'Element' with name '{2}', namespace '{3}'",
+				typeQName.Name, typeQName.Namespace, graph_qname.Name, graph_qname.Namespace));
+		}
+
+		private XmlFormatterDeserializer (
+			KnownTypeCollection knownTypes,
+			IDataContractSurrogate surrogate)
+		{
+			this.types = knownTypes;
+			this.surrogate = surrogate;
+		}
+
+		// At the beginning phase, we still have to instantiate a new
+		// target object even if fromContent is true.
+		public object Deserialize (Type type, XmlReader reader)
+		{
+			QName graph_qname = types.GetQName (type);
+			string itype = reader.GetAttribute ("type", XmlSchema.InstanceNamespace);
+			if (itype != null) {
+				string[] parts = itype.Split (':');
+				if (parts.Length > 1)
+					graph_qname = new QName (parts [1], reader.LookupNamespace (reader.NameTable.Get (parts[0])));
+				else
+					graph_qname = new QName (itype, reader.NamespaceURI);
+			}
+
+			bool isNil = reader.GetAttribute ("nil", XmlSchema.InstanceNamespace) == "true";
+			reader.ReadStartElement ();
+			if (isNil)
+				if (!type.IsValueType)
+					return null;
+				else if (type.IsGenericType && type.GetGenericTypeDefinition () == typeof (Nullable<>))
+					return null;
+				else 
+					throw new SerializationException (String.Format ("Value type {0} cannot be null.", type));
+
+			object res = DeserializeContent (graph_qname, type, reader);
+			if (reader.NodeType == XmlNodeType.EndElement)
+				reader.ReadEndElement ();
+			else if (reader.NodeType != XmlNodeType.None)
+				throw new SerializationException (String.Format ("Deserializing type '{3}'. Expecting state 'EndElement'. Encountered state '{0}' with name '{1}' with namespace '{2}'.", reader.NodeType, reader.Name, reader.NamespaceURI, type.FullName));
+			return res;
+		}
+
+		object DeserializeContent (QName name, Type type, XmlReader reader)
+		{
+			if (KnownTypeCollection.IsPrimitiveType (name)) {
+				string value;
+				if (reader.NodeType != XmlNodeType.Text)
+					if (type.IsValueType)
+						return Activator.CreateInstance (type);
+					else
+						// FIXME: Workaround for creating empty objects of the correct type.
+						value = String.Empty;
+				else
+					value = reader.ReadContentAsString ();
+				return KnownTypeCollection.PredefinedTypeStringToObject (value, name.Name, reader);
+			}
+
+			SerializationMap map = types.FindUserMap (name);
+			if (map == null)
+				throw new SerializationException (String.Format ("Unknown type {0} is used for DataContract. Any derived types of a data contract or a data member should be added to KnownTypes.", type));
+
+			return map.DeserializeContent (reader, this);
+		}
+	}
+}
+#endif

+ 140 - 0
mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlFormatterSerializer.cs

@@ -0,0 +1,140 @@
+//
+// XmlFormatterSerializer.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+using System;
+using System.Collections;
+using System.IO;
+using System.Reflection;
+using System.Runtime.Serialization.Formatters.Binary;
+using System.Xml;
+using System.Xml.Schema;
+
+using QName = System.Xml.XmlQualifiedName;
+
+namespace System.Runtime.Serialization
+{
+	internal class XmlFormatterSerializer
+	{
+		XmlDictionaryWriter writer;
+		object graph;
+		KnownTypeCollection types;
+		
+		bool save_id;
+		bool ignore_unknown;
+		IDataContractSurrogate surrogate;
+		int max_items;
+
+		ArrayList objects = new ArrayList ();
+
+		public static void Serialize (XmlDictionaryWriter writer, object graph,
+			KnownTypeCollection types,
+			bool ignoreUnknown, int maxItems, string root_ns)
+		{
+			new XmlFormatterSerializer (writer, types, ignoreUnknown, maxItems, root_ns)
+				.Serialize (graph != null ? graph.GetType () : null, graph);
+		}
+
+		public XmlFormatterSerializer (XmlDictionaryWriter writer,
+			KnownTypeCollection types,
+			bool ignoreUnknown, int maxItems, string root_ns)
+		{
+			this.writer = writer;
+			this.types = types;
+			ignore_unknown = ignoreUnknown;
+			max_items = maxItems;
+		}
+
+		public XmlDictionaryWriter Writer {
+			get { return writer; }
+		}
+
+		public void Serialize (Type type, object graph)
+		{
+			if (graph == null)
+				writer.WriteAttributeString ("nil", XmlSchema.InstanceNamespace, "true");
+			else {
+				Type actualType = graph.GetType ();
+				QName predef = KnownTypeCollection.GetPredefinedTypeName (actualType);
+				if (predef != QName.Empty)
+					SerializePrimitive (type, graph, predef);
+				else
+					SerializeNonPrimitive (type, graph);
+			}
+		}
+
+		public void SerializePrimitive (Type type, object graph, QName qname)
+		{
+//			writer.WriteStartAttribute ("type", XmlSchema.InstanceNamespace);
+//			writer.WriteQualifiedName (qname.Name, qname.Namespace);
+//			writer.WriteEndAttribute ();
+			writer.WriteString (KnownTypeCollection.PredefinedTypeObjectToString (graph));
+		}
+
+		public void WriteStartElement (string rootName, string rootNamespace, string currentNamespace)
+		{
+			writer.WriteStartElement (rootName, rootNamespace);
+			if (!string.IsNullOrEmpty (currentNamespace) && currentNamespace != rootNamespace)
+				writer.WriteXmlnsAttribute (null, currentNamespace);
+		}
+
+		public void WriteEndElement ()
+		{
+			writer.WriteEndElement ();
+		}
+
+		private void Write_i_type (QName qname)
+		{
+			writer.WriteStartAttribute ("type", XmlSchema.InstanceNamespace);
+			writer.WriteQualifiedName (qname.Name, qname.Namespace);
+			writer.WriteEndAttribute ();
+		}
+
+		public void SerializeNonPrimitive (Type type, object graph)
+		{
+			if (objects.Contains (graph))
+				throw new SerializationException (String.Format ("Circular reference of an object in the object graph was found: '{0}' of type {1}", graph, graph.GetType ()));
+			objects.Add (graph);
+
+			Type actualType = graph.GetType ();
+
+			SerializationMap map = types.FindUserMap (actualType);
+			if (map == null) {
+				/* Unknown actual type */
+				types.Add (actualType);
+				map = types.FindUserMap (actualType);
+//				throw new InvalidDataContractException (String.Format ("Type {0} has neither Serializable nor DataContract attributes.", type));
+			}
+
+			if (type != actualType)
+				Write_i_type (map.XmlName);
+
+			map.Serialize (graph, this);
+		}
+	}
+}
+#endif

+ 136 - 0
mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlObjectSerializer.cs

@@ -0,0 +1,136 @@
+//
+// XmlObjectSerializer.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+using System;
+using System.Collections;
+using System.IO;
+using System.Reflection;
+using System.Runtime.Serialization.Formatters.Binary;
+using System.Xml;
+using System.Xml.Schema;
+
+using QName = System.Xml.XmlQualifiedName;
+
+namespace System.Runtime.Serialization
+{
+	public abstract class XmlObjectSerializer
+	{
+		internal const string DefaultNamespaceBase =
+			"http://schemas.datacontract.org/2004/07/";
+
+		// This is only for compatible mode.
+		IDataContractSurrogate surrogate;
+
+		SerializationBinder binder;
+		ISurrogateSelector selector;
+
+		int max_items = 0x10000; // FIXME: could be from config.
+
+		protected XmlObjectSerializer ()
+		{
+		}
+
+		public virtual bool IsStartObject (XmlReader reader)
+		{
+			return IsStartObject (XmlDictionaryReader.CreateDictionaryReader (reader));
+		}
+
+		public abstract bool IsStartObject (XmlDictionaryReader reader);
+
+		public virtual object ReadObject (Stream stream)
+		{
+			return ReadObject (XmlReader.Create (stream));
+		}
+
+		public virtual object ReadObject (XmlReader reader)
+		{
+			return ReadObject (XmlDictionaryReader.CreateDictionaryReader (reader));
+		}
+
+		public virtual object ReadObject (XmlDictionaryReader reader)
+		{
+			return ReadObject (reader, true);
+		}
+
+		public virtual object ReadObject (XmlReader reader, bool readContentOnly)
+		{
+			return ReadObject (
+				XmlDictionaryReader.CreateDictionaryReader (reader),
+				readContentOnly);
+		}
+
+		[MonoTODO]
+		public abstract object ReadObject (XmlDictionaryReader reader, bool readContentOnly);
+
+		public virtual void WriteObject (Stream stream, object graph)
+		{
+			using (XmlWriter xw = XmlDictionaryWriter.CreateTextWriter (stream)) {
+				WriteObject (xw, graph);
+			}
+		}
+
+		public virtual void WriteObject (XmlWriter writer, object graph)
+		{
+			WriteObject (XmlDictionaryWriter.CreateDictionaryWriter (writer), graph);
+		}
+
+		public virtual void WriteStartObject (XmlWriter writer, object graph)
+		{
+			WriteStartObject (XmlDictionaryWriter.CreateDictionaryWriter (writer), graph);
+		}
+
+		public virtual void WriteObject (XmlDictionaryWriter writer, object graph)
+		{
+			WriteStartObject (writer, graph);
+			WriteObjectContent (writer, graph);
+			WriteEndObject (writer);
+		}
+
+		public abstract void WriteStartObject (
+			XmlDictionaryWriter writer, object graph);
+
+		public virtual void WriteObjectContent (XmlWriter writer, object graph)
+		{
+			WriteObjectContent (
+				XmlDictionaryWriter.CreateDictionaryWriter (writer),
+				graph);
+		}
+
+		public abstract void WriteObjectContent (
+			XmlDictionaryWriter writer, object graph);
+
+		public virtual void WriteEndObject (XmlWriter writer)
+		{
+			WriteEndObject (XmlDictionaryWriter.CreateDictionaryWriter (writer));
+		}
+
+		public abstract void WriteEndObject (
+			XmlDictionaryWriter writer);
+	}
+}
+#endif

+ 77 - 0
mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlSerializableServices.cs

@@ -0,0 +1,77 @@
+//
+// XmlSerializableServices.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Xml;
+using System.Xml.Schema;
+
+using QName = System.Xml.XmlQualifiedName;
+
+namespace System.Runtime.Serialization
+{
+	public static class XmlSerializableServices
+	{
+		static Dictionary<QName, XmlSchemaSet> defaultSchemas
+			= new Dictionary<QName, XmlSchemaSet> ();
+
+		[MonoTODO]
+		public static void AddDefaultSchema (
+			XmlSchemaSet schemas,
+			QName typeQName)
+		{
+			throw new NotImplementedException ();
+		}
+
+		public static XmlNode [] ReadNodes (XmlReader xmlReader)
+		{
+			if (xmlReader.NodeType != XmlNodeType.Element || xmlReader.IsEmptyElement)
+				return new XmlNode [0];
+
+			int depth = xmlReader.Depth;
+			xmlReader.Read ();
+			if (xmlReader.NodeType == XmlNodeType.EndElement)
+				return new XmlNode [0];
+
+			List<XmlNode> al = new List<XmlNode> ();
+			XmlDocument doc = new XmlDocument ();
+			while (xmlReader.Depth > depth & !xmlReader.EOF)
+				al.Add (doc.ReadNode (xmlReader));
+			return al.ToArray ();
+		}
+
+		public static void WriteNodes (XmlWriter xmlWriter,
+			XmlNode [] nodes)
+		{
+			foreach (XmlNode n in nodes)
+				n.WriteTo (xmlWriter);
+		}
+	}
+}
+#endif

+ 180 - 0
mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XsdDataContractExporter.cs

@@ -0,0 +1,180 @@
+//
+// XsdDataContractExporter.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//	Ankit Jain <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Reflection;
+using System.Xml;
+using System.Xml.Schema;
+
+using QName = System.Xml.XmlQualifiedName;
+
+namespace System.Runtime.Serialization
+{
+	public class XsdDataContractExporter
+	{
+		ExportOptions options;
+		KnownTypeCollection known_types;
+		XmlSchemaSet schemas;
+		Dictionary<QName, XmlSchemaType> generated_schema_types;
+
+		static XmlSchema mstypes_schema;
+
+		public XsdDataContractExporter ()
+		{
+		}
+
+		public XsdDataContractExporter (XmlSchemaSet schemas)
+		{
+			this.schemas = schemas;
+		}
+
+		public XmlSchemaSet Schemas {
+			get { 
+				if (schemas == null) {
+					schemas = new XmlSchemaSet ();
+					schemas.Add (MSTypesSchema);
+				}
+				return schemas;
+			}
+		}
+
+		public ExportOptions Options {
+			get { return options; }
+			set { options = value; }
+		}
+
+		public bool CanExport (ICollection<Type> types)
+		{
+			foreach (Type t in types)
+				if (!CanExport (t))
+					return false;
+			return true;
+		}
+
+		public bool CanExport (ICollection<Assembly> assemblies)
+		{
+			foreach (Assembly a in assemblies)
+				foreach (Module m in a.GetModules ())
+					foreach (Type t in m.GetTypes ())
+						if (!CanExport (t))
+							return false;
+			return true;
+		}
+
+		public bool CanExport (Type type)
+		{
+			return !KnownTypes.GetQName (type).IsEmpty;
+		}
+
+		public void Export (ICollection<Type> types)
+		{
+			foreach (Type t in types)
+				Export (t);
+		}
+
+		public void Export (ICollection<Assembly> assemblies)
+		{
+			foreach (Assembly a in assemblies)
+				foreach (Module m in a.GetModules ())
+					foreach (Type t in m.GetTypes ())
+						Export (t);
+		}
+
+		[MonoTODO]
+		public void Export (Type type)
+		{
+			//FIXME: Which types to exclude?
+			KnownTypes.Add (type);
+			SerializationMap map = KnownTypes.FindUserMap (type);
+			if (map == null)
+				return;
+
+			map.GetSchemaType (Schemas, GeneratedTypes);
+			Schemas.Compile ();
+		}
+
+		[MonoTODO]
+		public XmlQualifiedName GetRootElementName (Type type)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public XmlSchemaType GetSchemaType (Type type)
+		{
+			SerializationMap map = KnownTypes.FindUserMap (type);
+			if (map == null)
+				return null;
+
+			return map.GetSchemaType (Schemas, GeneratedTypes);
+		}
+
+		public XmlQualifiedName GetSchemaTypeName (Type type)
+		{
+			QName qname = KnownTypes.GetQName (type);
+			if (qname.Namespace == KnownTypeCollection.MSSimpleNamespace)
+				//primitive type, mapping to XmlSchema ns
+				return new QName (qname.Name, XmlSchema.Namespace);
+
+			return qname;
+		}
+
+		KnownTypeCollection KnownTypes {
+			get {
+				if (known_types == null)
+					known_types = new KnownTypeCollection ();
+				return known_types;
+			}
+		}
+
+		Dictionary<QName, XmlSchemaType> GeneratedTypes {
+			get {
+				if (generated_schema_types == null)
+					generated_schema_types = new Dictionary<QName, XmlSchemaType> ();
+				return generated_schema_types;
+			}
+		}
+		
+		static XmlSchema MSTypesSchema {
+			get {
+				if (mstypes_schema == null) {
+					Assembly a = Assembly.GetCallingAssembly ();
+					Stream s = a.GetManifestResourceStream ("mstypes.schema");
+					mstypes_schema= XmlSchema.Read (s, null);
+				}
+				return mstypes_schema;
+			}
+		}
+
+
+	}
+}
+#endif

+ 325 - 0
mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XsdDataContractImporter.cs

@@ -0,0 +1,325 @@
+//
+// XsdDataContractImporter.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+using System;
+using System.CodeDom;
+using System.Collections.Generic;
+using System.IO;
+using System.Xml;
+using System.Xml.Schema;
+using System.Xml.Serialization;
+
+using QName = System.Xml.XmlQualifiedName;
+
+namespace System.Runtime.Serialization
+{
+	public class XsdDataContractImporter
+	{
+		ImportOptions options;
+		CodeCompileUnit ccu;
+		Dictionary<QName, QName> imported_names = new Dictionary<QName, QName> ();
+
+		public XsdDataContractImporter ()
+			: this (null)
+		{
+		}
+
+		public XsdDataContractImporter (CodeCompileUnit ccu)
+		{
+			this.ccu = ccu;
+			this.imported_names = new Dictionary<QName, QName> ();
+		}
+
+		public CodeCompileUnit CodeCompileUnit {
+			get { 
+				if (ccu == null)
+					ccu = new CodeCompileUnit ();
+			
+				return ccu; 
+			}
+		}
+
+		public ImportOptions Options {
+			get { return options; }
+			set { options = value; }
+		}
+
+		[MonoTODO]
+		public ICollection<CodeTypeReference> GetKnownTypeReferences (QName typeName)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public CodeTypeReference GetCodeTypeReference (QName typeName)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public CodeTypeReference GetCodeTypeReference (QName typeName,
+			XmlSchemaElement element)
+		{
+			throw new NotImplementedException ();
+		}
+
+		public bool CanImport (XmlSchemaSet schemas)
+		{
+			foreach (XmlSchemaElement e in schemas.GlobalElements)
+				if (!CanImport (schemas, e))
+					return false;
+			return true;
+		}
+
+		public bool CanImport (XmlSchemaSet schemas,
+			ICollection<QName> typeNames)
+		{
+			foreach (QName name in typeNames)
+				if (!CanImport (schemas, name))
+					return false;
+			return true;
+		}
+
+		public bool CanImport (XmlSchemaSet schemas, QName name)
+		{
+			return CanImport (schemas,
+				(XmlSchemaElement) schemas.GlobalElements [name]);
+		}
+
+		[MonoTODO]
+		public bool CanImport (XmlSchemaSet schemas, XmlSchemaElement element)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public void Import (XmlSchemaSet schemas)
+		{
+			if (schemas == null)
+				throw new ArgumentNullException ("schemas");
+
+			schemas.Compile ();
+			foreach (XmlSchemaElement e in schemas.GlobalElements.Values)
+				ImportInternal (schemas, e.QualifiedName);
+		}
+
+		public void Import (XmlSchemaSet schemas,
+			ICollection<QName> typeNames)
+		{
+			if (schemas == null)
+				throw new ArgumentNullException ("schemas");
+			if (typeNames == null)
+				throw new ArgumentNullException ("typeNames");
+
+			schemas.Compile ();
+			foreach (QName name in typeNames)
+				ImportInternal (schemas, name);
+		}
+
+		public void Import (XmlSchemaSet schemas, QName name)
+		{
+			if (schemas == null)
+				throw new ArgumentNullException ("schemas");
+			if (name == null)
+				throw new ArgumentNullException ("name");
+
+			schemas.Compile ();
+			
+			if (schemas.GlobalTypes [name] == null)
+				throw new InvalidDataContractException (String.Format (
+						"Type with name '{0}' not found in schema with namespace '{1}'", 
+						name.Name, name.Namespace));
+
+			ImportInternal (schemas, name);
+		}
+
+		[MonoTODO]
+		public QName Import (XmlSchemaSet schemas, XmlSchemaElement element)
+		{
+			if (schemas == null)
+				throw new ArgumentNullException ("schemas");
+			if (element == null)
+				throw new ArgumentNullException ("element");
+
+			schemas.Compile ();
+			QName ret = ImportInternal (schemas, element.QualifiedName);
+
+			foreach (QName qname in schemas.GlobalTypes.Names)
+				ImportInternal (schemas, qname);
+
+			return ret;
+		}
+
+		private QName ImportInternal (XmlSchemaSet schemas, QName qname)
+		{
+			if (qname.Namespace == KnownTypeCollection.MSSimpleNamespace)
+				//Primitive type
+				return qname;
+
+			if (imported_names.ContainsKey (qname))
+				return imported_names [qname];
+
+			XmlSchemas xss = new XmlSchemas ();
+			foreach (XmlSchema schema in schemas.Schemas ())
+				xss.Add (schema);
+			
+			XmlSchemaImporter xsi = new XmlSchemaImporter (xss);
+			XmlTypeMapping xtm = xsi.ImportTypeMapping (qname);
+
+			ImportFromTypeMapping (xtm);
+			return qname;
+		}
+
+		//Duplicate code from ServiceContractGenerator.ExportDataContract
+		private void ImportFromTypeMapping (XmlTypeMapping mapping)
+		{
+			if (mapping == null)
+				return;
+
+			QName qname = new QName (mapping.TypeName, mapping.Namespace);
+			if (imported_names.ContainsKey (qname))
+				return;
+
+			CodeNamespace cns = new CodeNamespace ();
+
+			XmlCodeExporter xce = new XmlCodeExporter (cns);
+			xce.ExportTypeMapping (mapping);
+
+			List <CodeTypeDeclaration> to_remove = new List <CodeTypeDeclaration> ();
+			
+			//Process the types just generated
+			//FIXME: Iterate and assign the types to correct namespaces
+			//At the end, add all those namespaces to the ccu
+			foreach (CodeTypeDeclaration type in cns.Types) {
+				string ns = GetNamespace (type);
+				if (ns == null)
+					//FIXME: do what here?
+					continue;
+
+				QName type_name = new QName (type.Name, ns);
+				if (imported_names.ContainsKey (type_name)) {
+					//Type got reemitted, so remove it!
+					to_remove.Add (type);
+					continue;
+				}
+
+				imported_names [type_name] = type_name;
+
+				type.Comments.Clear ();
+				//Custom Attributes
+				type.CustomAttributes.Clear ();
+
+				if (type.IsEnum)
+					//FIXME: Add test case for this
+					continue;
+	
+				type.CustomAttributes.Add (
+					new CodeAttributeDeclaration (
+						new CodeTypeReference ("System.CodeDom.Compiler.GeneratedCodeAttribute"),
+						new CodeAttributeArgument (new CodePrimitiveExpression ("System.Runtime.Serialization")),
+						new CodeAttributeArgument (new CodePrimitiveExpression ("3.0.0.0"))));
+			
+				type.CustomAttributes.Add (
+					new CodeAttributeDeclaration (
+						new CodeTypeReference ("System.Runtime.Serialization.DataContractAttribute")));
+
+				//BaseType and interface
+				type.BaseTypes.Add (new CodeTypeReference (typeof (object)));
+				type.BaseTypes.Add (new CodeTypeReference ("System.Runtime.Serialization.IExtensibleDataObject"));
+
+				foreach (CodeTypeMember mbr in type.Members) {
+					CodeMemberProperty p = mbr as CodeMemberProperty;
+					if (p == null)
+						continue;
+
+					if ((p.Attributes & MemberAttributes.Public) == MemberAttributes.Public) {
+						//FIXME: Clear all attributes or only XmlElementAttribute?
+						p.CustomAttributes.Clear ();
+						p.CustomAttributes.Add (new CodeAttributeDeclaration (
+							new CodeTypeReference ("System.Runtime.Serialization.DataMemberAttribute")));
+
+						p.Comments.Clear ();
+					}
+				}
+
+				//Fields
+				CodeMemberField field = new CodeMemberField (
+					new CodeTypeReference ("System.Runtime.Serialization.ExtensionDataObject"),
+					"extensionDataField");
+				field.Attributes = MemberAttributes.Private | MemberAttributes.Final;
+				type.Members.Add (field);
+
+				//Property 
+				CodeMemberProperty prop = new CodeMemberProperty ();
+				prop.Type = new CodeTypeReference ("System.Runtime.Serialization.ExtensionDataObject");
+				prop.Name = "ExtensionData";
+				prop.Attributes = MemberAttributes.Public | MemberAttributes.Final;
+
+				//Get
+				prop.GetStatements.Add (new CodeMethodReturnStatement (
+					new CodeFieldReferenceExpression (
+					new CodeThisReferenceExpression (),
+					"extensionDataField")));
+
+				//Set
+				prop.SetStatements.Add (new CodeAssignStatement (
+					new CodeFieldReferenceExpression (
+					new CodeThisReferenceExpression (),
+					"extensionDataField"),
+					new CodePropertySetValueReferenceExpression ()));
+
+				type.Members.Add (prop);
+			}
+
+			foreach (CodeTypeDeclaration type in to_remove)
+				cns.Types.Remove (type);
+
+			CodeCompileUnit.Namespaces.Add (cns);
+		}
+
+		private string GetNamespace (CodeTypeDeclaration type)
+		{
+			foreach (CodeAttributeDeclaration attr in type.CustomAttributes) {
+				if (attr.Name == "System.Xml.Serialization.XmlTypeAttribute" ||
+					attr.Name == "System.Xml.Serialization.XmlRootAttribute") {
+
+					foreach (CodeAttributeArgument arg in attr.Arguments)
+						if (arg.Name == "Namespace")
+							return ((CodePrimitiveExpression)arg.Value).Value as string;
+
+					//Could not find Namespace arg!
+					return null;	
+				}
+			}
+			
+			return null;
+		}
+
+	}
+}
+#endif

+ 17 - 0
mcs/class/System.Runtime.Serialization/System.Runtime.Serialization_test.dll.sources

@@ -0,0 +1,17 @@
+System.Runtime.Serialization/DataContractSerializerTest_FrameworkTypes.cs
+System.Runtime.Serialization/DataContractSerializerTest_FrameworkTypes_mscorlib.cs
+System.Runtime.Serialization/DataContractSerializerTest_FrameworkTypes_System.cs
+System.Runtime.Serialization/DataContractSerializerTest_FrameworkTypes_System.Data.cs
+System.Runtime.Serialization/XmlObjectSerializerTest.cs
+System.Runtime.Serialization/XsdDataContractExporterTest.cs
+System.Runtime.Serialization/XsdDataContractImporterTest.cs
+System.Xml/UniqueIdTest.cs
+System.Xml/XmlBinaryDictionaryReaderTest.cs
+System.Xml/XmlBinaryDictionaryWriterTest.cs
+System.Xml/XmlBinaryWriterSessionTest.cs
+System.Xml/XmlDictionaryReaderAbstractTest.cs
+System.Xml/XmlDictionaryReaderQuotasTest.cs
+System.Xml/XmlDictionaryTest.cs
+System.Xml/XmlSimpleDictionaryWriterTest.cs
+System.Runtime.Serialization/AttributesTest.cs
+XmlComparer.cs

+ 365 - 0
mcs/class/System.Runtime.Serialization/System.Xml/ChangeLog

@@ -0,0 +1,365 @@
+2008-04-10  Eyal Alaluf <[email protected]>
+
+	* XmlBinaryDictionaryWriter.cs: WriteXmlnsAttribute generates a prefix
+	  when given a null prefix.
+
+2008-03-22  Atsushi Enomoto  <[email protected]>
+
+	* XmlBinaryDictionaryReader.cs :
+	  - It didn't clean namespaces up during Read().
+	  - Non-typed attribute nodes should be allowed in get_Value().
+	  - Fixed wrong namespace scope push.
+
+2008-02-27 Eyal Alaluf <[email protected]>
+
+	* XmlBinaryDictionaryReader.cs: Handle compilation warnings.
+	* XmlSimpleDictionaryReader.cs: Added onClose handling.
+	* XmlDictionaryReader.cs: Simple implementation of CreateTextReader.
+
+2008-02-08  Atsushi Enomoto  <[email protected]>
+
+	* XmlDictionaryWriter.cs : Even with UTF8 (marked) .net does not
+	  output BOMs, so use always unmarked utf8 for any UTF8 encodings.
+
+2008-02-08  Atsushi Enomoto  <[email protected]>
+
+	* XmlDictionaryWriter.cs : Since it does not support XML declaration
+	  its encoding is limited to utf16 and utf8. Null argument check.
+
+2007-11-27  Atsushi Enomoto  <[email protected]>
+
+	* XmlDictionaryWriter.cs : WriteNode() is override, not new.
+
+2007-07-27  Atsushi Enomoto  <[email protected]>
+
+	* XmlDictionaryWriter.cs : store Depth for dummy prefix output.
+	  WriteXmlnsAttribute() writes dummy prefix when null prefix is given.
+	* XmlSimpleDictionaryWriter.cs, XmlBinaryDictionaryWriter.cs :
+	  increment Depth on WriteStartElement() and decrement it on
+	  WriteEndElement(). They don't have to be complete, just fine as
+	  long as it correctly creates a dummy.
+
+2007-04-02  Atsushi Enomoto  <[email protected]>
+
+	* XmlBinaryFormat.cs : added Base64Fixed (0xA0).
+	* XmlBinaryDictionaryReader.cs : support 0xA0 type above.
+	  ReadInt() refactoring. Handle float and double value types.
+
+2007-03-30  Atsushi Enomoto  <[email protected]>
+
+	* XmlBinaryDictionaryReader.cs :
+	  implemented some ReadContentAs[Type]() methods.
+	* XmlDictionaryReader.cs :
+	  Added Read[[Element]ContentAs]String() implementations.
+	* XmlDictionaryReaderAutoGen.cs : regenerated
+
+2007-03-20  Atsushi Enomoto  <[email protected]>
+
+	* XmlDictionaryReader.cs : simply return false for
+	  TryGet[Base64|Array]Length().
+	* XmlBinaryDictionaryReader.cs : Value string should be pupulated
+	  for typed value nodes.
+
+2007-03-19  Atsushi Enomoto  <[email protected]>
+
+	* XmlDictionaryReader.cs : more ongoing updates (valuetype support,
+	  key support updates, ReadElementContentAsBase64).
+
+2007-03-19  Atsushi Enomoto  <[email protected]>
+
+	* XmlBinaryFormat.cs, XmlBinaryDictionaryWriter.cs :
+	  support following operators; 0x80 (integer 0), 0x82 (integer 1) and
+	  0xAE (UniqueId which is created from Guid).
+	  Little fix for length output.
+
+2007-03-16  Atsushi Enomoto  <[email protected]>
+
+	* XmlDictionaryReader.cs : fix infinite loop.
+
+2007-03-16  Atsushi Enomoto  <[email protected]>
+
+	* XmlDictionaryReader.cs : added couple of missing methods.
+
+2007-03-16  Atsushi Enomoto  <[email protected]>
+
+	* XmlDictionaryReaderAutoGen.cs : regenerated.
+
+2007-03-16  Atsushi Enomoto  <[email protected]>
+
+	* XmlBinaryDictionaryReader.cs : ongoing updates to the 3.0 RTM
+	  format.
+
+2007-03-16  Atsushi Enomoto  <[email protected]>
+
+	* XmlBinaryDictionaryWriter.cs : for XmlWriterBinarySession lookup,
+	  internal dictionary lookup should be string-based, since otherwise
+	  it will never return correct dictionary string stored when the
+	  dictionary string is from another dictionary.
+	* XmlBinaryWriterSession.cs :
+	  TryLookup() is now based on string value comparison.
+	  Reverted internal dictionary to int->XmlDictionaryString form,
+	  as I don't use TryGetValue() anymore.
+
+2007-03-16  Atsushi Enomoto  <[email protected]>
+
+	* XmlBinaryDictionaryWriter.cs : WriteValue(Decimal) is working now.
+
+2007-03-15  Atsushi Enomoto  <[email protected]>
+
+	* XmlBinaryFormat.cs : new file, collection of constants.
+	* XmlBinaryDictionaryWriter.cs :
+	  Stream->BinaryWriter. Support for WriteValue() for almost all
+	  types.
+
+2007-03-15  Atsushi Enomoto  <[email protected]>
+
+	* XmlDictionaryWriter.cs : removed couple of MonoTODOs.
+
+2007-03-15  Atsushi Enomoto  <[email protected]>
+
+	* XmlBinaryDictionaryWriter.cs : more couple of fixes (typed value
+	  support and fixes, more element/attribute namespace fixes etc.).
+
+2007-03-15  Atsushi Enomoto  <[email protected]>
+
+	* XmlBinaryDictionaryWriter.cs : fixed Base64 operation byte.
+	  For comment node there is no corresponding combined EndElement
+	  operation, so don't try to combine it.
+	  Don't output xmlns and xml namespaces.
+
+2007-03-15  Atsushi Enomoto  <[email protected]>
+
+	* XmlBinaryDictionaryWriter.cs : fixed couple of dictionary string
+	  issues (on lookup and index output).
+	* XmlBinaryWriterSession.cs : added internal TryLookup(). Changed
+	  internal structure to have dictionary string as a key.
+
+2007-03-15  Atsushi Enomoto  <[email protected]>
+
+	* XmlBinaryDictionaryWriter.cs : new prefix population is needed
+	  in this class too.
+
+2007-03-15  Atsushi Enomoto  <[email protected]>
+
+	* XmlBinaryDictionaryWriter.cs : more WriteEndAttribute() is needed.
+	  Remove wrong namespaceUri index output. Fixed attribute operation.
+
+2007-03-15  Atsushi Enomoto  <[email protected]>
+
+	* XmlBinaryDictionaryWriter.cs : output attribute value.
+
+2007-03-15  Atsushi Enomoto  <[email protected]>
+
+	* XmlBinaryDictionaryWriter.cs : for binary output format requirement,
+	  every content must be buffered once and wait for next operation so
+	  that if the content is one of the content sequence or not. This is
+	  almost silly, but that is what Microsoft wanted to do.
+
+2007-03-15  Atsushi Enomoto  <[email protected]>
+
+	* XmlBinaryDictionaryWriter.cs : couple of namespaces processing fix.
+
+2007-03-15  Atsushi Enomoto  <[email protected]>
+
+	* XmlDictionaryWriter.cs : WriteAttributeString and WriteStartElement
+	  should also delegate to dictionary-string based methods.
+	* XmlBinaryDictionaryWriter.cs : ongoing reimplementation as it was
+	  based on pretty old design as well as pretty old XmlTextWriter.
+
+2007-03-14  Atsushi Enomoto  <[email protected]>
+
+	* XmlBinaryWriterSession.cs : implemented.
+	* XmlBinaryDictionaryWriter.cs : a bunch of updates.
+
+2007-03-14  Atsushi Enomoto  <[email protected]>
+
+	* UniqueId.cs : hacky Equals() implementation.
+	* XmlDictionaryReaderQuotas.cs : removed Default and fixed Max.
+	* XmlSimpleDictionaryWriter.cs : in .NET 3.0 RTM, it is supported.
+	* XmlDictionaryWriter.cs : WriteStartElement(XmlDictionaryString,
+	  XmlDictionaryString) should call WriteStartElement(string,
+	  XmlDictionaryString,XmlDictionaryString) since because only the
+	  latter is overridable and possible to provide dictionary string.
+
+2007-03-09  Atsushi Enomoto  <[email protected]>
+
+	* XmlDictionaryReader.cs : make it partial. Fill Quotas when requested.
+	* XmlDictionaryReaderAutoGen.cs : added autogenerated array reader
+	  methods.
+	* XmlDictionaryWriter.cs : make it partial.
+	* XmlDictionaryWruterAutoGen.cs : added autogenerated array writer
+	  methods.
+
+2006-10-05  Atsushi Enomoto  <[email protected]>
+
+	* XmlBinaryDictionaryReader.cs, XmlSimpleDictionaryReader.cs :
+	  implement IXmlNamespaceResolver.
+
+2006-07-31  Ankit Jain  <[email protected]>
+
+	* UniqueId.cs (.ctor): (string overload) Implement.
+	(ToString): Prepend "urn:uuid:" instead of "uuid-".
+
+2006-07-31  Atsushi Enomoto  <[email protected]>
+
+	* UniqueId.cs : some implementation.
+
+2006-07-04  Atsushi Enomoto  <[email protected]>
+
+	* XmlDictionaryWriter.cs, XmlSimpleDictionaryWriter.cs,
+	  XmlDictionaryReaderQuotas.cs : June CTP API update.
+
+2006-07-04  Atsushi Enomoto  <[email protected]>
+
+	* XmlBinaryDictionaryReader.cs, IStreamProvider.cs,
+	  XmlSimpleDictionaryReader.cs, IXmlMtomReaderInitializer.cs,
+	  XmlBinaryWriterSession.cs, IXmlUTF8ReaderInitializer.cs,
+	  IXmlMtomWriterInitializer.cs, XmlDictionaryReader.cs :
+	  June CTP API updates.
+
+2006-01-17  Atsushi Enomoto  <[email protected]>
+
+	* XmlShimWriter.cs : deleted.
+	* XmlBinaryDictionaryWriter.cs, XmlSimpleDictionaryWriter.cs :
+	  WriteProcessingInstruction() throws InvalidOperationException.
+
+2005-11-28  Atsushi Enomoto  <[email protected]>
+
+	* XmlDictionaryReader.cs, XmlBinaryDictionaryWriter.cs,
+	  XmlDictionary.cs, XmlDictionaryWriter.cs, XmlC14NWriter.cs :
+	  several API fixes to Nov. CTP.
+
+2005-11-03  Atsushi Enomoto  <[email protected]>
+
+	* XmlDictionaryReader.cs : CreateMtomReader() stubs.
+
+2005-10-24  Atsushi Enomoto  <[email protected]>
+
+	* XmlBinaryDictionaryWriter.cs : use saved xml_lang and xml_space for
+	  those corresponding properties (they bork at the declaring element).
+
+2005-10-24  Atsushi Enomoto  <[email protected]>
+
+	* UniqueId.cs : it does not compile.
+
+2005-10-23  Duncan Mak  <[email protected]>
+
+	* UniqueId.cs (.ctor): Implement some overloads by chaining it to
+	other Unimplemented ones.
+	(operator ==, operator !=): Implemented using the Equals method.
+	(Equals, TryGetGuid): Well, at least figure the false case....
+
+2005-10-23  Atsushi Enomoto  <[email protected]>
+
+	* XmlDictionary.cs : fixed type of Empty.
+	* XmlDictionaryReaderQuotas.cs : Default and Max were not readonly.
+
+2005-10-05  Atsushi Enomoto  <[email protected]>
+
+	* XmlBinaryDictionaryReader.cs : and it can GetContext().
+
+2005-10-05  Atsushi Enomoto  <[email protected]>
+
+	* XmlBinaryDictionaryWriter.cs :
+	  Fixed index for room-reserved attributes (0x22-0x3B).
+	  Added note on 0x9D.
+	* XmlBinaryDictionaryReader.cs :
+	  Several fixes to get it work fine.
+
+2005-10-05  Atsushi Enomoto  <[email protected]>
+
+	* XmlDictionary.cs : TryLookup() should use TryGetValue().
+	  Fixed incorrect upper bound check for TryLookup(int, out dictstr).
+	* XmlBinaryDictionaryWriter.cs : Use 0x8B for empty string everywhere
+	  we use 0x83.
+
+2005-10-04  Atsushi Enomoto  <[email protected]>
+
+	* XmlBinaryDictionaryReader.cs : new file for CreateBinaryReader().
+	* XmlDictionaryReader.cs : use above.
+	* XmlBinaryDictionaryWriter.cs : several fixes (renamed private
+	  fields, added more notes, and much more).
+
+2005-10-04  Atsushi Enomoto  <[email protected]>
+
+	* XmlBinaryDictionaryWriter.cs :
+	  Added notes on dictionary string support inference. Fixed filename.
+
+2005-10-04  Atsushi Enomoto  <[email protected]>
+
+	* XmlBinaryDictionaryWriter.cs : new file for CreateBinaryWriter().
+	* XmlDictionaryWriter.cs : use above.
+
+2005-10-03  Atsushi Enomoto  <[email protected]>
+
+	* XmlDictionaryWriter.cs : stubby WriteNode() impl.
+	* XmlBinaryWriterSession.cs : tiny notes.
+
+2005-10-03  Atsushi Enomoto  <[email protected]>
+
+	* XmlSimpleDictionaryWriter.cs : new file for CreateDictionaryWriter().
+	  Implemented simple XmlWriter functionality.
+	* XmlDictionaryWriter.cs : use above.
+
+2005-10-03  Atsushi Enomoto  <[email protected]>
+
+	* XmlDictionaryWriter.cs : implemented some members. Added more stubs.
+
+2005-09-29  Duncan Mak  <[email protected]>
+
+	* XmlDictionaryWriter.cs (CreateBinaryWriter): Added stub.
+
+2005-09-28  Duncan Mak  <[email protected]>
+
+	* XmlDictionaryWriter.cs (CreateDictionaryWriter): Added stub.
+
+2005-09-27  Atsushi Enomoto  <[email protected]>
+
+	* XmlDictionaryReader.cs :
+	  Some member signature fixes.
+	  implemented CreateDictionaryReader().
+	  TryGetLocalNameAsDictionaryString() seems always returning false.
+	  IsLocalName() is not likely to use TryGet...() above.
+	* XmlSimpleDictionaryReader.cs : for CreateDictionaryReader().
+
+2005-09-26  Atsushi Enomoto  <[email protected]>
+
+	* XmlDictionaryString.cs, XmlDictionary.cs,
+	  XmlDictionaryReaderQuotas.cs, XmlDictionaryReader.cs:
+	  added some implementations.
+
+2005-09-22  Atsushi Enomoto  <[email protected]>
+
+	* XmlDictionaryString.cs, XmlShimWriter.cs,
+	  IXmlBinaryWriterInitializer.cs, IXmlUTF8WriterInitializer.cs,
+	  XmlDictionaryWriter.cs, UniqueId.cs, XmlC14NWriter.cs,
+	  XmlDictionary.cs, OnXmlDictionaryReaderClose.cs,
+	  XmlBinaryReaderSession.cs, IXmlMtomReaderInitializer.cs,
+	  IXmlDictionary.cs, IXmlBinaryReaderInitializer.cs,
+	  XmlCanonicalWriter.cs, XmlBinaryWriterSession.cs,
+	  XmlDictionaryReaderQuotas.cs, IXmlUTF8ReaderInitializer.cs,
+	  IXmlMtomWriterInitializer.cs, XmlDictionaryReader.cs :
+	  #if NET_2_0. coding style was updated.
+
+2005-09-22  Atsushi Enomoto  <[email protected]>
+
+	* IXmlBinaryReaderInitializer.cs
+	  IXmlBinaryWriterInitializer.cs
+	  IXmlDictionary.cs
+	  IXmlMtomReaderInitializer.cs
+	  IXmlMtomWriterInitializer.cs
+	  IXmlUTF8ReaderInitializer.cs
+	  IXmlUTF8WriterInitializer.cs
+	  OnXmlDictionaryReaderClose.cs
+	  UniqueId.cs
+	  XmlBinaryReaderSession.cs
+	  XmlBinaryWriterSession.cs
+	  XmlC14NWriter.cs
+	  XmlCanonicalWriter.cs
+	  XmlDictionary.cs
+	  XmlDictionaryReader.cs
+	  XmlDictionaryReaderQuotas.cs
+	  XmlDictionaryString.cs
+	  XmlDictionaryWriter.cs
+	  XmlShimWriter.cs : new files.
+

+ 39 - 0
mcs/class/System.Runtime.Serialization/System.Xml/IStreamProvider.cs

@@ -0,0 +1,39 @@
+//
+// IStreamProvider.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+using System.IO;
+
+namespace System.Xml
+{
+	public interface IStreamProvider
+	{
+		Stream GetStream ();
+		void ReleaseStream (Stream stream);
+	}
+}
+#endif

+ 50 - 0
mcs/class/System.Runtime.Serialization/System.Xml/IXmlBinaryReaderInitializer.cs

@@ -0,0 +1,50 @@
+//
+// IXmlBinaryReaderInitializer.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+using System;
+using System.IO;
+
+namespace System.Xml
+{
+	public interface IXmlBinaryReaderInitializer
+	{
+		void SetInput (
+			Stream stream,
+			IXmlDictionary dictionary,
+			XmlDictionaryReaderQuotas quota,
+			XmlBinaryReaderSession session,
+			OnXmlDictionaryReaderClose onClose);
+
+		void SetInput (byte [] buffer, int offset, int count,
+			IXmlDictionary dictionary,
+			XmlDictionaryReaderQuotas quota,
+			XmlBinaryReaderSession session,
+			OnXmlDictionaryReaderClose onClose);
+	}
+}
+#endif

+ 42 - 0
mcs/class/System.Runtime.Serialization/System.Xml/IXmlBinaryWriterInitializer.cs

@@ -0,0 +1,42 @@
+//
+// IXmlBinaryWriterInitializer.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+using System;
+using System.IO;
+
+namespace System.Xml
+{
+	public interface IXmlBinaryWriterInitializer
+	{
+		void SetOutput (Stream stream,
+			IXmlDictionary dictionary,
+			XmlBinaryWriterSession session,
+			bool ownsStream);
+	}
+}
+#endif

+ 39 - 0
mcs/class/System.Runtime.Serialization/System.Xml/IXmlDictionary.cs

@@ -0,0 +1,39 @@
+//
+// IXmlDictionary.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+namespace System.Xml
+{
+	public interface IXmlDictionary
+	{
+		bool TryLookup (int key, out XmlDictionaryString result);
+		bool TryLookup (string value, out XmlDictionaryString result);
+		bool TryLookup (XmlDictionaryString value,
+			out XmlDictionaryString result);
+	}
+}
+#endif

+ 50 - 0
mcs/class/System.Runtime.Serialization/System.Xml/IXmlMtomReaderInitializer.cs

@@ -0,0 +1,50 @@
+//
+// IXmlMtomReaderInitializer.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+using System;
+using System.IO;
+using System.Text;
+
+namespace System.Xml
+{
+	public interface IXmlMtomReaderInitializer
+	{
+		void SetInput (Stream stream, Encoding [] encodings,
+				string contentType,
+				XmlDictionaryReaderQuotas quotas,
+				int maxBufferSize,
+				OnXmlDictionaryReaderClose onClose);
+
+		void SetInput (byte [] buffer, int offset, int count,
+				Encoding [] encodings, string contentType, 
+				XmlDictionaryReaderQuotas quotas,
+				int maxBufferSize,
+				OnXmlDictionaryReaderClose onClose);
+	}
+}
+#endif

+ 42 - 0
mcs/class/System.Runtime.Serialization/System.Xml/IXmlMtomWriterInitializer.cs

@@ -0,0 +1,42 @@
+//
+// IXmlMtomWriterInitializer.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+using System;
+using System.IO;
+using System.Text;
+
+namespace System.Xml
+{
+	public interface IXmlMtomWriterInitializer
+	{
+		void SetOutput (Stream stream, Encoding encoding,
+			int maxSizeInBytes, string startInfo, string boundary,
+			string startUri, bool writeMessageHeaders, bool ownsStream);
+	}
+}
+#endif

+ 48 - 0
mcs/class/System.Runtime.Serialization/System.Xml/IXmlUTF8ReaderInitializer.cs

@@ -0,0 +1,48 @@
+//
+// IXmlTextReaderInitializer.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+using System;
+using System.IO;
+using System.Text;
+
+namespace System.Xml
+{
+	public interface IXmlTextReaderInitializer
+	{
+		void SetInput (byte [] buffer, int offset, int count,
+			Encoding encoding,
+			XmlDictionaryReaderQuotas quota,
+			OnXmlDictionaryReaderClose onClose);
+
+		void SetInput (Stream stream,
+			Encoding encoding,
+			XmlDictionaryReaderQuotas quota,
+			OnXmlDictionaryReaderClose onClose);
+	}
+}
+#endif

+ 40 - 0
mcs/class/System.Runtime.Serialization/System.Xml/IXmlUTF8WriterInitializer.cs

@@ -0,0 +1,40 @@
+//
+// IXmlTextWriterInitializer.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+using System;
+using System.IO;
+using System.Text;
+
+namespace System.Xml
+{
+	public interface IXmlTextWriterInitializer
+	{
+		void SetOutput (Stream stream, Encoding encoding, bool ownsStream);
+	}
+}
+#endif

+ 34 - 0
mcs/class/System.Runtime.Serialization/System.Xml/OnXmlDictionaryReaderClose.cs

@@ -0,0 +1,34 @@
+//
+// OnXmlDictionaryReaderClose.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+namespace System.Xml
+{
+	public delegate void OnXmlDictionaryReaderClose (XmlDictionaryReader reader);
+}
+
+#endif

+ 168 - 0
mcs/class/System.Runtime.Serialization/System.Xml/UniqueId.cs

@@ -0,0 +1,168 @@
+//
+// UniqueId.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//
+// Copyright (C) 2005,2007 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+using System;
+
+namespace System.Xml
+{
+	public class UniqueId
+	{
+		Guid guid;
+		string id;
+
+		public UniqueId ()
+			: this (Guid.NewGuid ())
+		{
+		}
+
+		public UniqueId (byte [] id)
+			: this (id, 0)
+		{
+		}
+
+		public UniqueId (Guid id)
+		{
+			this.guid = id;
+		}
+
+		public UniqueId (string value)
+		{
+			if (value == null)
+				throw new ArgumentNullException ("value cannot be null", "value");
+
+			if (value.Length == 0)
+				throw new FormatException ("UniqueId cannot be zero length");
+
+			this.id = value;
+		}
+
+		[MonoTODO]
+		public UniqueId (byte [] id, int offset)
+		{
+			if (id == null)
+				throw new ArgumentNullException ();
+			if (offset < 0 || offset >= id.Length)
+				throw new ArgumentOutOfRangeException ("offset");
+
+			if (id.Length - offset != 16)
+				throw new NotImplementedException ();
+
+			guid = new Guid (new ArraySegment<byte> (id, offset, id.Length - offset).Array);
+		}
+
+		[MonoTODO]
+		public UniqueId (char [] id, int offset, int count)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public int CharArrayLength {
+			get { throw new NotImplementedException (); }
+		}
+
+		public bool IsGuid {
+			get { return guid != default (Guid); }
+		}
+
+		[MonoTODO]
+		public override bool Equals (Object obj)
+		{
+			UniqueId other = obj as UniqueId;
+
+			if (other == null)
+				return false;
+
+			if (IsGuid && other.IsGuid) {
+				Guid g1, g2;
+				TryGetGuid (out g1);
+				other.TryGetGuid (out g2);
+				return g1.Equals (g2);
+			}
+
+			return ToString () == other.ToString ();
+		}
+
+		[MonoTODO]
+		public override int GetHashCode ()
+		{
+			throw new NotImplementedException ();
+		}
+
+		public static bool operator == (UniqueId id1, UniqueId id2)
+		{
+			if ((object) id1 == null)
+				return (object) id2 == null;
+			if ((object) id2 == null)
+				return false;
+			return id1.Equals (id2);
+		}
+
+		public static bool operator != (UniqueId id1, UniqueId id2)
+		{
+			return ! (id1 == id2);
+		}
+
+		[MonoTODO]
+		public int ToCharArray (char [] array, int offset)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public override string ToString ()
+		{
+			if (IsGuid)
+				return "urn:uuid:" + guid;
+
+			return id;
+		}
+
+		public bool TryGetGuid (out Guid guid)
+		{
+			if (IsGuid) {
+				guid = this.guid;
+				return true;
+			} else {
+				guid = default (Guid);
+				return false;
+			}
+		}
+
+		public bool TryGetGuid (byte [] buffer, int offset)
+		{
+			Guid ret;
+			if (!TryGetGuid (out ret))
+				return false;
+			byte [] bytes = ret.ToByteArray ();
+			bytes.CopyTo (buffer, offset);
+			return true;
+		}
+	}
+}
+#endif

+ 1114 - 0
mcs/class/System.Runtime.Serialization/System.Xml/XmlBinaryDictionaryReader.cs

@@ -0,0 +1,1114 @@
+//
+// XmlBinaryDictionaryReader.cs
+//
+// Author:
+//	Atsushi Enomoto  <[email protected]>
+//
+// Copyright (C) 2005, 2007 Novell, Inc.  http://www.novell.com
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections;
+using System.Collections.Specialized;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Text;
+
+using QName = System.Xml.XmlQualifiedName;
+using BF = System.Xml.XmlBinaryFormat;
+
+namespace System.Xml
+{
+	// FIXME:
+	//	- native value data (7B-82, 8D-A0) are not implemented.
+	//	- support XmlDictionaryReaderQuotas.
+	//	- support XmlBinaryReaderSession.
+	//	- handle namespaces as expected.
+
+	internal class XmlBinaryDictionaryReader : XmlDictionaryReader, IXmlNamespaceResolver
+	{
+		internal interface ISource
+		{
+			int Position { get; }
+			int ReadByte ();
+			int Read (byte [] data, int offset, int count);
+			BinaryReader Reader { get; }
+		}
+
+		internal class StreamSource : ISource
+		{
+			BinaryReader stream;
+			int position;
+
+			public StreamSource (Stream stream)
+			{
+				this.stream = new BinaryReader (stream);
+			}
+
+			public int Position {
+				get { return position - 1; }
+			}
+
+			public BinaryReader Reader {
+				get { return stream; }
+			}
+
+			public int ReadByte ()
+			{
+				if (stream.PeekChar () < 0)
+					return -1;
+				position++;
+				return stream.ReadByte ();
+			}
+
+			public int Read (byte [] data, int offset, int count)
+			{
+				int ret = stream.Read (data, offset, count);
+				position += ret;
+				return ret;
+			}
+		}
+
+		class NodeInfo
+		{
+			public NodeInfo ()
+			{
+			}
+
+			public NodeInfo (bool isAttr)
+			{
+				IsAttributeValue = isAttr;
+			}
+
+			public bool IsAttributeValue;
+			public int Position;
+			public string Prefix;
+			public XmlDictionaryString DictLocalName;
+			public XmlDictionaryString DictNS;
+			public XmlNodeType NodeType;
+			public object TypedValue;
+			public byte ValueType;
+
+			// -1 for nothing,
+			// -2 for that of element (only for attribute),
+			// 0 or more to fill later
+			public int NSSlot;
+
+			string name;
+			string local_name;
+			string ns;
+			string value;
+
+			public string LocalName {
+				get { return DictLocalName != null ? DictLocalName.Value : local_name; }
+				set {
+					DictLocalName = null;
+					local_name = value;
+				}
+			}
+
+			public string NS {
+				get { return DictNS != null ? DictNS.Value : ns; }
+				set {
+					DictNS = null;
+					ns = value;
+				}
+			}
+
+			public string Name {
+				get {
+					if (name == null)
+						name = Prefix.Length > 0 ?
+							String.Concat (Prefix, ":", LocalName) :
+							LocalName;
+					return name;
+				}
+			}
+
+			public string Value {
+				get {
+					if (BF.AttrString <= ValueType && ValueType <= BF.GlobalAttrIndexInElemNS)
+						return value; // attribute
+					switch (ValueType) {
+					case 0:
+					case BF.Comment:
+					case BF.Text:
+					case BF.EmptyText:
+						return value;
+					case BF.Zero:
+					case BF.One:
+						return XmlConvert.ToString ((int) TypedValue);
+					case BF.Int8:
+						return XmlConvert.ToString ((byte) TypedValue);
+					case BF.Int16:
+						return XmlConvert.ToString ((short) TypedValue);
+					case BF.Int32:
+						return XmlConvert.ToString ((int) TypedValue);
+					case BF.Int64:
+						return XmlConvert.ToString ((long) TypedValue);
+					case BF.Single:
+						return XmlConvert.ToString ((float) TypedValue);
+					case BF.Double:
+						return XmlConvert.ToString ((double) TypedValue);
+					case BF.DateTime:
+						return XmlConvert.ToString ((DateTime) TypedValue, XmlDateTimeSerializationMode.RoundtripKind);
+					case BF.TimeSpan:
+						return XmlConvert.ToString ((TimeSpan) TypedValue);
+					case BF.Guid:
+						return XmlConvert.ToString ((Guid) TypedValue);
+					case BF.UniqueIdFromGuid:
+						return TypedValue.ToString ();
+					case BF.Base64:
+					case BF.Base64Fixed:
+						return Convert.ToBase64String ((byte []) TypedValue);
+					default:
+						throw new NotImplementedException ("ValueType " + ValueType + " on node " + NodeType);
+					}
+				}
+				set { this.value = value; }
+			}
+
+			public virtual void Reset ()
+			{
+				Position = 0;
+				DictLocalName = DictNS = null;
+				LocalName = NS = Prefix = Value = String.Empty;
+				NodeType = XmlNodeType.None;
+				TypedValue = null;
+				ValueType = 0;
+				NSSlot = -1;
+			}
+		}
+
+		class AttrNodeInfo : NodeInfo
+		{
+			public int ValueIndex;
+
+			public override void Reset ()
+			{
+				base.Reset ();
+				ValueIndex = -1;
+			}
+		}
+
+		ISource source;
+		IXmlDictionary dictionary;
+		XmlDictionaryReaderQuotas quota;
+		XmlBinaryReaderSession session;
+		OnXmlDictionaryReaderClose on_close;
+		XmlParserContext context;
+
+		ReadState state = ReadState.Initial;
+		NodeInfo node;
+		NodeInfo current;
+		List<AttrNodeInfo> attributes = new List<AttrNodeInfo> ();
+		List<NodeInfo> attr_values = new List<NodeInfo> ();
+		List<NodeInfo> node_stack = new List<NodeInfo> ();
+		List<QName> ns_store = new List<QName> ();
+		Dictionary<int,XmlDictionaryString> ns_dict_store =
+			new Dictionary<int,XmlDictionaryString> ();
+		int attr_count;
+		int attr_value_count;
+		int current_attr = -1;
+		int depth = 0;
+		// used during Read()
+		int ns_slot;
+		// next byte in the source (one byte token ahead always
+		// happens because there is no "end of start element" mark).
+		int next = -1;
+		bool is_next_end_element;
+		// temporary buffer for utf8enc.GetString()
+		byte [] tmp_buffer = new byte [128];
+		UTF8Encoding utf8enc = new UTF8Encoding ();
+
+		public XmlBinaryDictionaryReader (byte [] buffer, int offset,
+			int count, IXmlDictionary dictionary,
+			XmlDictionaryReaderQuotas quota,
+			XmlBinaryReaderSession session,
+			OnXmlDictionaryReaderClose onClose)
+		{
+			source = /*new ArraySource (buffer, offset, count);*/
+				new StreamSource (new MemoryStream (buffer, offset, count));
+			Initialize (dictionary, quota, session, onClose);
+		}
+
+		public XmlBinaryDictionaryReader (Stream stream,
+			IXmlDictionary dictionary,
+			XmlDictionaryReaderQuotas quota,
+			XmlBinaryReaderSession session,
+			OnXmlDictionaryReaderClose onClose)
+		{
+			source = new StreamSource (stream);
+			Initialize (dictionary, quota, session, onClose);
+		}
+
+		private void Initialize (IXmlDictionary dictionary,
+			XmlDictionaryReaderQuotas quotas,
+			XmlBinaryReaderSession session,
+			OnXmlDictionaryReaderClose onClose)
+		{
+			if (quotas == null)
+				throw new ArgumentNullException ("quotas");
+			if (dictionary == null)
+				dictionary = new XmlDictionary ();
+			this.dictionary = dictionary;
+
+			this.quota = quotas;
+
+			if (session == null)
+				session = new XmlBinaryReaderSession ();
+			this.session = session;
+
+			on_close = onClose;
+			NameTable nt = new NameTable ();
+			this.context = new XmlParserContext (nt,
+				new XmlNamespaceManager (nt),
+				null, XmlSpace.None);
+
+			current = node = new NodeInfo ();
+			current.Reset ();
+		}
+
+		public override int AttributeCount {
+			get { return attr_count; }
+		}
+
+		public override string BaseURI {
+			get { return context.BaseURI; }
+		}
+
+		public override int Depth {
+			get { return depth; }
+		}
+
+		public override bool EOF {
+			get { return state == ReadState.EndOfFile || state == ReadState.Error; }
+		}
+
+		public override bool HasValue {
+			get { return current.Value.Length > 0; }
+		}
+
+		public override bool IsEmptyElement {
+			get { return false; }
+		}
+
+		public override XmlNodeType NodeType {
+			get { return current.NodeType; }
+		}
+
+		public override string Prefix {
+			get { return current.Prefix; }
+		}
+
+		public override string LocalName {
+			get { return current.LocalName; }
+		}
+
+		public override string NamespaceURI {
+			get { return current.NS; }
+		}
+
+		public override XmlNameTable NameTable {
+			get { return context.NameTable; }
+		}
+
+		public override XmlDictionaryReaderQuotas Quotas {
+			get { return quota; }
+		}
+
+		public override ReadState ReadState {
+			get { return state; }
+		}
+
+		public override string Value {
+			get { return current.Value; }
+		}
+
+		public override void Close ()
+		{
+			if (on_close != null)
+				on_close (this);
+		}
+
+		public override string GetAttribute (int i)
+		{
+			if (i >= attr_count)
+				throw new ArgumentOutOfRangeException (String.Format ("Specified attribute index is {0} and should be less than {1}", i, attr_count));
+			return attributes [i].Value;
+		}
+
+		public override string GetAttribute (string name)
+		{
+			for (int i = 0; i < attributes.Count; i++)
+				if (attributes [i].Name == name)
+					return attributes [i].Value;
+			return null;
+		}
+
+		public override string GetAttribute (string localName, string ns)
+		{
+			for (int i = 0; i < attributes.Count; i++)
+				if (attributes [i].LocalName == localName &&
+					attributes [i].NS == ns)
+					return attributes [i].Value;
+			return null;
+		}
+
+		public IDictionary<string,string> GetNamespacesInScope (
+			XmlNamespaceScope scope)
+		{
+			return context.NamespaceManager.GetNamespacesInScope (scope);
+		}
+
+		public string LookupPrefix (string ns)
+		{
+			return context.NamespaceManager.LookupPrefix (NameTable.Get (ns));
+		}
+
+		public override string LookupNamespace (string prefix)
+		{
+			return context.NamespaceManager.LookupNamespace (
+				NameTable.Get (prefix));
+		}
+
+		public override bool MoveToElement ()
+		{
+			bool ret = current_attr >= 0;
+			current_attr = -1;
+			current = node;
+			return ret;
+		}
+
+		public override bool MoveToFirstAttribute ()
+		{
+			if (attr_count == 0)
+				return false;
+			current_attr = 0;
+			current = attributes [current_attr];
+			return true;
+		}
+
+		public override bool MoveToNextAttribute ()
+		{
+			if (++current_attr < attr_count) {
+				current = attributes [current_attr];
+				return true;
+			} else {
+				--current_attr;
+				return false;
+			}
+		}
+
+		public override void MoveToAttribute (int i)
+		{
+			if (i >= attr_count)
+				throw new ArgumentOutOfRangeException (String.Format ("Specified attribute index is {0} and should be less than {1}", i, attr_count));
+			current_attr = i;
+			current = attributes [i];
+		}
+
+		public override bool MoveToAttribute (string name)
+		{
+			for (int i = 0; i < attributes.Count; i++) {
+				if (attributes [i].Name == name) {
+					MoveToAttribute (i);
+					return true;
+				}
+			}
+			return false;
+		}
+
+		public override bool MoveToAttribute (string localName, string ns)
+		{
+			for (int i = 0; i < attributes.Count; i++) {
+				if (attributes [i].LocalName == localName &&
+					attributes [i].NS == ns) {
+					MoveToAttribute (i);
+					return true;
+				}
+			}
+			return false;
+		}
+
+		public override bool ReadAttributeValue ()
+		{
+			if (current_attr < 0)
+				return false;
+			int start = attributes [current_attr].ValueIndex;
+			int end = current_attr + 1 == attr_count ? attr_value_count : attributes [current_attr + 1].ValueIndex;
+			if (start == end)
+				return false;
+			if (!current.IsAttributeValue) {
+				current = attr_values [start];
+				return true;
+			}
+			for (int i = start; i < end; i++) {
+				if (current == attr_values [i] && i + 1 < end) {
+					current = attr_values [i + 1];
+					return true;
+				}
+			}
+			return false;
+		}
+
+		public override bool Read ()
+		{
+			switch (state) {
+			case ReadState.Closed:
+			case ReadState.EndOfFile:
+			case ReadState.Error:
+				return false;
+			}
+
+			// clear.
+			state = ReadState.Interactive;
+			attr_count = 0;
+			attr_value_count = 0;
+			ns_slot = 0;
+			current = node;
+
+			if (node.NodeType == XmlNodeType.Element) {
+				// push element scope
+				depth++;
+				if (node_stack.Count <= depth) {
+					node_stack.Add (node);
+					node = new NodeInfo ();
+				}
+				else
+					node = node_stack [depth];
+				node.Reset ();
+				current = node;
+			}
+
+			if (is_next_end_element) {
+				is_next_end_element = false;
+				ProcessEndElement ();
+				return true;
+			}
+			node.Reset ();
+
+			int ident = next >= 0 ? next : source.ReadByte ();
+			next = -1;
+
+			// check end of source.
+			if (ident < 0) {
+				state = ReadState.EndOfFile;
+				current.Reset ();
+				return false;
+			}
+
+			is_next_end_element = ident > 0x80 && (ident & 1) == 1;
+			ident -= is_next_end_element ? 1 : 0;
+/*
+			if (0x3F <= ident && ident <= 0x42)
+				ReadElementBinary ((byte) ident);
+			else {
+				switch (ident) {
+				case 0x3C: // end element
+					ProcessEndElement ();
+					break;
+				case 0x3D: // comment
+					node.Value = ReadUTF8 ();
+					node.NodeType = XmlNodeType.Comment;
+					break;
+				default:
+					ReadTextOrValue ((byte) ident, node, false);
+					break;
+				}
+			}
+*/
+			switch (ident) {
+			case BF.EndElement:
+				ProcessEndElement ();
+				break;
+			case BF.Comment:
+				node.Value = ReadUTF8 ();
+				node.ValueType = BF.Comment;
+				node.NodeType = XmlNodeType.Comment;
+				break;
+			case BF.ElemString:
+			case BF.ElemStringPrefix:
+			case BF.ElemIndex:
+			case BF.ElemIndexPrefix:
+				ReadElementBinary ((byte) ident);
+				break;
+
+			default:
+				ReadTextOrValue ((byte) ident, node, false);
+				break;
+			}
+
+			return true;
+		}
+
+		private void ProcessEndElement ()
+		{
+			if (depth == 0)
+				throw new XmlException ("Unexpected end of element while there is no element started.");
+			current = node = node_stack [--depth];
+			node.NodeType = XmlNodeType.EndElement;
+			context.NamespaceManager.PopScope ();
+		}
+
+		private void ReadElementBinary (int ident)
+		{
+			// element
+			node.NodeType = XmlNodeType.Element;
+			node.Prefix = String.Empty;
+			context.NamespaceManager.PushScope ();
+			switch (ident) {
+			case BF.ElemString:
+				node.LocalName = ReadUTF8 ();
+				break;
+			case BF.ElemStringPrefix:
+				node.Prefix = ReadUTF8 ();
+				node.NSSlot = ns_slot++;
+				goto case BF.ElemString;
+			case BF.ElemIndex:
+				node.DictLocalName = ReadDictName ();
+				break;
+			case BF.ElemIndexPrefix:
+				node.Prefix = ReadUTF8 ();
+				node.NSSlot = ns_slot++;
+				goto case BF.ElemIndex;
+			}
+
+			bool loop = true;
+			do {
+				ident = next < 0 ? ReadByteOrError () : next;
+				next = -1;
+
+				switch (ident) {
+				case BF.AttrString:
+				case BF.AttrStringPrefix:
+				case BF.AttrIndex:
+				case BF.AttrIndexPrefix:
+				case BF.GlobalAttrIndex:
+				case BF.GlobalAttrIndexInElemNS:
+					ReadAttribute ((byte) ident);
+					break;
+				case BF.DefaultNSString:
+				case BF.PrefixNSString:
+				case BF.DefaultNSIndex:
+				case BF.PrefixNSIndex:
+					ReadNamespace ((byte) ident);
+					break;
+				default:
+					next = ident;
+					loop = false;
+					break;
+				}
+/*
+				if (ident < 4) {
+					// attributes
+					if (attributes.Count == attr_count)
+						attributes.Add (new AttrNodeInfo ());
+					AttrNodeInfo a = attributes [attr_count++];
+					a.Reset ();
+					a.Position = source.Position;
+					switch (ident) {
+					case 0:
+						a.LocalName = ReadUTF8 ();
+						break;
+					case 1:
+						a.Prefix = ReadUTF8 ();
+						goto case 0;
+					case 2:
+						a.DictLocalName = ReadDictName ();
+						break;
+					case 3:
+						a.Prefix = ReadUTF8 ();
+						goto case 2;
+					}
+					ReadAttributeValueBinary (a);
+				}
+				else if (ident < 6) {
+					// namespaces
+					string prefix = ident == 4 ?
+						String.Empty : ReadUTF8 ();
+					string ns = ReadUTF8 ();
+					ns_store.Add (new QName (prefix, ns));
+					context.NamespaceManager.AddNamespace (prefix, ns);
+				}
+				else if (0x22 <= ident && ident < 0x3C) {
+					// attributes with predefined ns index
+					if (attributes.Count == attr_count)
+						attributes.Add (new AttrNodeInfo ());
+					AttrNodeInfo a = attributes [attr_count++];
+					a.Reset ();
+					a.Position = source.Position;
+					a.NSSlot = ident - 0x22;
+					a.LocalName = ReadUTF8 ();
+					ReadAttributeValueBinary (a);
+				}
+				else {
+					next = ident;
+					break;
+				}
+*/
+			} while (loop);
+
+#if true
+			node.NS = context.NamespaceManager.LookupNamespace (node.Prefix) ?? String.Empty;
+			foreach (AttrNodeInfo a in attributes)
+				if (a.Prefix.Length > 0)
+					a.NS = context.NamespaceManager.LookupNamespace (a.Prefix);
+//Console.WriteLine ("[{0}-{1}->{3}/{2:X02}]", node.Prefix, node.LocalName, ident, node.NS);
+#else
+			if (node.Prefix.Length == 0)
+				foreach (QName q in ns_store)
+					if (q.Name.Length == 0) {
+						node.NS = q.Namespace;
+						break;
+					}
+			else if (node.NSSlot >= 0)
+				FillNamespaceBySlot (node);
+			foreach (AttrNodeInfo a in attributes) {
+				if (a.NSSlot >= 0) {
+					/*
+					if (a.NSSlot >= ns_store.Count)
+						throw new XmlException (String.Format ("Binary XML data is not valid. An attribute node has an invalid index at position {0}. Index is {1}.", a.Position, a.NSSlot));
+					a.NS = ns_store [a.NSSlot].Namespace;
+					a.Prefix = ns_store [a.NSSlot].Name;
+					*/
+					FillNamespaceBySlot (a);
+				}
+				else if (a.NSSlot == -2) {
+					a.NS = node.NS;
+					a.Prefix = node.Prefix;
+				}
+			}
+#endif
+
+			ns_store.Clear ();
+			ns_dict_store.Clear ();
+		}
+
+		void FillNamespaceBySlot (NodeInfo n)
+		{
+			if (n.NSSlot >= ns_store.Count)
+				throw new XmlException (String.Format ("Binary XML data is not valid. The '{2}' node has an invalid index. Index is {1}. The position in the stream is at {0}.", n.Position, n.NSSlot, n.NodeType));
+			n.NS = ns_store [n.NSSlot].Namespace;
+			//n.Prefix = ns_store [n.NSSlot].Name;
+		}
+
+		private void ReadAttribute (byte ident)
+		{
+			if (attributes.Count == attr_count)
+				attributes.Add (new AttrNodeInfo ());
+			AttrNodeInfo a = attributes [attr_count++];
+			a.Reset ();
+			a.Position = source.Position;
+
+			switch (ident) {
+			case BF.AttrString:
+				a.LocalName = ReadUTF8 ();
+				break;
+			case BF.AttrStringPrefix:
+				a.Prefix = ReadUTF8 ();
+				a.NSSlot = ns_slot++;
+				goto case BF.AttrString;
+			case BF.AttrIndex:
+				a.DictLocalName = ReadDictName ();
+				break;
+			case BF.AttrIndexPrefix:
+				a.Prefix = ReadUTF8 ();
+				a.NSSlot = ns_slot++;
+				goto case BF.AttrIndex;
+			case BF.GlobalAttrIndex:
+				a.NSSlot = ns_slot++;
+				a.DictLocalName = ReadDictName ();
+				// FIXME: retrieve namespace
+				break;
+			case BF.GlobalAttrIndexInElemNS:
+				a.Prefix = node.Prefix;
+				a.DictLocalName = ReadDictName ();
+				a.NSSlot = -2;
+				break;
+			}
+			ReadAttributeValueBinary (a);
+		}
+
+		private void ReadNamespace (byte ident)
+		{
+			string prefix = null, ns = null;
+				XmlDictionaryString dns;
+			switch (ident) {
+			case BF.DefaultNSString:
+				prefix = String.Empty;
+				ns = ReadUTF8 ();
+				break;
+			case BF.PrefixNSString:
+				prefix = ReadUTF8 ();
+				ns = ReadUTF8 ();
+				break;
+			case BF.DefaultNSIndex:
+				prefix = String.Empty;
+				dns = ReadDictName ();
+				ns_dict_store.Add (ns_store.Count, dns);
+				ns = dns.Value;
+				break;
+			case BF.PrefixNSIndex:
+				prefix = ReadUTF8 ();
+				dns = ReadDictName ();
+				ns_dict_store.Add (ns_store.Count, dns);
+				ns = dns.Value;
+				break;
+			}
+			ns_store.Add (new QName (prefix, ns));
+			context.NamespaceManager.AddNamespace (prefix, ns);
+		}
+
+		private void ReadAttributeValueBinary (AttrNodeInfo a)
+		{
+			a.ValueIndex = attr_value_count;
+			do {
+				if (attr_value_count == attr_values.Count)
+					attr_values.Add (new NodeInfo (true));
+				NodeInfo v = attr_values [attr_value_count++];
+				v.Reset ();
+				int ident = ReadByteOrError ();
+				is_next_end_element = ident > 0x80 && (ident & 1) == 1;
+				ident -= is_next_end_element ? 1 : 0;
+				if (!ReadTextOrValue ((byte) ident, v, true) || is_next_end_element)
+					break;
+			} while (true);
+		}
+
+		private bool ReadTextOrValue (byte ident, NodeInfo node, bool canSkip)
+		{
+			node.Value = null;
+			node.ValueType = ident;
+			node.NodeType = XmlNodeType.Text;
+			switch (ident) {
+			case BF.Zero:
+				node.TypedValue = 0;
+				break;
+			case BF.One:
+				node.TypedValue = 1;
+				break;
+			case BF.BoolFalse:
+				node.TypedValue = false;
+				break;
+			case BF.BoolTrue:
+				node.TypedValue = true;
+				break;
+			case BF.Int8:
+				node.TypedValue = ReadByteOrError ();
+				break;
+			case BF.Int16:
+				node.TypedValue = source.Reader.ReadInt16 ();
+				break;
+			case BF.Int32:
+				node.TypedValue = source.Reader.ReadInt32 ();
+				break;
+			case BF.Int64:
+				node.TypedValue = source.Reader.ReadInt64 ();
+				break;
+			case BF.Single:
+				node.TypedValue = source.Reader.ReadSingle ();
+				break;
+			case BF.Double:
+				node.TypedValue = source.Reader.ReadDouble ();
+				break;
+			case BF.Decimal:
+				int [] bits = new int [4];
+				bits [3] = source.Reader.ReadInt32 ();
+				bits [2] = source.Reader.ReadInt32 ();
+				bits [0] = source.Reader.ReadInt32 ();
+				bits [1] = source.Reader.ReadInt32 ();
+				node.TypedValue = new Decimal (bits);
+				break;
+			case BF.DateTime:
+				node.TypedValue = new DateTime (source.Reader.ReadInt64 ());
+				break;
+			//case BF.UniqueId: // identical to .Text
+			case BF.Base64:
+				byte [] base64 = new byte [ReadVariantSize ()];
+				source.Reader.Read (base64, 0, base64.Length);
+				node.TypedValue = base64;
+				break;
+			case BF.Base64Fixed:
+				base64 = new byte [source.Reader.ReadInt16 ()];
+				source.Reader.Read (base64, 0, base64.Length);
+				node.TypedValue = base64;
+				break;
+			case BF.TimeSpan:
+				node.TypedValue = new TimeSpan (source.Reader.ReadInt64 ());
+				break;
+			case BF.UniqueIdFromGuid:
+				byte [] guid = new byte [16];
+				source.Reader.Read (guid, 0, guid.Length);
+				node.TypedValue = new UniqueId (new Guid (guid));
+				break;
+			case BF.Guid:
+				guid = new byte [16];
+				source.Reader.Read (guid, 0, guid.Length);
+				node.TypedValue = new Guid (guid);
+				break;
+			case BF.Text:
+				node.Value = ReadUTF8 ();
+				node.NodeType = XmlNodeType.Text;
+				break;
+			case BF.EmptyText:
+				node.Value = String.Empty;
+				node.NodeType = XmlNodeType.Text;
+				break;
+			default:
+				if (!canSkip)
+					throw new ArgumentException (String.Format ("Unexpected binary XML data at position {1}: {0:X}", ident + (is_next_end_element ? 1 : 0), source.Position));
+				next = ident;
+				return false;
+			}
+			return true;
+/*
+			if (ident == 0x8B) {
+				// empty text
+				node.Value = String.Empty;
+				node.NodeType = XmlNodeType.Text;
+			}
+			else if (0x83 <= ident && ident <= 0x85 ||
+				0x9D <= ident && ident <= 0x9F) {
+				// text
+				int sizeSpec = ident > 0x90 ? ident - 0x9D : ident - 0x83;
+				node.Value = ReadUTF8 (sizeSpec);
+				node.NodeType = XmlNodeType.Text;
+				is_next_end_element = ident > 0x90;
+			}
+			else {
+				switch (ident) {
+				case 0x7B: // byte
+				case 0x7C: // short
+				case 0x7D: // int
+				case 0x7E: // long
+				case 0x7F: // float
+				case 0x80: // double
+				case 0x81: // decimal
+				case 0x82: // DateTime
+				case 0x8D: // UniqueId
+				case 0x8E: // TimeSpan
+				case 0x8F: // Guid
+				case 0xA0: // base64Binary
+					Console.WriteLine ("At position {0}({0:X})", source.Position);
+					throw new NotImplementedException ();
+				default:
+					if (!canSkip)
+						throw new ArgumentException (String.Format ("Unexpected binary XML data at position {1}: {0:X}", ident, source.Position));
+					next = ident;
+					return false;
+				}
+			}
+			return true;
+*/
+		}
+
+		private int ReadVariantSize ()
+		{
+			int size = 0;
+			// If sizeSpec < 0, then it is variant size specifier.
+			// Otherwise it is fixed size s = sizeSpec + 1 byte(s).
+			do {
+				size <<= 7;
+				byte got = ReadByteOrError ();
+				size += got;
+				if (got < 0x80)
+					break;
+				size -= 0x80;
+			} while (true);
+			return size;
+		}
+
+		private string ReadUTF8 ()
+		{
+			int size = ReadVariantSize ();
+			if (size == 0)
+				return String.Empty;
+			if (tmp_buffer.Length < size) {
+				int extlen = tmp_buffer.Length * 2;
+				tmp_buffer = new byte [size < extlen ? extlen : size];
+			}
+			size = source.Read (tmp_buffer, 0, size);
+			return utf8enc.GetString (tmp_buffer, 0, size);
+		}
+
+		private XmlDictionaryString ReadDictName ()
+		{
+			int key = ReadVariantSize ();
+			XmlDictionaryString s;
+			if ((key & 1) == 1) {
+				if (session.TryLookup (key >> 1, out s))
+					return s;
+			} else {
+				if (dictionary.TryLookup (key >> 1, out s))
+					return s;
+			}
+			throw new XmlException (String.Format ("Input XML binary stream is invalid. No matching XML dictionary string entry at {0}. Binary stream position at {1}", key, source.Position));
+		}
+
+		private byte ReadByteOrError ()
+		{
+			int ret = source.ReadByte ();
+			if (ret < 0)
+				throw new XmlException (String.Format ("Unexpected end of binary stream. Position is at {0}", source.Position));
+			return (byte) ret;
+		}
+
+		public override void ResolveEntity ()
+		{
+			throw new NotSupportedException ("this XmlReader does not support ResolveEntity.");
+		}
+
+		public override bool TryGetBase64ContentLength (out int length)
+		{
+			length = 0;
+			if (current.ValueType != BF.Base64 &&
+			    current.ValueType != BF.Base64Fixed)
+				return false;
+			length = ((byte []) current.TypedValue).Length;
+			return true;
+		}
+
+		public override string ReadContentAsString ()
+		{
+			string value = Value;
+			do {
+				switch (NodeType) {
+				case XmlNodeType.Element:
+				case XmlNodeType.EndElement:
+					return value;
+				case XmlNodeType.Text:
+					value += Value;
+					break;
+				}
+			} while (Read ());
+			return value;
+		}
+
+		#region read typed content
+
+		public override int ReadContentAsInt ()
+		{
+			int ret = GetIntValue ();
+			Read ();
+			return ret;
+		}
+		
+		int GetIntValue ()
+		{
+			switch (node.ValueType) {
+			case BF.Zero:
+				return 0;
+			case BF.One:
+				return 1;
+			case BF.Int8:
+				return (byte) current.TypedValue;
+			case BF.Int16:
+				return (short) current.TypedValue;
+			case BF.Int32:
+				return (int) current.TypedValue;
+			}
+			throw new InvalidOperationException ("Current content is not an integer");
+		}
+
+		public override long ReadContentAsLong ()
+		{
+			if (node.ValueType == BF.Int64) {
+				long v = (long) current.TypedValue;
+				Read ();
+				return v;
+			}
+			return ReadContentAsInt ();
+		}
+
+		public override float ReadContentAsFloat ()
+		{
+			if (node.ValueType != BF.Single)
+				throw new InvalidOperationException ("Current content is not a single");
+			float v = (float) current.TypedValue;
+			Read ();
+			return v;
+		}
+
+		public override double ReadContentAsDouble ()
+		{
+			if (node.ValueType != BF.Double)
+				throw new InvalidOperationException ("Current content is not a double");
+			double v = (double) current.TypedValue;
+			Read ();
+			return v;
+		}
+
+		// FIXME: this is not likely to consume sequential base64 nodes.
+		public override byte [] ReadContentAsBase64 ()
+		{
+			byte [] ret = null;
+			if (node.ValueType != BF.Base64 &&
+			    node.ValueType != BF.Base64Fixed)
+				throw new InvalidOperationException ("Current content is not base64");
+			while (NodeType == XmlNodeType.Text &&
+			       (node.ValueType == BF.Base64 || node.ValueType == BF.Base64Fixed)) {
+				if (ret == null)
+					ret = (byte []) node.TypedValue;
+				else {
+					byte [] tmp = (byte []) node.TypedValue;
+					byte [] tmp2 = new byte [ret.Length + tmp.Length];
+					Array.Copy (ret, tmp2, ret.Length);
+					Array.Copy (tmp, 0, tmp2, ret.Length, tmp.Length);
+					ret = tmp2;
+				}
+				Read ();
+				//MoveToContent ();
+			}
+			return ret;
+		}
+
+		public override Guid ReadContentAsGuid ()
+		{
+			if (node.ValueType != BF.Guid)
+				throw new InvalidOperationException ("Current content is not a Guid");
+			Guid ret = (Guid) node.TypedValue;
+			Read ();
+			return ret;
+		}
+
+		public override UniqueId ReadContentAsUniqueId ()
+		{
+			switch (node.ValueType) {
+			case BF.Text:
+				UniqueId ret = new UniqueId (node.Value);
+				Read ();
+				return ret;
+			case BF.UniqueIdFromGuid:
+				ret = (UniqueId) node.TypedValue;
+				Read ();
+				return ret;
+			default:
+				throw new InvalidOperationException ("Current content is not a UniqueId");
+			}
+		}
+
+		#endregion
+	}
+}

+ 934 - 0
mcs/class/System.Runtime.Serialization/System.Xml/XmlBinaryDictionaryWriter.cs

@@ -0,0 +1,934 @@
+//
+// XmlBinaryDictionaryWriter.cs
+//
+// Author:
+//	Atsushi Enomoto  <[email protected]>
+//
+// Copyright (C) 2005, 2007 Novell, Inc.  http://www.novell.com
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections;
+using System.Collections.Specialized;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Text;
+
+using BF = System.Xml.XmlBinaryFormat;
+
+namespace System.Xml
+{
+	internal class XmlBinaryDictionaryWriter : XmlDictionaryWriter
+	{
+		#region Fields
+		BinaryWriter original, writer, buffer_writer;
+		IXmlDictionary dict_ext;
+		XmlDictionary dict_int = new XmlDictionary ();
+		XmlBinaryWriterSession session;
+		bool owns_stream;
+		Encoding utf8Enc = new UTF8Encoding ();
+		MemoryStream buffer = new MemoryStream ();
+
+		const string XmlNamespace = "http://www.w3.org/XML/1998/namespace";
+		const string XmlnsNamespace = "http://www.w3.org/2000/xmlns/";
+
+		WriteState state = WriteState.Start;
+		bool open_start_element = false;
+		// transient current node info
+		ListDictionary namespaces = new ListDictionary ();
+		string xml_lang = null;
+		XmlSpace xml_space = XmlSpace.None;
+		// stacked info
+		Stack<string> xml_lang_stack = new Stack<string> ();
+		Stack<XmlSpace> xml_space_stack = new Stack<XmlSpace> ();
+		XmlNamespaceManager nsmgr = new XmlNamespaceManager (new NameTable ());
+		Stack<string> element_ns_stack = new Stack<string> ();
+		string element_ns = String.Empty;
+		int element_count;
+		string element_prefix; // only meaningful at Element state
+		// current attribute info
+		string attr_value;
+		string current_attr_prefix;
+		object current_attr_name, current_attr_ns;
+		bool attr_typed_value;
+		SaveTarget save_target;
+
+		enum SaveTarget {
+			None,
+			Namespaces,
+			XmlLang,
+			XmlSpace
+		}
+
+		// XmlWriterSettings support
+
+		#endregion
+
+		#region Constructors
+
+		public XmlBinaryDictionaryWriter (Stream stream,
+			IXmlDictionary dictionary,
+			XmlBinaryWriterSession session, bool ownsStream)
+		{
+			if (dictionary == null)
+				dictionary = new XmlDictionary ();
+			if (session == null)
+				session = new XmlBinaryWriterSession ();
+
+			original = new BinaryWriter (stream);
+			this.writer = original;
+			buffer_writer = new BinaryWriter (buffer);
+			this.dict_ext = dictionary;
+			this.session = session;
+			owns_stream = ownsStream;
+
+//			xml_lang_stack.Push (null);
+//			xml_space_stack.Push (XmlSpace.None);
+		}
+
+		#endregion
+
+		#region Properties
+
+		public override WriteState WriteState {
+			get { return state; }
+		}
+		
+		public override string XmlLang {
+			get { return xml_lang; }
+		}
+
+		public override XmlSpace XmlSpace {
+			get { return xml_space; }
+		}
+
+		#endregion
+
+		#region Methods
+
+		private void AddMissingElementXmlns ()
+		{
+			// push new namespaces to manager.
+			foreach (DictionaryEntry ent in namespaces) {
+				string prefix = (string) ent.Key;
+				string ns = ent.Value as string;
+				XmlDictionaryString dns = ent.Value as XmlDictionaryString;
+				if (ns != null) {
+					if (prefix.Length > 0) {
+						writer.Write (BF.PrefixNSString);
+						WriteNamePart (prefix);
+					}
+					else
+						writer.Write (BF.DefaultNSString);
+					WriteNamePart (ns);
+				} else {
+					if (prefix.Length > 0) {
+						writer.Write (BF.PrefixNSIndex);
+						WriteNamePart (prefix);
+					}
+					else
+						writer.Write (BF.DefaultNSIndex);
+					WriteDictionaryIndex (dns);
+				}
+				nsmgr.AddNamespace (prefix, ent.Value.ToString ());
+			}
+			namespaces.Clear ();
+		}
+
+		private void CheckState ()
+		{
+			if (state == WriteState.Closed) {
+				throw new InvalidOperationException ("The Writer is closed.");
+			}
+		}
+
+		void ProcessStateForContent ()
+		{
+			CheckState ();
+
+			if (state == WriteState.Element)
+				CloseStartElement ();
+
+			ProcessPendingBuffer (false, false);
+			if (state != WriteState.Attribute)
+				writer = buffer_writer;
+		}
+
+		void ProcessTypedValue ()
+		{
+			ProcessStateForContent ();
+			if (state == WriteState.Attribute) {
+				if (attr_typed_value)
+					throw new InvalidOperationException (String.Format ("A typed value for the attribute '{0}' in namespace '{1}' was already written", current_attr_name, current_attr_ns));
+				attr_typed_value = true;
+			}
+		}
+
+		void ProcessPendingBuffer (bool last, bool endElement)
+		{
+			if (buffer.Position > 0) {
+				byte [] arr = buffer.GetBuffer ();
+				if (endElement)
+					arr [0]++;
+				original.Write (arr, 0, (int) buffer.Position);
+				buffer.SetLength (0);
+			}
+			if (last)
+				writer = original;
+		}
+
+		public override void Close ()
+		{
+			CloseOpenAttributeAndElements ();
+
+			if (owns_stream)
+				writer.Close ();
+			else if (state != WriteState.Closed)
+				writer.Flush ();
+			state = WriteState.Closed;
+		}
+
+		private void CloseOpenAttributeAndElements ()
+		{
+			CloseStartElement ();
+
+			 while (element_count > 0)
+				WriteEndElement ();
+		}
+
+		private void CloseStartElement ()
+		{
+			if (!open_start_element)
+				return;
+
+			if (state == WriteState.Attribute)
+				WriteEndAttribute ();
+
+			AddMissingElementXmlns ();
+
+			state = WriteState.Content;
+			open_start_element = false;
+			nsmgr.PushScope ();
+		}
+
+		public override void Flush ()
+		{
+			writer.Flush ();
+		}
+
+		public override string LookupPrefix (string ns)
+		{
+			if (ns == null || ns == String.Empty)
+				throw new ArgumentException ("The Namespace cannot be empty.");
+			throw new NotImplementedException ();
+		}
+
+		public override void WriteBase64 (byte[] buffer, int index, int count)
+		{
+			ProcessStateForContent ();
+
+			WriteToStream (BF.Base64, buffer, index, count);
+		}
+
+		public override void WriteCData (string text)
+		{
+			if (text.IndexOf ("]]>") >= 0)
+				throw new ArgumentException ("CDATA section cannot contain text \"]]>\".");
+
+			ProcessStateForContent ();
+
+			WriteTextBinary (text);
+		}
+
+		public override void WriteCharEntity (char ch)
+		{
+			WriteChars (new char [] {ch}, 0, 1);
+		}
+
+		public override void WriteChars (char[] buffer, int index, int count)
+		{
+			ProcessStateForContent ();
+
+			if (count == 0)
+				writer.Write (BF.EmptyText);
+			else {
+				byte [] data = utf8Enc.GetBytes (buffer, index, count);
+				WriteToStream (BF.Text, data, 0, data.Length);
+			}
+		}
+
+		public override void WriteComment (string text)
+		{
+			if (text.EndsWith("-"))
+				throw new ArgumentException ("An XML comment cannot contain \"--\" inside.");
+			else if (text.IndexOf("--") > 0)
+				throw new ArgumentException ("An XML comment cannot end with \"-\".");
+
+			ProcessStateForContent ();
+
+			if (state == WriteState.Attribute)
+				throw new InvalidOperationException ("Comment node is not allowed inside an attribute");
+
+			WriteToStream (BF.Comment, text);
+		}
+
+		public override void WriteDocType (string name, string pubid, string sysid, string subset)
+		{
+			throw new NotSupportedException ("This XmlWriter implementation does not support document type.");
+		}
+
+		public override void WriteEndAttribute ()
+		{
+			if (state != WriteState.Attribute)
+				throw new InvalidOperationException("Token EndAttribute in state Start would result in an invalid XML document.");
+
+			CheckState ();
+
+			if (attr_value == null)
+				attr_value = String.Empty;
+
+			switch (save_target) {
+			case SaveTarget.XmlLang:
+				xml_lang = attr_value;
+				goto default;
+			case SaveTarget.XmlSpace:
+				switch (attr_value) {
+				case "preserve":
+					xml_space = XmlSpace.Preserve;
+					break;
+				case "default":
+					xml_space = XmlSpace.Default;
+					break;
+				default:
+					throw new ArgumentException (String.Format ("Invalid xml:space value: '{0}'", attr_value));
+				}
+				goto default;
+			case SaveTarget.Namespaces:
+				if (current_attr_name.ToString ().Length > 0 && attr_value.Length == 0)
+					throw new ArgumentException ("Cannot use prefix with an empty namespace.");
+
+				// add namespace
+				AddNamespaceChecked (current_attr_name.ToString (), attr_value);
+				break;
+			default:
+				if (!attr_typed_value)
+					WriteTextBinary (attr_value);
+				break;
+			}
+
+			state = WriteState.Element;
+			current_attr_prefix = null;
+			current_attr_name = null;
+			current_attr_ns = null;
+			attr_value = null;
+			attr_typed_value = false;
+		}
+
+		public override void WriteEndDocument ()
+		{
+			CloseOpenAttributeAndElements ();
+
+			switch (state) {
+			case WriteState.Start:
+				throw new InvalidOperationException ("Document has not started.");
+			case WriteState.Prolog:
+				throw new ArgumentException ("This document does not have a root element.");
+			}
+
+			state = WriteState.Start;
+		}
+
+		bool SupportsCombinedEndElementSupport (byte operation)
+		{
+			switch (operation) {
+			case BF.Comment:
+				return false;
+			}
+			return true;
+		}
+
+		public override void WriteEndElement ()
+		{
+			if (element_count-- == 0)
+				throw new InvalidOperationException("There was no XML start tag open.");
+
+			if (state == WriteState.Attribute)
+				WriteEndAttribute ();
+
+			// Comment+EndElement does not exist
+			bool needExplicitEndElement = buffer.Position == 0 || !SupportsCombinedEndElementSupport (buffer.GetBuffer () [0]);
+			ProcessPendingBuffer (true, !needExplicitEndElement);
+			CheckState ();
+			AddMissingElementXmlns ();
+
+			if (needExplicitEndElement)
+				writer.Write (BF.EndElement);
+
+			nsmgr.PopScope ();
+			element_ns = element_ns_stack.Pop ();
+			xml_lang = xml_lang_stack.Pop ();
+			xml_space = xml_space_stack.Pop ();
+			open_start_element = false;
+
+			Depth--;
+		}
+
+		public override void WriteEntityRef (string name)
+		{
+			throw new NotSupportedException ("This XmlWriter implementation does not support entity references.");
+		}
+
+		public override void WriteFullEndElement ()
+		{
+			WriteEndElement ();
+		}
+
+		public override void WriteProcessingInstruction (string name, string text)
+		{
+			if (name != "xml")
+				throw new ArgumentException ("Processing instructions are not supported. ('xml' is allowed for XmlDeclaration; this is because of design problem of ECMA XmlWriter)");
+			// Otherwise, silently ignored. WriteStartDocument()
+			// is still callable after this method(!)
+		}
+
+		public override void WriteRaw (string data)
+		{
+			WriteString (data);
+		}
+
+		public override void WriteRaw (char[] buffer, int index, int count)
+		{
+			WriteChars (buffer, index, count);
+		}
+
+		void CheckStateForAttribute ()
+		{
+			CheckState ();
+
+			if (state != WriteState.Element)
+				throw new InvalidOperationException ("Token StartAttribute in state " + WriteState + " would result in an invalid XML document.");
+		}
+
+		string CreateNewPrefix ()
+		{
+			string s = String.Empty;
+			for (int n = 0; n < 26; n++) {
+				for (int i = 0; i < 26; i++) {
+					string x = s + (char) (0x61 + i);
+					if (!namespaces.Contains (x))
+						return x;
+				}
+				s = ((char) (0x61 + n)).ToString ();
+			}
+			throw new InvalidOperationException ("too many prefix population");
+		}
+
+		void ProcessStartAttributeCommon (string prefix, string localName, string ns, object nameObj, object nsObj)
+		{
+			// dummy prefix is created here, while the caller
+			// still uses empty string as the prefix there.
+			if (prefix.Length == 0 && ns.Length > 0)
+				prefix = CreateNewPrefix ();
+			else if (prefix.Length > 0 && ns.Length == 0)
+				throw new ArgumentException ("Cannot use prefix with an empty namespace.");
+			// here we omit such cases that it is used for writing
+			// namespace-less xml, unlike XmlTextWriter.
+			if (prefix == "xmlns" && ns != XmlnsNamespace)
+				throw new ArgumentException (String.Format ("The 'xmlns' attribute is bound to the reserved namespace '{0}'", XmlnsNamespace));
+
+			CheckStateForAttribute ();
+
+			state = WriteState.Attribute;
+
+			save_target = SaveTarget.None;
+			switch (prefix) {
+			case "xml":
+				// MS.NET looks to allow other names than 
+				// lang and space (e.g. xml:link, xml:hack).
+				ns = XmlNamespace;
+				switch (localName) {
+				case "lang":
+					save_target = SaveTarget.XmlLang;
+					break;
+				case "space":
+					save_target = SaveTarget.XmlSpace;
+					break;
+				}
+				break;
+			case "xmlns":
+				save_target = SaveTarget.Namespaces;
+				break;
+			}
+
+			current_attr_prefix = prefix;
+			current_attr_name = nameObj;
+			current_attr_ns = nsObj;
+
+			// for namespace nodes we don't write attribute node here.
+			if (save_target == SaveTarget.Namespaces)
+				return;
+
+			if (prefix.Length > 0)
+				AddNamespaceChecked (prefix, nsObj);
+		}
+
+		public override void WriteStartAttribute (string prefix, string localName, string ns)
+		{
+			if (prefix == null)
+				prefix = String.Empty;
+			if (ns == null)
+				ns = String.Empty;
+			if (localName == "xmlns" && prefix.Length == 0) {
+				prefix = "xmlns";
+				localName = String.Empty;
+			}
+
+			ProcessStartAttributeCommon (prefix, localName, ns, localName, ns);
+
+			// for namespace nodes we don't write attribute node here.
+			if (save_target == SaveTarget.Namespaces)
+				return;
+
+			int op = prefix.Length > 0 ? BF.AttrStringPrefix : BF.AttrString;
+			// Write to Stream
+			writer.Write ((byte) op);
+			WriteNames (prefix, localName);
+		}
+
+		public override void WriteStartDocument ()
+		{
+			WriteStartDocument (false);
+		}
+
+		public override void WriteStartDocument (bool standalone)
+		{
+			if (state != WriteState.Start)
+				throw new InvalidOperationException("WriteStartDocument should be the first call.");
+
+			CheckState ();
+
+			// write nothing to stream.
+
+			state = WriteState.Prolog;
+		}
+
+		void PrepareStartElement ()
+		{
+			ProcessPendingBuffer (true, false);
+			CheckState ();
+			CloseStartElement ();
+
+			Depth++;
+
+			element_ns_stack.Push (element_ns);
+			xml_lang_stack.Push (xml_lang);
+			xml_space_stack.Push (xml_space);
+		}
+
+		public override void WriteStartElement (string prefix, string localName, string ns)
+		{
+			PrepareStartElement ();
+
+			if ((prefix != null && prefix != String.Empty) && ((ns == null) || (ns == String.Empty)))
+				throw new ArgumentException ("Cannot use a prefix with an empty namespace.");
+
+			if (ns == null)
+				ns = String.Empty;
+			if (ns == String.Empty)
+				prefix = String.Empty;
+			if (prefix == null)
+				prefix = String.Empty;
+
+			writer.Write ((byte) (prefix.Length > 0 ? BF.ElemStringPrefix : BF.ElemString));
+			WriteNames (prefix, localName);
+
+			OpenElement (prefix, ns);
+		}
+
+		void OpenElement (string prefix, object nsobj)
+		{
+			string ns = nsobj.ToString ();
+//			if (prefix.Length == 0 && ns != nsmgr.DefaultNamespace ||
+//			    prefix.Length > 0 && nsmgr.LookupNamespace (prefix) != ns) {
+			// FIXME: this condition might be still incorrect...
+			if (nsobj.ToString () != element_ns ||
+			    nsmgr.LookupPrefix (element_ns) != prefix) {
+				nsmgr.AddNamespace (prefix, ns);
+				if (nsmgr.LookupPrefix (element_ns) != prefix)
+					namespaces.Add (prefix, nsobj);
+			}
+
+			state = WriteState.Element;
+			open_start_element = true;
+			element_prefix = prefix;
+			element_count++;
+			element_ns = nsobj.ToString ();
+		}
+
+		public override void WriteString (string text)
+		{
+			switch (state) {
+			case WriteState.Start:
+			case WriteState.Prolog:
+				throw new InvalidOperationException ("Token content in state Prolog would result in an invalid XML document.");
+			}
+
+			if (text == null)
+				text = String.Empty;
+
+			ProcessStateForContent ();
+
+			if (state == WriteState.Attribute)
+				attr_value += text;
+			else
+				WriteTextBinary (text);
+		}
+
+		public override void WriteSurrogateCharEntity (char lowChar, char highChar)
+		{
+			WriteChars (new char [] {highChar, lowChar}, 0, 2);
+		}
+
+		public override void WriteWhitespace (string ws)
+		{
+			for (int i = 0; i < ws.Length; i++) {
+				switch (ws [i]) {
+				case ' ': case '\t': case '\r': case '\n':
+					continue;
+				default:
+					throw new ArgumentException ("Invalid Whitespace");
+				}
+			}
+
+			ProcessStateForContent ();
+
+			WriteTextBinary (ws);
+		}
+
+		public override void WriteXmlnsAttribute (string prefix, string namespaceUri)
+		{
+			if (namespaceUri == null)
+				throw new ArgumentNullException ("namespaceUri");
+
+			if (prefix == null)
+				prefix = ((char)('a' + Depth - 1)).ToString ();
+
+			CheckStateForAttribute ();
+
+			AddNamespaceChecked (prefix, namespaceUri);
+
+			state = WriteState.Element;
+		}
+
+		void AddNamespaceChecked (string prefix, object ns)
+		{
+			switch (ns.ToString ()) {
+			case XmlnsNamespace:
+			case XmlNamespace:
+				return;
+			}
+
+			if (prefix == null)
+				prefix = String.Empty;
+			if (namespaces.Contains (prefix)) {
+				if (namespaces [prefix].ToString () != ns.ToString ())
+					throw new ArgumentException (String.Format ("The prefix '{0}' is already mapped to another namespace URI '{1}' in this element scope", prefix ?? "(null)", namespaces [prefix] ?? "(null)"));
+			}
+			else
+				namespaces.Add (prefix, ns);
+		}
+
+		#region DictionaryString
+
+		void WriteDictionaryIndex (XmlDictionaryString ds)
+		{
+			XmlDictionaryString ds2;
+			bool isSession = false;
+			int idx = ds.Key;
+			if (ds.Dictionary != dict_ext) {
+				isSession = true;
+				if (dict_int.TryLookup (ds.Value, out ds2))
+					ds = ds2;
+				if (!session.TryLookup (ds, out idx))
+					session.TryAdd (dict_int.Add (ds.Value), out idx);
+			}
+			if (idx >= 0x80) {
+				writer.Write ((byte) (0x80 + ((idx % 0x80) << 1) + (isSession ? 1 : 0)));
+				writer.Write ((byte) ((byte) (idx / 0x80) << 1));
+			}
+			else
+				writer.Write ((byte) (((idx % 0x80) << 1) + (isSession ? 1 : 0)));
+		}
+
+		public override void WriteStartElement (string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri)
+		{
+			PrepareStartElement ();
+
+			if (prefix == null)
+				prefix = String.Empty;
+
+			if (prefix.Length == 0)
+				writer.Write (BF.ElemIndex);
+			else
+				WriteToStream (BF.ElemIndexPrefix, prefix);
+			WriteDictionaryIndex (localName);
+
+			OpenElement (prefix, namespaceUri);
+		}
+
+		public override void WriteStartAttribute (string prefix, XmlDictionaryString localName, XmlDictionaryString ns)
+		{
+			if (localName == null)
+				throw new ArgumentNullException ("localName");
+			if (prefix == null)
+				prefix = String.Empty;
+			if (ns == null)
+				ns = XmlDictionaryString.Empty;
+			if (localName.Value == "xmlns" && prefix.Length == 0) {
+				prefix = "xmlns";
+				localName = XmlDictionaryString.Empty;
+			}
+
+			ProcessStartAttributeCommon (prefix, localName.Value, ns.Value, localName, ns);
+
+			if (save_target == SaveTarget.Namespaces)
+				return;
+
+			int op = 
+				ns.Value == nsmgr.LookupNamespace (element_prefix) ? BF.GlobalAttrIndexInElemNS :
+				ns.Value.Length == 0 ? BF.AttrIndex :
+				prefix.Length > 0 ? BF.AttrIndexPrefix : BF.GlobalAttrIndex;
+			// Write to Stream
+			writer.Write ((byte) op);
+			if (prefix.Length > 0)
+				WriteNamePart (prefix);
+			WriteDictionaryIndex (localName);
+		}
+
+		public override void WriteXmlnsAttribute (string prefix, XmlDictionaryString namespaceUri)
+		{
+			if (prefix == null)
+				throw new ArgumentNullException ("prefix");
+			if (namespaceUri == null)
+				throw new ArgumentNullException ("namespaceUri");
+
+			CheckStateForAttribute ();
+
+			AddNamespaceChecked (prefix, namespaceUri);
+
+			state = WriteState.Element;
+		}
+		#endregion
+
+		#region WriteValue
+		public override void WriteValue (bool value)
+		{
+			ProcessTypedValue ();
+
+			writer.Write ((byte) (value ? BF.BoolTrue : BF.BoolFalse));
+		}
+
+		public override void WriteValue (int value)
+		{
+			WriteValue ((long) value);
+		}
+
+		public override void WriteValue (long value)
+		{
+			ProcessTypedValue ();
+
+			if (value == 0)
+				writer.Write (BF.Zero);
+			else if (value == 1)
+				writer.Write (BF.One);
+			else if (value < 0 || value > uint.MaxValue) {
+				writer.Write (BF.Int64);
+				for (int i = 0; i < 8; i++) {
+					writer.Write ((byte) (value & 0xFF));
+					value >>= 8;
+				}
+			} else if (value <= byte.MaxValue) {
+				writer.Write (BF.Int8);
+				writer.Write ((byte) value);
+			} else if (value <= short.MaxValue) {
+				writer.Write (BF.Int16);
+				writer.Write ((byte) (value & 0xFF));
+				writer.Write ((byte) (value >> 8));
+			} else if (value <= int.MaxValue) {
+				writer.Write (BF.Int32);
+				for (int i = 0; i < 4; i++) {
+					writer.Write ((byte) (value & 0xFF));
+					value >>= 8;
+				}
+			}
+		}
+
+		public override void WriteValue (float value)
+		{
+			ProcessTypedValue ();
+			writer.Write (BF.Single);
+			writer.Write (value);
+		}
+
+		public override void WriteValue (double value)
+		{
+			ProcessTypedValue ();
+			writer.Write (BF.Double);
+			writer.Write (value);
+		}
+
+		public override void WriteValue (decimal value)
+		{
+			ProcessTypedValue ();
+			writer.Write (BF.Decimal);
+			int [] bits = Decimal.GetBits (value);
+			// so, looks like it is saved as its internal form,
+			// not the returned order.
+			// BinaryWriter.Write(Decimal) is useless here.
+			writer.Write (bits [3]);
+			writer.Write (bits [2]);
+			writer.Write (bits [0]);
+			writer.Write (bits [1]);
+		}
+
+		public override void WriteValue (DateTime value)
+		{
+			ProcessTypedValue ();
+			writer.Write (BF.DateTime);
+			writer.Write (value.Ticks);
+		}
+
+		public override void WriteValue (Guid value)
+		{
+			ProcessTypedValue ();
+
+			writer.Write (BF.Guid);
+			byte [] bytes = value.ToByteArray ();
+			writer.Write (bytes, 0, bytes.Length);
+		}
+
+		public override void WriteValue (UniqueId value)
+		{
+			if (value == null)
+				throw new ArgumentNullException ("value");
+
+			Guid guid;
+			if (value.TryGetGuid (out guid)) {
+				// this conditional branching is required for
+				// attr_typed_value not being true.
+				ProcessTypedValue ();
+
+				writer.Write (BF.UniqueIdFromGuid);
+				byte [] bytes = guid.ToByteArray ();
+				writer.Write (bytes, 0, bytes.Length);
+			} else {
+				WriteValue (value.ToString ());
+			}
+		}
+
+		public override void WriteValue (TimeSpan value)
+		{
+			ProcessTypedValue ();
+
+			writer.Write (BF.TimeSpan);
+			WriteBigEndian (value.Ticks, 8);
+		}
+		#endregion
+
+		private void WriteBigEndian (long value, int digits)
+		{
+			long v = 0;
+			for (int i = 0; i < digits; i++) {
+				v = (v << 8) + (value & 0xFF);
+				value >>= 8;
+			}
+			for (int i = 0; i < digits; i++) {
+				writer.Write ((byte) (v & 0xFF));
+				v >>= 8;
+			}
+		}
+
+		private void WriteTextBinary (string text)
+		{
+			if (text.Length == 0)
+				writer.Write (BF.EmptyText);
+			else
+				WriteToStream (BF.Text, text);
+		}
+
+		private void WriteNames (string prefix, string localName)
+		{
+			if (prefix != String.Empty)
+				WriteNamePart (prefix);
+			WriteNamePart (localName);
+		}
+
+		private void WriteNamePart (string name)
+		{
+			byte [] data = utf8Enc.GetBytes (name);
+			writer.Write ((byte) (data.Length));
+			writer.Write (data, 0, data.Length);
+		}
+
+		private void WriteToStream (byte identifier, string text)
+		{
+			if (text.Length == 0) {
+				writer.Write (identifier);
+				writer.Write ((byte) 0);
+			} else {
+				byte [] data = utf8Enc.GetBytes (text);
+				WriteToStream (identifier, data, 0, data.Length);
+			}
+		}
+
+		// FIXME: process long data (than 255 bytes)
+		private void WriteToStream (byte identifier, byte [] data, int start, int len)
+		{
+			//int lengthAdjust = 0;GetLengthAdjust (len);
+			//writer.Write ((byte) (identifier + lengthAdjust));
+			//WriteLength (len, lengthAdjust);
+			writer.Write ((byte) (identifier));
+			WriteLength (len, 0);
+			writer.Write (data, start, len);
+		}
+
+		/*
+		private int GetLengthAdjust (int count)
+		{
+			int lengthAdjust = 0;
+			for (int ctmp = count; ctmp >= 0x100; ctmp /= 0x100)
+				lengthAdjust++;
+			return lengthAdjust;
+		}
+		*/
+
+		private void WriteLength (int count, int lengthAdjust)
+		{
+			for (int i = 0, ctmp = count; i < lengthAdjust + 1; i++, ctmp /= 0x100)
+				writer.Write ((byte) (ctmp % 0x100));
+		}
+
+		#endregion
+	}
+}

+ 145 - 0
mcs/class/System.Runtime.Serialization/System.Xml/XmlBinaryFormat.cs

@@ -0,0 +1,145 @@
+//
+// XmlBinaryFormat.cs
+//
+// Author:
+//	Atsushi Enomoto  <[email protected]>
+//
+// Copyright (C) 2007 Novell, Inc.  http://www.novell.com
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.Xml
+{
+	internal class XmlBinaryFormat
+	{
+		public const byte EndElement = 0x01;
+		public const byte Comment = 0x02;
+		public const byte AttrString = 0x04;
+		public const byte AttrStringPrefix = 0x05;
+		public const byte AttrIndex = 0x06;
+		public const byte AttrIndexPrefix = 0x07;
+		public const byte DefaultNSString = 0x08;
+		public const byte PrefixNSString = 0x09;
+		public const byte DefaultNSIndex = 0x0A;
+		public const byte PrefixNSIndex = 0x0B;
+		public const byte GlobalAttrIndex = 0x0C;
+		public const byte GlobalAttrIndexInElemNS = 0x0D;
+
+		public const byte ElemString = 0x40;
+		public const byte ElemStringPrefix = 0x41;
+		public const byte ElemIndex = 0x42;
+		public const byte ElemIndexPrefix = 0x43;
+
+		public const byte Zero = 0x80;
+		public const byte One = 0x82;
+		public const byte BoolFalse = 0x84;
+		public const byte BoolTrue = 0x86;
+		public const byte Int8 = 0x88;
+		public const byte Int16 = 0x8A;
+		public const byte Int32 = 0x8C;
+		public const byte Int64 = 0x8E;
+		public const byte Single = 0x90;
+		public const byte Double = 0x92;
+		public const byte Decimal = 0x94;
+		public const byte DateTime = 0x96;
+		public const byte Base64 = 0x9E;
+		public const byte Base64Fixed = 0xA0;
+
+		public const byte Text = 0x98;
+		public const byte EmptyText = 0xA8;
+
+		public const byte UniqueIdFromGuid = 0xAC;
+		public const byte TimeSpan = 0xAE;
+		public const byte Guid = 0xB0;
+	}
+
+	/* Binary Format (incomplete):
+
+		Literal strings are represented as UTF-8 string, with a length
+		prefixed to the string itself.
+
+		Key indices are based on the rules below:
+		- dictionary strings which can be found in IXmlDictionary are 
+		  doubled its Key. e.g. if the string.Key is 4, then the
+		  output is 8.
+		- dictionary strings which cannot be found in IXmlDictionary
+		  are stored in the XmlBinaryWriterSession, and its output
+		  number is doubled + 1 e.g. if the string is the first
+		  non-dictionary entry, then the output is 1, and 7 for the
+		  fourth one.
+		- When the index goes beyond 128, then it becomes 2 bytes,
+		  where the first byte becomes 0x80 + idx % 0x80 and
+		  the second byte becomes idx / 0x80.
+
+		Below are operations. Prefixes are always raw strings.
+		$string is length-prefixed string. @index is index as
+		described above. [value] is length-prefixed raw array.
+
+		01			: EndElement
+		02 $value		: Comment
+		04 $name		: local attribute by string
+		05 $prefix $name	: global attribute by string
+		06 @name		: local attribute by index
+		07 $prefix @name	: global attribute by index
+		08 $name		: default namespace by string
+		09 $prefix $name	: prefixed namespace by string
+		0A @name		: default namespace by index
+		0B $prefix @name	: prefixed namespace by index
+		0C @name		: global attribute by index
+		0D @name		: global attribute by index,
+					: in current element's namespace
+		40 $name		: element w/o namespace by string
+		41 $prefix $name	: element with namespace by string
+		42 @name		: element w/o namespace by index
+		43 $prefix @name	: element with namespace by index
+		98 $value		: text/cdata/chars
+		99 $value		: text/cdata/chars + EndElement
+
+		FIXME: Below are not implemented:
+		(Uri is simply 98, QName is 98 '{' ns '}' 98 name)
+
+		Combined EndElement for below are supported:
+		80 : 0 (integer)
+		82 : 1 (integer)
+		84 : false (bool)
+		86 : true (bool)
+		88 : 1-byte integer
+		8A : 2-bytes integer
+		8C : 4-bytes integer
+		8E : 8-bytes integer
+		90 : single
+		92 : double
+		94 : decimal
+		96 : DateTime
+		98 : UniqueId
+		9E : base64Binary
+		A0 : base64Binary fixed length?
+		AC : UniqueId whose IsGuid = true
+		AE : TimeSpan
+		B0 : Guid
+
+		Error: PIs, doctype
+		Ignored: XMLdecl
+	*/
+}

+ 69 - 0
mcs/class/System.Runtime.Serialization/System.Xml/XmlBinaryReaderSession.cs

@@ -0,0 +1,69 @@
+//
+// XmlBinaryReaderSession.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+namespace System.Xml
+{
+	public class XmlBinaryReaderSession : IXmlDictionary
+	{
+		public XmlBinaryReaderSession ()
+		{
+		}
+
+		[MonoTODO]
+		public XmlDictionaryString Add (int id, string value)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public void Clear ()
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public bool TryLookup (int key, out XmlDictionaryString result)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public bool TryLookup (string value, out XmlDictionaryString result)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public bool TryLookup (XmlDictionaryString value,
+			out XmlDictionaryString result)
+		{
+			throw new NotImplementedException ();
+		}
+	}
+}
+#endif

+ 74 - 0
mcs/class/System.Runtime.Serialization/System.Xml/XmlBinaryWriterSession.cs

@@ -0,0 +1,74 @@
+//
+// XmlBinaryWriterSession.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//
+// Copyright (C) 2005, 2007 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+using System.Collections.Generic;
+
+namespace System.Xml
+{
+	public class XmlBinaryWriterSession
+	{
+		Dictionary<int,XmlDictionaryString> dic =
+			new Dictionary<int,XmlDictionaryString> ();
+
+		public XmlBinaryWriterSession ()
+		{
+		}
+
+		public void Reset ()
+		{
+			dic.Clear ();
+		}
+
+		// Unlike XmlDictionary, it throws an InvalidOperationException
+		// if the same string already exists.
+		public virtual bool TryAdd (XmlDictionaryString value,
+			out int key)
+		{
+			if (value == null)
+				throw new ArgumentNullException ("value");
+			if (TryLookup (value, out key))
+				throw new InvalidOperationException ("Argument XmlDictionaryString was already added to the writer session");
+			key = dic.Count;
+			dic.Add (key, value);
+			return true;
+		}
+
+		internal bool TryLookup (XmlDictionaryString value,
+			out int key)
+		{
+			foreach (KeyValuePair<int,XmlDictionaryString> e in dic)
+				if (e.Value.Value == value.Value) {
+					key = e.Key;
+					return true;
+				}
+			key = -1;
+			return false;
+		}
+	}
+}
+#endif

+ 187 - 0
mcs/class/System.Runtime.Serialization/System.Xml/XmlC14NWriter.cs

@@ -0,0 +1,187 @@
+//
+// XmlC14NWriter.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if USE_DEPRECATED
+#if NET_2_0
+using System;
+using System.IO;
+
+namespace System.Xml
+{
+	[MonoTODO]
+	public sealed class XmlC14NWriter : XmlCanonicalWriter
+	{
+		bool include_comments;
+
+		public XmlC14NWriter (Stream stream)
+		{
+			throw new NotImplementedException ();
+		}
+
+		public XmlC14NWriter (Stream stream, bool includeComments,
+			params string [] inclusivePrefixes)
+		{
+			throw new NotImplementedException ();
+		}
+
+		public bool IncludeComments {
+			get { return include_comments; }
+			set {
+				throw new NotImplementedException ();
+			}
+		}
+
+		public override void Close ()
+		{
+			Flush ();
+		}
+
+		public override void Flush ()
+		{
+			throw new NotImplementedException ();
+		}
+
+		public void SetOutput (Stream stream)
+		{
+			throw new NotImplementedException ();
+		}
+
+		public void SetOutput (Stream stream, bool includeComments,
+			params string [] inclusivePrefixes)
+		{
+			throw new NotImplementedException ();
+		}
+
+		public override void WriteBase64 (byte [] buffer, int index, int count)
+		{
+			throw new NotImplementedException ();
+		}
+
+		public override void WriteCharEntity (int ch)
+		{
+			throw new NotImplementedException ();
+		}
+
+		public override void WriteComment (string text)
+		{
+			throw new NotImplementedException ();
+		}
+
+		public override void WriteComment (byte [] data, int offset, int count)
+		{
+			throw new NotImplementedException ();
+		}
+
+		public override void WriteDeclaration ()
+		{
+			throw new NotImplementedException ();
+		}
+
+		public override void WriteEndAttribute ()
+		{
+			throw new NotImplementedException ();
+		}
+
+		public override void WriteEndElement (string prefix, string localName)
+		{
+			throw new NotImplementedException ();
+		}
+
+		public override void WriteEndElement (byte [] prefix, int offset1, int count1, byte [] localName, int offset2, int count2)
+		{
+			throw new NotImplementedException ();
+		}
+
+		public override void WriteEndStartElement (bool isEmpty)
+		{
+			throw new NotImplementedException ();
+		}
+
+		public override void WriteEscapedText (string text)
+		{
+			throw new NotImplementedException ();
+		}
+
+		public override void WriteEscapedText (byte [] text, int offset, int count)
+		{
+			throw new NotImplementedException ();
+		}
+
+		public override void WriteNode (XmlReader reader)
+		{
+			throw new NotImplementedException ();
+		}
+
+		public override void WriteStartAttribute (string prefix, string localName)
+		{
+			throw new NotImplementedException ();
+		}
+
+		public override void WriteStartAttribute (byte [] prefix, int offset1, int count1, byte [] localName, int offset2, int count2)
+		{
+			throw new NotImplementedException ();
+		}
+
+		public override void WriteStartElement (string prefix, string localName)
+		{
+			throw new NotImplementedException ();
+		}
+
+		public override void WriteStartElement (byte [] prefix, int offset1, int count1, byte [] localName, int offset2, int count2)
+		{
+			throw new NotImplementedException ();
+		}
+
+		public override void WriteText (string text)
+		{
+			throw new NotImplementedException ();
+		}
+
+		public override void WriteText (int ch)
+		{
+			throw new NotImplementedException ();
+		}
+
+		public override void WriteText (byte [] text, int offset, int count)
+		{
+			throw new NotImplementedException ();
+		}
+
+		public override void WriteXmlnsAttribute (
+			string prefix, string namespaceUri)
+		{
+			throw new NotImplementedException ();
+		}
+
+		public override void WriteXmlnsAttribute (byte [] prefix, int offset1, int count1, byte [] namespaceUri, int offset2, int count2)
+		{
+			throw new NotImplementedException ();
+		}
+	}
+}
+#endif
+#endif

+ 92 - 0
mcs/class/System.Runtime.Serialization/System.Xml/XmlCanonicalWriter.cs

@@ -0,0 +1,92 @@
+//
+// XmlCanonicalWriter.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if USE_DEPRECATED
+#if NET_2_0
+using System;
+using System.IO;
+
+namespace System.Xml
+{
+	[MonoTODO]
+	public abstract class XmlCanonicalWriter
+	{
+		protected XmlCanonicalWriter ()
+		{
+			throw new NotImplementedException ();
+		}
+
+		public abstract void Close ();
+
+		public abstract void Flush ();
+
+		public abstract void WriteBase64 (byte [] buffer, int index, int count);
+
+		public abstract void WriteCharEntity (int ch);
+
+		public abstract void WriteComment (string text);
+
+		public abstract void WriteComment (byte [] data, int offset, int count);
+
+		public abstract void WriteDeclaration ();
+
+		public abstract void WriteEndAttribute ();
+
+		public abstract void WriteEndElement (string prefix, string localName);
+
+		public abstract void WriteEndElement (byte [] prefix, int offset1, int count1, byte [] localName, int offset2, int count2);
+
+		public abstract void WriteEndStartElement (bool isEmpty);
+
+		public abstract void WriteEscapedText (string text);
+
+		public abstract void WriteEscapedText (byte [] text, int offset, int count);
+
+		public abstract void WriteNode (XmlReader reader);
+
+		public abstract void WriteStartAttribute (string prefix, string localName);
+
+		public abstract void WriteStartAttribute (byte [] prefix, int offset1, int count1, byte [] localName, int offset2, int count2);
+
+		public abstract void WriteStartElement (string prefix, string localName);
+
+		public abstract void WriteStartElement (byte [] prefix, int offset1, int count1, byte [] localName, int offset2, int count2);
+
+		public abstract void WriteText (string text);
+
+		public abstract void WriteText (byte [] text, int offset, int count);
+
+		public abstract void WriteText (int ch);
+
+		public abstract void WriteXmlnsAttribute (
+			string prefix, string namespaceUri);
+
+		public abstract void WriteXmlnsAttribute (byte [] prefix, int offset1, int count1, byte [] namespaceUri, int offset2, int count2);
+	}
+}
+#endif
+#endif

+ 129 - 0
mcs/class/System.Runtime.Serialization/System.Xml/XmlDictionary.cs

@@ -0,0 +1,129 @@
+//
+// XmlDictionary.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+using System;
+using System.Collections;
+using System.Collections.Generic;
+
+namespace System.Xml
+{
+	public class XmlDictionary : IXmlDictionary
+	{
+		internal class EmptyDictionary : XmlDictionary
+		{
+			public static readonly EmptyDictionary Instance =
+				new EmptyDictionary ();
+
+			public EmptyDictionary ()
+				: base (1)
+			{
+			}
+		}
+
+		static XmlDictionary empty = new XmlDictionary (true);
+
+		public static IXmlDictionary Empty {
+			get { return empty; }
+		}
+
+		readonly bool is_readonly;
+		Dictionary<string, XmlDictionaryString> dict;
+		List<XmlDictionaryString> list;
+
+		public XmlDictionary ()
+		{
+			dict = new Dictionary<string, XmlDictionaryString> ();
+			list = new List<XmlDictionaryString> ();
+		}
+
+		public XmlDictionary (int capacity)
+		{
+			dict = new Dictionary<string, XmlDictionaryString> (capacity);
+			list = new List<XmlDictionaryString> (capacity);
+		}
+
+		// for static empty.
+		private XmlDictionary (bool isReadOnly)
+			: this (1)
+		{
+			is_readonly = isReadOnly;
+		}
+
+		public virtual XmlDictionaryString Add (string value)
+		{
+			if (is_readonly)
+				throw new InvalidOperationException ();
+			XmlDictionaryString ret;
+			if (dict.TryGetValue (value, out ret))
+				return ret;
+			ret = new XmlDictionaryString (this, value, dict.Count);
+			dict.Add (value, ret);
+			list.Add (ret);
+			return ret;
+		}
+
+		public virtual bool TryLookup (
+			int key, out XmlDictionaryString result)
+		{
+			if (key < 0 || dict.Count <= key) {
+				result = null;
+				return false;
+			}
+			result = list [key];
+			return true;
+		}
+
+		public virtual bool TryLookup (string value,
+			out XmlDictionaryString result)
+		{
+			if (value == null)
+				throw new ArgumentNullException ();
+			return dict.TryGetValue (value, out result);
+		}
+
+		public virtual bool TryLookup (XmlDictionaryString value,
+			out XmlDictionaryString result)
+		{
+			if (value == null)
+				throw new ArgumentNullException ();
+			if (value.Dictionary != this) {
+				result = null;
+				return false;
+			}
+			for (int i = 0; i < list.Count; i++) {
+				if (object.ReferenceEquals (list [i], value)) {
+					result = value;
+					return true;
+				}
+			}
+			result = null;
+			return false;
+		}
+	}
+}
+#endif

+ 597 - 0
mcs/class/System.Runtime.Serialization/System.Xml/XmlDictionaryReader.cs

@@ -0,0 +1,597 @@
+//
+// XmlDictionaryReader.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//
+// Copyright (C) 2005, 2007 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+using System;
+using System.IO;
+using System.Reflection;
+using System.Text;
+using System.Xml;
+
+namespace System.Xml
+{
+	public abstract partial class XmlDictionaryReader : XmlReader
+	{
+		protected XmlDictionaryReader ()
+		{
+		}
+
+		XmlDictionaryReaderQuotas quotas;
+
+		public virtual bool CanCanonicalize {
+			get { return false; }
+		}
+
+		public virtual XmlDictionaryReaderQuotas Quotas {
+			get {
+				if (quotas == null)
+					quotas = new XmlDictionaryReaderQuotas ();
+				return quotas;
+			}
+		}
+
+		[MonoTODO]
+		public virtual void EndCanonicalization ()
+		{
+			throw new NotSupportedException ();
+		}
+
+		public virtual string GetAttribute (
+			XmlDictionaryString localName,
+			XmlDictionaryString namespaceUri)
+		{
+			if (localName == null)
+				throw new ArgumentNullException ("localName");
+			if (namespaceUri == null)
+				throw new ArgumentNullException ("namespaceUri");
+			return GetAttribute (localName.Value, namespaceUri.Value);
+		}
+
+		public virtual int IndexOfLocalName (
+			string [] localNames, string namespaceUri)
+		{
+			if (localNames == null)
+				throw new ArgumentNullException ("localNames");
+			if (namespaceUri == null)
+				throw new ArgumentNullException ("namespaceUri");
+			if (NamespaceURI != namespaceUri)
+				return -1;
+			for (int i = 0; i < localNames.Length; i++)
+				if (localNames [i] == LocalName)
+					return i;
+			return -1;
+		}
+
+		public virtual int IndexOfLocalName (
+			XmlDictionaryString [] localNames,
+			XmlDictionaryString namespaceUri)
+		{
+			if (localNames == null)
+				throw new ArgumentNullException ("localNames");
+			if (namespaceUri == null)
+				throw new ArgumentNullException ("namespaceUri");
+			if (NamespaceURI != namespaceUri.Value)
+				return -1;
+			XmlDictionaryString localName;
+			if (!TryGetLocalNameAsDictionaryString (out localName))
+				return -1;
+			IXmlDictionary dict = localName.Dictionary;
+			XmlDictionaryString iter;
+			for (int i = 0; i < localNames.Length; i++)
+				if (dict.TryLookup (localNames [i], out iter) && object.ReferenceEquals (iter, localName))
+					return i;
+			return -1;
+		}
+
+		public virtual bool IsLocalName (string localName)
+		{
+			return LocalName == localName;
+		}
+
+		public virtual bool IsLocalName (XmlDictionaryString localName)
+		{
+			if (localName == null)
+				throw new ArgumentNullException ("localName");
+			return LocalName == localName.Value;
+		}
+
+		public virtual bool IsNamespaceUri (string namespaceUri)
+		{
+			return NamespaceURI == namespaceUri;
+		}
+
+		public virtual bool IsNamespaceUri (XmlDictionaryString namespaceUri)
+		{
+			if (namespaceUri == null)
+				throw new ArgumentNullException ("namespaceUri");
+			return NamespaceURI == namespaceUri.Value;
+		}
+
+		[MonoTODO]
+		public virtual bool IsStartArray (out Type type)
+		{
+			throw new NotImplementedException ();
+		}
+
+		public virtual bool IsStartElement (
+			XmlDictionaryString localName,
+			XmlDictionaryString namespaceUri)
+		{
+			if (localName == null)
+				throw new ArgumentNullException ("localName");
+			if (namespaceUri == null)
+				throw new ArgumentNullException ("namespaceUri");
+			return IsStartElement (localName.Value, namespaceUri.Value);
+		}
+
+		[MonoTODO]
+		public virtual void MoveToStartElement ()
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public virtual void MoveToStartElement (string name)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public virtual void MoveToStartElement (
+			string localName, string namespaceUri)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public virtual void MoveToStartElement (
+			XmlDictionaryString localName,
+			XmlDictionaryString namespaceUri)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public virtual void StartCanonicalization (
+			Stream stream, bool includeComments,
+			string [] inclusivePrefixes)
+		{
+			throw new NotSupportedException ();
+		}
+
+		public virtual bool TryGetArrayLength (out int count)
+		{
+			count = -1;
+			return false;
+		}
+
+		public virtual bool TryGetBase64ContentLength (out int count)
+		{
+			count = -1;
+			return false;
+		}
+
+		[MonoTODO]
+		public virtual bool TryGetLocalNameAsDictionaryString (
+			out XmlDictionaryString localName)
+		{
+			localName = null;
+			return false;
+		}
+
+		[MonoTODO]
+		public virtual bool TryGetNamespaceUriAsDictionaryString (
+			out XmlDictionaryString namespaceUri)
+		{
+			namespaceUri = null;
+			return false;
+		}
+
+		#region Content Reader Methods
+
+		[MonoTODO]
+		public override object ReadContentAs (Type type, IXmlNamespaceResolver nsResolver)
+		{
+			return base.ReadContentAs (type, nsResolver);
+		}
+
+		public virtual byte [] ReadContentAsBase64 ()
+		{
+			int len;
+			if (!TryGetBase64ContentLength (out len))
+				return Convert.FromBase64String (ReadContentAsString ());
+			byte [] bytes = new byte [len];
+			ReadContentAsBase64 (bytes, 0, len);
+			return bytes;
+		}
+
+		MethodInfo xmlconv_from_bin_hex = typeof (XmlConvert).GetMethod ("FromBinHexString", BindingFlags.Static | BindingFlags.NonPublic, null, new Type [] {typeof (string)}, null);
+
+		byte [] FromBinHexString (string s)
+		{
+			return (byte []) xmlconv_from_bin_hex.Invoke (null, new object [] {s});
+		}
+
+		public virtual byte [] ReadContentAsBinHex ()
+		{
+			int len;
+			if (!TryGetArrayLength (out len))
+				return FromBinHexString (ReadContentAsString ());
+			return ReadContentAsBinHex (len);
+		}
+
+		protected byte [] ReadContentAsBinHex (int maxByteArrayContentLength)
+		{
+			byte [] bytes = new byte [maxByteArrayContentLength];
+			ReadContentAsBinHex (bytes, 0, maxByteArrayContentLength);
+			return bytes;
+		}
+
+		[MonoTODO]
+		public virtual int ReadContentAsChars (char [] chars, int offset, int count)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public override decimal ReadContentAsDecimal ()
+		{
+			return base.ReadContentAsDecimal ();
+		}
+
+		[MonoTODO]
+		public override float ReadContentAsFloat ()
+		{
+			return base.ReadContentAsFloat ();
+		}
+
+		public virtual Guid ReadContentAsGuid ()
+		{
+			return XmlConvert.ToGuid (ReadContentAsString ());
+		}
+
+		[MonoTODO]
+		public virtual void ReadContentAsQualifiedName (out string localName, out string namespaceUri)
+		{
+			throw new NotImplementedException ();
+		}
+
+		public override string ReadContentAsString ()
+		{
+			return ReadContentAsString (Quotas.MaxStringContentLength);
+		}
+
+		[MonoTODO]
+		protected string ReadContentAsString (int maxStringContentLength)
+		{
+			return base.ReadContentAsString ();
+		}
+
+		[MonoTODO]
+		public virtual string ReadContentAsString (string [] strings, out int index)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public virtual string ReadContentAsString (XmlDictionaryString [] strings, out int index)
+		{
+			throw new NotImplementedException ();
+		}
+
+		public virtual TimeSpan ReadContentAsTimeSpan ()
+		{
+			return XmlConvert.ToTimeSpan (ReadContentAsString ());
+		}
+
+		public virtual UniqueId ReadContentAsUniqueId ()
+		{
+			return new UniqueId (ReadContentAsString ());
+		}
+
+		public virtual byte [] ReadElementContentAsBase64 ()
+		{
+			ReadStartElement ();
+			byte [] ret = ReadContentAsBase64 ();
+			ReadEndElement ();
+			return ret;
+		}
+
+		public virtual byte [] ReadElementContentAsBinHex ()
+		{
+			ReadStartElement ();
+			byte [] ret = ReadContentAsBinHex ();
+			ReadEndElement ();
+			return ret;
+		}
+
+		public virtual Guid ReadElementContentAsGuid ()
+		{
+			ReadStartElement ();
+			Guid ret = ReadContentAsGuid ();
+			ReadEndElement ();
+			return ret;
+		}
+
+		public virtual TimeSpan ReadElementContentAsTimeSpan ()
+		{
+			ReadStartElement ();
+			TimeSpan ret = ReadContentAsTimeSpan ();
+			ReadEndElement ();
+			return ret;
+		}
+
+		public virtual UniqueId ReadElementContentAsUniqueId ()
+		{
+			ReadStartElement ();
+			UniqueId ret = ReadContentAsUniqueId ();
+			ReadEndElement ();
+			return ret;
+		}
+
+		public override string ReadElementContentAsString ()
+		{
+			if (IsEmptyElement) {
+				Read ();
+				return String.Empty;
+			} else {
+				ReadStartElement ();
+				string s;
+				if (NodeType == XmlNodeType.EndElement)
+					s = String.Empty;
+				else
+					s = ReadContentAsString ();
+				ReadEndElement ();
+				return s;
+			}
+		}
+
+		public override string ReadString ()
+		{
+			return ReadString (Quotas.MaxStringContentLength);
+		}
+
+		[MonoTODO]
+		protected string ReadString (int maxStringContentLength)
+		{
+			return base.ReadString ();
+		}
+
+		[MonoTODO]
+		public virtual byte [] ReadValueAsBase64 ()
+		{
+			return ReadContentAsBase64 ();
+		}
+
+		#endregion
+
+		#region Factory Methods
+
+		public static XmlDictionaryReader CreateBinaryReader (
+			byte [] buffer, XmlDictionaryReaderQuotas quotas)
+		{
+			return CreateBinaryReader (buffer, 0, buffer.Length, quotas);
+		}
+
+		public static XmlDictionaryReader CreateBinaryReader (
+			byte [] buffer, int offset, int count, 
+			XmlDictionaryReaderQuotas quotas)
+		{
+			return CreateBinaryReader (buffer, offset, count, new XmlDictionary (), quotas);
+		}
+
+		public static XmlDictionaryReader CreateBinaryReader (
+			byte [] buffer, int offset, int count,
+			IXmlDictionary dictionary,
+			XmlDictionaryReaderQuotas quotas)
+		{
+			return CreateBinaryReader (buffer, offset, count,
+				dictionary, quotas,
+				new XmlBinaryReaderSession (), null);
+		}
+
+		public static XmlDictionaryReader CreateBinaryReader (
+			byte [] buffer, int offset, int count,
+			IXmlDictionary dictionary,
+			XmlDictionaryReaderQuotas quotas,
+			XmlBinaryReaderSession session)
+		{
+			return CreateBinaryReader (buffer, offset, count,
+				dictionary, quotas,
+				session, null);
+		}
+
+		public static XmlDictionaryReader CreateBinaryReader (
+			byte [] buffer, int offset, int count,
+			IXmlDictionary dictionary,
+			XmlDictionaryReaderQuotas quotas,
+			XmlBinaryReaderSession session,
+			OnXmlDictionaryReaderClose onClose)
+		{
+			return new XmlBinaryDictionaryReader (buffer,
+				offset, count,
+				dictionary, quotas, session, onClose);
+		}
+
+		public static XmlDictionaryReader CreateBinaryReader (
+			Stream stream, XmlDictionaryReaderQuotas quotas)
+		{
+			return CreateBinaryReader (stream, new XmlDictionary (), quotas);
+		}
+
+		public static XmlDictionaryReader CreateBinaryReader (
+			Stream stream, IXmlDictionary dictionary, 
+			XmlDictionaryReaderQuotas quotas)
+		{
+			return CreateBinaryReader (stream, dictionary, quotas,
+				new XmlBinaryReaderSession (), null);
+		}
+
+		public static XmlDictionaryReader CreateBinaryReader (
+			Stream stream, IXmlDictionary dictionary, 
+			XmlDictionaryReaderQuotas quotas,
+			XmlBinaryReaderSession session)
+		{
+			return CreateBinaryReader (stream, dictionary, quotas,
+				session, null);
+		}
+
+		[MonoTODO]
+		public static XmlDictionaryReader CreateBinaryReader (
+			Stream stream, IXmlDictionary dictionary,
+			XmlDictionaryReaderQuotas quotas,
+			XmlBinaryReaderSession session,
+			OnXmlDictionaryReaderClose onClose)
+		{
+			return new XmlBinaryDictionaryReader (stream,
+				dictionary, quotas, session, onClose);
+		}
+
+		[MonoTODO]
+		public static XmlDictionaryReader CreateDictionaryReader (
+			XmlReader reader)
+		{
+			return new XmlSimpleDictionaryReader (reader);
+		}
+
+		[MonoTODO]
+		public static XmlDictionaryReader CreateMtomReader (
+			Stream stream, Encoding encoding,
+			XmlDictionaryReaderQuotas quotas)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public static XmlDictionaryReader CreateMtomReader (
+			Stream stream, Encoding [] encodings,
+			XmlDictionaryReaderQuotas quotas)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public static XmlDictionaryReader CreateMtomReader (
+			Stream stream, Encoding [] encodings, string contentType,
+			XmlDictionaryReaderQuotas quotas)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public static XmlDictionaryReader CreateMtomReader (
+			Stream stream, Encoding [] encodings, string contentType,
+			XmlDictionaryReaderQuotas quotas,
+			int maxBufferSize,
+			OnXmlDictionaryReaderClose onClose)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public static XmlDictionaryReader CreateMtomReader (
+			byte [] buffer, int offset, int count,
+			Encoding encoding, XmlDictionaryReaderQuotas quotas)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public static XmlDictionaryReader CreateMtomReader (
+			byte [] buffer, int offset, int count,
+			Encoding [] encodings, XmlDictionaryReaderQuotas quotas)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public static XmlDictionaryReader CreateMtomReader (
+			byte [] buffer, int offset, int count,
+			Encoding [] encodings, string contentType,
+			XmlDictionaryReaderQuotas quotas)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public static XmlDictionaryReader CreateMtomReader (
+			byte [] buffer, int offset, int count,
+			Encoding [] encodings, string contentType,
+			XmlDictionaryReaderQuotas quotas,
+			int maxBufferSize,
+			OnXmlDictionaryReaderClose onClose)
+		{
+			throw new NotImplementedException ();
+		}
+
+		public static XmlDictionaryReader CreateTextReader (byte [] buffer, XmlDictionaryReaderQuotas quotas)
+		{
+			return CreateTextReader (buffer, 0, buffer.Length, quotas);
+		}
+
+		public static XmlDictionaryReader CreateTextReader (
+			byte [] buffer, int offset, int count,
+			XmlDictionaryReaderQuotas quotas)
+		{
+			return CreateTextReader (buffer, offset, count,
+				Encoding.UTF8, quotas, null);
+		}
+
+		[MonoTODO]
+		public static XmlDictionaryReader CreateTextReader (
+			byte [] buffer, int offset, int count,
+			Encoding encoding,
+			XmlDictionaryReaderQuotas quotas,
+			OnXmlDictionaryReaderClose onClose)
+		{
+			return CreateTextReader (new MemoryStream (buffer, offset, count), encoding, quotas, onClose);
+		}
+
+		public static XmlDictionaryReader CreateTextReader (
+			Stream stream, XmlDictionaryReaderQuotas quotas)
+		{
+			return CreateTextReader (stream, Encoding.UTF8, quotas, null);
+		}
+
+		[MonoTODO]
+		public static XmlDictionaryReader CreateTextReader (
+			Stream stream, Encoding encoding,
+			XmlDictionaryReaderQuotas quotas,
+			OnXmlDictionaryReaderClose onClose)
+		{
+			XmlReaderSettings s = new XmlReaderSettings ();
+			XmlNameTable nt = new NameTable ();
+			XmlParserContext c = new XmlParserContext (nt, new XmlNamespaceManager (nt), String.Empty, XmlSpace.None, encoding);
+			XmlDictionaryReader res = new XmlSimpleDictionaryReader (XmlReader.Create (stream, s, c), null, onClose);
+			res.quotas = quotas;
+			return res;
+		}
+
+		#endregion
+	}
+}
+#endif

+ 522 - 0
mcs/class/System.Runtime.Serialization/System.Xml/XmlDictionaryReaderAutoGen.cs

@@ -0,0 +1,522 @@
+
+#pragma warning disable 612
+using System;
+using System.Collections.Generic;
+
+namespace System.Xml
+{
+	public abstract partial class XmlDictionaryReader : XmlReader
+	{
+		static readonly char [] wsChars = new char [] {' ', '\t', '\n', '\r'};
+
+		void CheckReadArrayArguments (Array array, int offset, int length)
+		{
+			if (array == null)
+				throw new ArgumentNullException ("array");
+			if (offset < 0)
+				throw new ArgumentOutOfRangeException ("offset is negative");
+			if (offset > array.Length)
+				throw new ArgumentOutOfRangeException ("offset exceeds the length of the destination array");
+			if (length < 0)
+				throw new ArgumentOutOfRangeException ("length is negative");
+			if (length > array.Length - offset)
+				throw new ArgumentOutOfRangeException ("length + offset exceeds the length of the destination array");
+		}
+
+		void CheckDictionaryStringArgs (XmlDictionaryString localName, XmlDictionaryString namespaceUri)
+		{
+			if (localName == null)
+				throw new ArgumentNullException ("localName");
+			if (namespaceUri == null)
+				throw new ArgumentNullException ("namespaceUri");
+		}
+
+
+		public virtual int ReadArray (XmlDictionaryString localName, XmlDictionaryString namespaceUri, bool [] array, int offset, int length)
+		{
+			CheckDictionaryStringArgs (localName, namespaceUri);
+			return ReadArray (localName.Value, namespaceUri.Value, array, offset, length);
+		}
+
+		public virtual int ReadArray (string localName, string namespaceUri, bool [] array, int offset, int length)
+		{
+			CheckReadArrayArguments (array, offset, length);
+			for (int i = 0; i < length; i++) {
+				MoveToContent ();
+				if (NodeType != XmlNodeType.Element)
+					return i;
+				ReadStartElement (localName, namespaceUri);
+				array [offset + i] = XmlConvert.ToBoolean (ReadContentAsString ());
+				ReadEndElement ();
+			}
+			return length;
+		}
+
+		public virtual bool [] ReadBooleanArray (string localName, string namespaceUri)
+		{
+			List<bool> list = new List<bool> ();
+			while (true) {
+				MoveToContent ();
+				if (NodeType != XmlNodeType.Element)
+					break;
+				ReadStartElement (localName, namespaceUri);
+				list.Add (XmlConvert.ToBoolean (ReadContentAsString ()));
+				ReadEndElement ();
+				if (list.Count == Quotas.MaxArrayLength)
+					// FIXME: check if raises an error or not
+					break;
+			}
+			return list.ToArray ();
+		}
+
+		public virtual bool [] ReadBooleanArray (XmlDictionaryString localName, XmlDictionaryString namespaceUri)
+		{
+			CheckDictionaryStringArgs (localName, namespaceUri);
+			return ReadBooleanArray (localName.Value, namespaceUri.Value);
+		}
+
+		public virtual int ReadArray (XmlDictionaryString localName, XmlDictionaryString namespaceUri, DateTime [] array, int offset, int length)
+		{
+			CheckDictionaryStringArgs (localName, namespaceUri);
+			return ReadArray (localName.Value, namespaceUri.Value, array, offset, length);
+		}
+
+		public virtual int ReadArray (string localName, string namespaceUri, DateTime [] array, int offset, int length)
+		{
+			CheckReadArrayArguments (array, offset, length);
+			for (int i = 0; i < length; i++) {
+				MoveToContent ();
+				if (NodeType != XmlNodeType.Element)
+					return i;
+				ReadStartElement (localName, namespaceUri);
+				array [offset + i] = XmlConvert.ToDateTime (ReadContentAsString ());
+				ReadEndElement ();
+			}
+			return length;
+		}
+
+		public virtual DateTime [] ReadDateTimeArray (string localName, string namespaceUri)
+		{
+			List<DateTime> list = new List<DateTime> ();
+			while (true) {
+				MoveToContent ();
+				if (NodeType != XmlNodeType.Element)
+					break;
+				ReadStartElement (localName, namespaceUri);
+				list.Add (XmlConvert.ToDateTime (ReadContentAsString ()));
+				ReadEndElement ();
+				if (list.Count == Quotas.MaxArrayLength)
+					// FIXME: check if raises an error or not
+					break;
+			}
+			return list.ToArray ();
+		}
+
+		public virtual DateTime [] ReadDateTimeArray (XmlDictionaryString localName, XmlDictionaryString namespaceUri)
+		{
+			CheckDictionaryStringArgs (localName, namespaceUri);
+			return ReadDateTimeArray (localName.Value, namespaceUri.Value);
+		}
+
+		public virtual int ReadArray (XmlDictionaryString localName, XmlDictionaryString namespaceUri, decimal [] array, int offset, int length)
+		{
+			CheckDictionaryStringArgs (localName, namespaceUri);
+			return ReadArray (localName.Value, namespaceUri.Value, array, offset, length);
+		}
+
+		public virtual int ReadArray (string localName, string namespaceUri, decimal [] array, int offset, int length)
+		{
+			CheckReadArrayArguments (array, offset, length);
+			for (int i = 0; i < length; i++) {
+				MoveToContent ();
+				if (NodeType != XmlNodeType.Element)
+					return i;
+				ReadStartElement (localName, namespaceUri);
+				array [offset + i] = XmlConvert.ToDecimal (ReadContentAsString ());
+				ReadEndElement ();
+			}
+			return length;
+		}
+
+		public virtual decimal [] ReadDecimalArray (string localName, string namespaceUri)
+		{
+			List<decimal> list = new List<decimal> ();
+			while (true) {
+				MoveToContent ();
+				if (NodeType != XmlNodeType.Element)
+					break;
+				ReadStartElement (localName, namespaceUri);
+				list.Add (XmlConvert.ToDecimal (ReadContentAsString ()));
+				ReadEndElement ();
+				if (list.Count == Quotas.MaxArrayLength)
+					// FIXME: check if raises an error or not
+					break;
+			}
+			return list.ToArray ();
+		}
+
+		public virtual decimal [] ReadDecimalArray (XmlDictionaryString localName, XmlDictionaryString namespaceUri)
+		{
+			CheckDictionaryStringArgs (localName, namespaceUri);
+			return ReadDecimalArray (localName.Value, namespaceUri.Value);
+		}
+
+		public virtual int ReadArray (XmlDictionaryString localName, XmlDictionaryString namespaceUri, double [] array, int offset, int length)
+		{
+			CheckDictionaryStringArgs (localName, namespaceUri);
+			return ReadArray (localName.Value, namespaceUri.Value, array, offset, length);
+		}
+
+		public virtual int ReadArray (string localName, string namespaceUri, double [] array, int offset, int length)
+		{
+			CheckReadArrayArguments (array, offset, length);
+			for (int i = 0; i < length; i++) {
+				MoveToContent ();
+				if (NodeType != XmlNodeType.Element)
+					return i;
+				ReadStartElement (localName, namespaceUri);
+				array [offset + i] = XmlConvert.ToDouble (ReadContentAsString ());
+				ReadEndElement ();
+			}
+			return length;
+		}
+
+		public virtual double [] ReadDoubleArray (string localName, string namespaceUri)
+		{
+			List<double> list = new List<double> ();
+			while (true) {
+				MoveToContent ();
+				if (NodeType != XmlNodeType.Element)
+					break;
+				ReadStartElement (localName, namespaceUri);
+				list.Add (XmlConvert.ToDouble (ReadContentAsString ()));
+				ReadEndElement ();
+				if (list.Count == Quotas.MaxArrayLength)
+					// FIXME: check if raises an error or not
+					break;
+			}
+			return list.ToArray ();
+		}
+
+		public virtual double [] ReadDoubleArray (XmlDictionaryString localName, XmlDictionaryString namespaceUri)
+		{
+			CheckDictionaryStringArgs (localName, namespaceUri);
+			return ReadDoubleArray (localName.Value, namespaceUri.Value);
+		}
+
+		public virtual int ReadArray (XmlDictionaryString localName, XmlDictionaryString namespaceUri, Guid [] array, int offset, int length)
+		{
+			CheckDictionaryStringArgs (localName, namespaceUri);
+			return ReadArray (localName.Value, namespaceUri.Value, array, offset, length);
+		}
+
+		public virtual int ReadArray (string localName, string namespaceUri, Guid [] array, int offset, int length)
+		{
+			CheckReadArrayArguments (array, offset, length);
+			for (int i = 0; i < length; i++) {
+				MoveToContent ();
+				if (NodeType != XmlNodeType.Element)
+					return i;
+				ReadStartElement (localName, namespaceUri);
+				array [offset + i] = XmlConvert.ToGuid (ReadContentAsString ());
+				ReadEndElement ();
+			}
+			return length;
+		}
+
+		public virtual Guid [] ReadGuidArray (string localName, string namespaceUri)
+		{
+			List<Guid> list = new List<Guid> ();
+			while (true) {
+				MoveToContent ();
+				if (NodeType != XmlNodeType.Element)
+					break;
+				ReadStartElement (localName, namespaceUri);
+				list.Add (XmlConvert.ToGuid (ReadContentAsString ()));
+				ReadEndElement ();
+				if (list.Count == Quotas.MaxArrayLength)
+					// FIXME: check if raises an error or not
+					break;
+			}
+			return list.ToArray ();
+		}
+
+		public virtual Guid [] ReadGuidArray (XmlDictionaryString localName, XmlDictionaryString namespaceUri)
+		{
+			CheckDictionaryStringArgs (localName, namespaceUri);
+			return ReadGuidArray (localName.Value, namespaceUri.Value);
+		}
+
+		public virtual int ReadArray (XmlDictionaryString localName, XmlDictionaryString namespaceUri, short [] array, int offset, int length)
+		{
+			CheckDictionaryStringArgs (localName, namespaceUri);
+			return ReadArray (localName.Value, namespaceUri.Value, array, offset, length);
+		}
+
+		public virtual int ReadArray (string localName, string namespaceUri, short [] array, int offset, int length)
+		{
+			CheckReadArrayArguments (array, offset, length);
+			for (int i = 0; i < length; i++) {
+				MoveToContent ();
+				if (NodeType != XmlNodeType.Element)
+					return i;
+				ReadStartElement (localName, namespaceUri);
+				array [offset + i] = XmlConvert.ToInt16 (ReadContentAsString ());
+				ReadEndElement ();
+			}
+			return length;
+		}
+
+		public virtual short [] ReadInt16Array (string localName, string namespaceUri)
+		{
+			List<short> list = new List<short> ();
+			while (true) {
+				MoveToContent ();
+				if (NodeType != XmlNodeType.Element)
+					break;
+				ReadStartElement (localName, namespaceUri);
+				list.Add (XmlConvert.ToInt16 (ReadContentAsString ()));
+				ReadEndElement ();
+				if (list.Count == Quotas.MaxArrayLength)
+					// FIXME: check if raises an error or not
+					break;
+			}
+			return list.ToArray ();
+		}
+
+		public virtual short [] ReadInt16Array (XmlDictionaryString localName, XmlDictionaryString namespaceUri)
+		{
+			CheckDictionaryStringArgs (localName, namespaceUri);
+			return ReadInt16Array (localName.Value, namespaceUri.Value);
+		}
+
+		public virtual int ReadArray (XmlDictionaryString localName, XmlDictionaryString namespaceUri, int [] array, int offset, int length)
+		{
+			CheckDictionaryStringArgs (localName, namespaceUri);
+			return ReadArray (localName.Value, namespaceUri.Value, array, offset, length);
+		}
+
+		public virtual int ReadArray (string localName, string namespaceUri, int [] array, int offset, int length)
+		{
+			CheckReadArrayArguments (array, offset, length);
+			for (int i = 0; i < length; i++) {
+				MoveToContent ();
+				if (NodeType != XmlNodeType.Element)
+					return i;
+				ReadStartElement (localName, namespaceUri);
+				array [offset + i] = XmlConvert.ToInt32 (ReadContentAsString ());
+				ReadEndElement ();
+			}
+			return length;
+		}
+
+		public virtual int [] ReadInt32Array (string localName, string namespaceUri)
+		{
+			List<int> list = new List<int> ();
+			while (true) {
+				MoveToContent ();
+				if (NodeType != XmlNodeType.Element)
+					break;
+				ReadStartElement (localName, namespaceUri);
+				list.Add (XmlConvert.ToInt32 (ReadContentAsString ()));
+				ReadEndElement ();
+				if (list.Count == Quotas.MaxArrayLength)
+					// FIXME: check if raises an error or not
+					break;
+			}
+			return list.ToArray ();
+		}
+
+		public virtual int [] ReadInt32Array (XmlDictionaryString localName, XmlDictionaryString namespaceUri)
+		{
+			CheckDictionaryStringArgs (localName, namespaceUri);
+			return ReadInt32Array (localName.Value, namespaceUri.Value);
+		}
+
+		public virtual int ReadArray (XmlDictionaryString localName, XmlDictionaryString namespaceUri, long [] array, int offset, int length)
+		{
+			CheckDictionaryStringArgs (localName, namespaceUri);
+			return ReadArray (localName.Value, namespaceUri.Value, array, offset, length);
+		}
+
+		public virtual int ReadArray (string localName, string namespaceUri, long [] array, int offset, int length)
+		{
+			CheckReadArrayArguments (array, offset, length);
+			for (int i = 0; i < length; i++) {
+				MoveToContent ();
+				if (NodeType != XmlNodeType.Element)
+					return i;
+				ReadStartElement (localName, namespaceUri);
+				array [offset + i] = XmlConvert.ToInt64 (ReadContentAsString ());
+				ReadEndElement ();
+			}
+			return length;
+		}
+
+		public virtual long [] ReadInt64Array (string localName, string namespaceUri)
+		{
+			List<long> list = new List<long> ();
+			while (true) {
+				MoveToContent ();
+				if (NodeType != XmlNodeType.Element)
+					break;
+				ReadStartElement (localName, namespaceUri);
+				list.Add (XmlConvert.ToInt64 (ReadContentAsString ()));
+				ReadEndElement ();
+				if (list.Count == Quotas.MaxArrayLength)
+					// FIXME: check if raises an error or not
+					break;
+			}
+			return list.ToArray ();
+		}
+
+		public virtual long [] ReadInt64Array (XmlDictionaryString localName, XmlDictionaryString namespaceUri)
+		{
+			CheckDictionaryStringArgs (localName, namespaceUri);
+			return ReadInt64Array (localName.Value, namespaceUri.Value);
+		}
+
+		public virtual int ReadArray (XmlDictionaryString localName, XmlDictionaryString namespaceUri, float [] array, int offset, int length)
+		{
+			CheckDictionaryStringArgs (localName, namespaceUri);
+			return ReadArray (localName.Value, namespaceUri.Value, array, offset, length);
+		}
+
+		public virtual int ReadArray (string localName, string namespaceUri, float [] array, int offset, int length)
+		{
+			CheckReadArrayArguments (array, offset, length);
+			for (int i = 0; i < length; i++) {
+				MoveToContent ();
+				if (NodeType != XmlNodeType.Element)
+					return i;
+				ReadStartElement (localName, namespaceUri);
+				array [offset + i] = XmlConvert.ToSingle (ReadContentAsString ());
+				ReadEndElement ();
+			}
+			return length;
+		}
+
+		public virtual float [] ReadSingleArray (string localName, string namespaceUri)
+		{
+			List<float> list = new List<float> ();
+			while (true) {
+				MoveToContent ();
+				if (NodeType != XmlNodeType.Element)
+					break;
+				ReadStartElement (localName, namespaceUri);
+				list.Add (XmlConvert.ToSingle (ReadContentAsString ()));
+				ReadEndElement ();
+				if (list.Count == Quotas.MaxArrayLength)
+					// FIXME: check if raises an error or not
+					break;
+			}
+			return list.ToArray ();
+		}
+
+		public virtual float [] ReadSingleArray (XmlDictionaryString localName, XmlDictionaryString namespaceUri)
+		{
+			CheckDictionaryStringArgs (localName, namespaceUri);
+			return ReadSingleArray (localName.Value, namespaceUri.Value);
+		}
+
+		public virtual int ReadArray (XmlDictionaryString localName, XmlDictionaryString namespaceUri, TimeSpan [] array, int offset, int length)
+		{
+			CheckDictionaryStringArgs (localName, namespaceUri);
+			return ReadArray (localName.Value, namespaceUri.Value, array, offset, length);
+		}
+
+		public virtual int ReadArray (string localName, string namespaceUri, TimeSpan [] array, int offset, int length)
+		{
+			CheckReadArrayArguments (array, offset, length);
+			for (int i = 0; i < length; i++) {
+				MoveToContent ();
+				if (NodeType != XmlNodeType.Element)
+					return i;
+				ReadStartElement (localName, namespaceUri);
+				array [offset + i] = XmlConvert.ToTimeSpan (ReadContentAsString ());
+				ReadEndElement ();
+			}
+			return length;
+		}
+
+		public virtual TimeSpan [] ReadTimeSpanArray (string localName, string namespaceUri)
+		{
+			List<TimeSpan> list = new List<TimeSpan> ();
+			while (true) {
+				MoveToContent ();
+				if (NodeType != XmlNodeType.Element)
+					break;
+				ReadStartElement (localName, namespaceUri);
+				list.Add (XmlConvert.ToTimeSpan (ReadContentAsString ()));
+				ReadEndElement ();
+				if (list.Count == Quotas.MaxArrayLength)
+					// FIXME: check if raises an error or not
+					break;
+			}
+			return list.ToArray ();
+		}
+
+		public virtual TimeSpan [] ReadTimeSpanArray (XmlDictionaryString localName, XmlDictionaryString namespaceUri)
+		{
+			CheckDictionaryStringArgs (localName, namespaceUri);
+			return ReadTimeSpanArray (localName.Value, namespaceUri.Value);
+		}
+
+		public override bool ReadElementContentAsBoolean ()
+		{
+			ReadStartElement (LocalName, NamespaceURI);
+			bool ret = ReadContentAsBoolean ();
+			ReadEndElement ();
+			return ret;
+		}
+
+		public override DateTime ReadElementContentAsDateTime ()
+		{
+			ReadStartElement (LocalName, NamespaceURI);
+			DateTime ret = ReadContentAsDateTime ();
+			ReadEndElement ();
+			return ret;
+		}
+
+		public override decimal ReadElementContentAsDecimal ()
+		{
+			ReadStartElement (LocalName, NamespaceURI);
+			decimal ret = ReadContentAsDecimal ();
+			ReadEndElement ();
+			return ret;
+		}
+
+		public override double ReadElementContentAsDouble ()
+		{
+			ReadStartElement (LocalName, NamespaceURI);
+			double ret = ReadContentAsDouble ();
+			ReadEndElement ();
+			return ret;
+		}
+
+		public override float ReadElementContentAsFloat ()
+		{
+			ReadStartElement (LocalName, NamespaceURI);
+			float ret = ReadContentAsFloat ();
+			ReadEndElement ();
+			return ret;
+		}
+
+		public override int ReadElementContentAsInt ()
+		{
+			ReadStartElement (LocalName, NamespaceURI);
+			int ret = ReadContentAsInt ();
+			ReadEndElement ();
+			return ret;
+		}
+
+		public override long ReadElementContentAsLong ()
+		{
+			ReadStartElement (LocalName, NamespaceURI);
+			long ret = ReadContentAsLong ();
+			ReadEndElement ();
+			return ret;
+		}
+
+	}
+}

+ 106 - 0
mcs/class/System.Runtime.Serialization/System.Xml/XmlDictionaryReaderQuotas.cs

@@ -0,0 +1,106 @@
+//
+// XmlDictionaryReaderQuotas.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+namespace System.Xml
+{
+	public sealed class XmlDictionaryReaderQuotas
+	{
+		static XmlDictionaryReaderQuotas max;
+
+		static XmlDictionaryReaderQuotas ()
+		{
+			max = new XmlDictionaryReaderQuotas (true);
+		}
+
+		readonly bool is_readonly;
+		int array_len, bytes, depth, nt_chars, text_len;
+
+		public XmlDictionaryReaderQuotas ()
+			: this (false)
+		{
+		}
+
+		private XmlDictionaryReaderQuotas (bool max)
+		{
+			is_readonly = max;
+			array_len = max ? int.MaxValue : 0x4000;
+			bytes = max ? int.MaxValue : 0x1000;
+			depth = max ? int.MaxValue : 0x20;
+			nt_chars = max ? int.MaxValue : 0x4000;
+			text_len = max ? int.MaxValue : 0x2000;
+		}
+
+		public static XmlDictionaryReaderQuotas Max {
+			get { return max; }
+		}
+
+		public int MaxArrayLength {
+			get { return array_len; }
+			set { array_len = Check (value); }
+		}
+
+		public int MaxBytesPerRead {
+			get { return bytes; }
+			set { bytes = Check (value); }
+		}
+
+		public int MaxDepth {
+			get { return depth; }
+			set { depth = Check (value); }
+		}
+
+		public int MaxNameTableCharCount {
+			get { return nt_chars; }
+			set { nt_chars = Check (value); }
+		}
+
+		public int MaxStringContentLength {
+			get { return text_len; }
+			set { text_len = Check (value); }
+		}
+
+		private int Check (int value)
+		{
+			if (is_readonly)
+				throw new InvalidOperationException ("This quota is read-only.");
+			if (value <= 0)
+				throw new ArgumentException ("Value must be positive integer.");
+			return value;
+		}
+
+		public void CopyTo (XmlDictionaryReaderQuotas quota)
+		{
+			quota.array_len = array_len;
+			quota.bytes = bytes;
+			quota.depth = depth;
+			quota.nt_chars = nt_chars;
+			quota.text_len = text_len;
+		}
+	}
+}
+#endif

+ 74 - 0
mcs/class/System.Runtime.Serialization/System.Xml/XmlDictionaryString.cs

@@ -0,0 +1,74 @@
+//
+// XmlDictionaryString.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+using System;
+using System.Collections;
+
+namespace System.Xml
+{
+	public class XmlDictionaryString
+	{
+		static XmlDictionaryString empty = new XmlDictionaryString (
+			XmlDictionary.EmptyDictionary.Instance,
+			String.Empty, 0);
+
+		public static XmlDictionaryString Empty {
+			get { return empty; }
+		}
+
+		readonly IXmlDictionary dict;
+		readonly string value;
+		readonly int key;
+
+		public XmlDictionaryString (IXmlDictionary dictionary,
+			string value, int key)
+		{
+			this.dict = dictionary;
+			this.value = value;
+			this.key = key;
+		}
+
+		public IXmlDictionary Dictionary {
+			get { return dict; }
+		}
+
+		public int Key {
+			get { return key; }
+		}
+
+		public string Value {
+			get { return value; }
+		}
+
+		public override string ToString ()
+		{
+			return value;
+		}
+	}
+}
+#endif

+ 309 - 0
mcs/class/System.Runtime.Serialization/System.Xml/XmlDictionaryWriter.cs

@@ -0,0 +1,309 @@
+//
+// XmlDictionaryWriter.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+using System;
+using System.IO;
+using System.Text;
+
+namespace System.Xml
+{
+	public abstract partial class XmlDictionaryWriter : XmlWriter
+	{
+		static readonly Encoding utf8_unmarked = new UTF8Encoding (false);
+
+		int depth;
+
+		protected XmlDictionaryWriter ()
+		{
+		}
+
+		internal int Depth {
+			get { return depth; }
+			set { depth = value; }
+		}
+
+		public virtual bool CanCanonicalize {
+			get { return false; }
+		}
+
+		public static XmlDictionaryWriter CreateBinaryWriter (
+			Stream stream)
+		{
+			return CreateBinaryWriter (stream, null, null, false);
+		}
+
+		public static XmlDictionaryWriter CreateBinaryWriter (
+			Stream stream, IXmlDictionary dictionary)
+		{
+			return CreateBinaryWriter (stream, dictionary, null, false);
+		}
+
+		public static XmlDictionaryWriter CreateBinaryWriter (
+			Stream stream, IXmlDictionary dictionary,
+			XmlBinaryWriterSession session)
+		{
+			return CreateBinaryWriter (stream, dictionary, session, false);
+		}
+
+		public static XmlDictionaryWriter CreateBinaryWriter (
+			Stream stream, IXmlDictionary dictionary,
+			XmlBinaryWriterSession session, bool ownsStream)
+		{
+			return new XmlBinaryDictionaryWriter (stream,
+				dictionary, session, ownsStream);
+		}
+
+		public static XmlDictionaryWriter CreateDictionaryWriter (XmlWriter writer)
+		{
+			return new XmlSimpleDictionaryWriter (writer);
+		}
+
+		[MonoTODO]
+		public static XmlDictionaryWriter CreateMtomWriter (
+			Stream stream, Encoding encoding, int maxSizeInBytes,
+			string startInfo)
+		{
+			return CreateMtomWriter (stream, encoding,
+				maxSizeInBytes, startInfo, null, null, false, false);
+		}
+
+		[MonoTODO]
+		public static XmlDictionaryWriter CreateMtomWriter (
+			Stream stream, Encoding encoding, int maxSizeInBytes,
+			string startInfo, string boundary, string startUri,
+			bool writeMessageHeaders, bool ownsStream)
+		{
+			throw new NotImplementedException ();
+		}
+
+		public static XmlDictionaryWriter CreateTextWriter (
+			Stream stream)
+		{
+			return CreateTextWriter (stream, Encoding.UTF8);
+		}
+
+		public static XmlDictionaryWriter CreateTextWriter (
+			Stream stream, Encoding encoding)
+		{
+			return CreateTextWriter (stream, encoding, false);
+		}
+
+		// BTW looks like it creates an instance of different
+		// implementation than those from XmlWriter.Create().
+		public static XmlDictionaryWriter CreateTextWriter (
+			Stream stream, Encoding encoding, bool ownsStream)
+		{
+			if (stream == null)
+				throw new ArgumentNullException ("stream");
+			if (encoding == null)
+				throw new ArgumentNullException ("encoding");
+
+			switch (encoding.CodePage) {
+			case 1200:
+			case 1201: // utf-16
+			case 65001: // utf-8
+				encoding = utf8_unmarked;
+				break;
+			default:
+				throw new XmlException (String.Format ("XML declaration is required for encoding code page {0} but this XmlWriter does not support XML declaration.", encoding.CodePage));
+			}
+
+			XmlWriterSettings s = new XmlWriterSettings ();
+			s.Encoding = encoding;
+			s.CloseOutput = ownsStream;
+			s.OmitXmlDeclaration = true;
+			return CreateDictionaryWriter (XmlWriter.Create (stream, s));
+		}
+
+		public virtual void EndCanonicalization ()
+		{
+			throw new NotSupportedException ();
+		}
+
+		public virtual void StartCanonicalization (
+			Stream stream, bool includeComments,
+			string [] inclusivePrefixes)
+		{
+			throw new NotSupportedException ();
+		}
+
+		// FIXME: add Write*Array() overloads.
+
+		public void WriteAttributeString (
+			XmlDictionaryString localName,
+			XmlDictionaryString namespaceUri,
+			string value)
+		{
+			WriteAttributeString (null, localName, namespaceUri, value);
+		}
+
+		public void WriteAttributeString (string prefix,
+			XmlDictionaryString localName,
+			XmlDictionaryString namespaceUri,
+			string value)
+		{
+			WriteStartAttribute (prefix, localName, namespaceUri);
+			WriteString (value);
+			WriteEndAttribute ();
+		}
+
+		public void WriteElementString (
+			XmlDictionaryString localName,
+			XmlDictionaryString namespaceUri,
+			string value)
+		{
+			WriteElementString (null, localName, namespaceUri, value);
+		}
+
+		public void WriteElementString (string prefix,
+			XmlDictionaryString localName,
+			XmlDictionaryString namespaceUri,
+			string value)
+		{
+			WriteStartElement (prefix, localName, namespaceUri);
+			WriteString (value);
+			WriteEndElement ();
+		}
+
+		[MonoTODO ("make use of dictionary reader optimization")]
+		public virtual void WriteNode (XmlDictionaryReader reader,
+			bool defattr)
+		{
+			WriteNode ((XmlReader) reader, defattr);
+		}
+
+		[MonoTODO ("make use of dictionary reader optimization")]
+		public override void WriteNode (XmlReader reader, bool defattr)
+		{
+			base.WriteNode (reader, defattr);
+		}
+
+		public virtual void WriteQualifiedName (
+			XmlDictionaryString localName,
+			XmlDictionaryString namespaceUri)
+		{
+			WriteQualifiedName (localName.Value, namespaceUri.Value);
+		}
+
+		public void WriteStartAttribute (
+			XmlDictionaryString localName,
+			XmlDictionaryString namespaceUri)
+		{
+			WriteStartAttribute (localName.Value, namespaceUri.Value);
+		}
+
+		public virtual void WriteStartAttribute (string prefix,
+			XmlDictionaryString localName,
+			XmlDictionaryString namespaceUri)
+		{
+			WriteStartAttribute (prefix, localName.Value, namespaceUri.Value);
+		}
+
+		public void WriteStartElement (
+			XmlDictionaryString localName,
+			XmlDictionaryString namespaceUri)
+		{
+			WriteStartElement (null, localName, namespaceUri);
+		}
+
+		public virtual void WriteStartElement (string prefix,
+			XmlDictionaryString localName,
+			XmlDictionaryString namespaceUri)
+		{
+			WriteStartElement (prefix, localName.Value, namespaceUri.Value);
+		}
+
+		public virtual void WriteString (XmlDictionaryString value)
+		{
+			WriteString (value.Value);
+		}
+
+		public virtual void WriteValue (Guid guid)
+		{
+			throw new NotSupportedException ();
+		}
+
+		public virtual void WriteValue (TimeSpan duration)
+		{
+			throw new NotSupportedException ();
+		}
+
+		public virtual void WriteValue (UniqueId id)
+		{
+			throw new NotSupportedException ();
+		}
+
+		public virtual void WriteValue (XmlDictionaryString value)
+		{
+			WriteValue (value.Value);
+		}
+
+		public virtual void WriteXmlAttribute (string localName, string value)
+		{
+			WriteAttributeString ("xml", localName, "http://www.w3.org/XML/1998/namespace", value);
+		}
+
+		public virtual void WriteXmlAttribute (XmlDictionaryString localName,
+			XmlDictionaryString value)
+		{
+			WriteXmlAttribute (localName.Value, value.Value);
+		}
+
+		public virtual void WriteXmlnsAttribute (
+			string prefix, string namespaceUri)
+		{
+			// BTW .NET 2.0 those XmlWriters from XmlWrite.Create()
+			// rejects namespace overriding i.e.
+			//
+			//	xw.WriteStartElement ("foo", "urn:foo");
+			//	xw.WriteXmlnsAttribute ("foo", "urn:bar");
+			//
+			// causes an XmlException. We need fix in sys.xml.dll
+
+			// When the prefix is null, this writer must mock
+			// a dummy namespace up. It is then up to the actual
+			// writer how it is determined in the output. (When
+			// there is a duplicate, then it will be further 
+			// modified.)
+			if (prefix == null)
+				prefix = "d" + Depth + "p1";
+
+			if (prefix == String.Empty)
+				WriteAttributeString ("xmlns", namespaceUri);
+			else
+				WriteAttributeString ("xmlns", prefix, "http://www.w3.org/2000/xmlns/", namespaceUri);
+		}
+
+		public virtual void WriteXmlnsAttribute (string prefix,
+			XmlDictionaryString namespaceUri)
+		{
+			WriteXmlnsAttribute (prefix, namespaceUri.Value);
+		}
+	}
+}
+#endif

+ 202 - 0
mcs/class/System.Runtime.Serialization/System.Xml/XmlDictionaryWriterAutoGen.cs

@@ -0,0 +1,202 @@
+
+using System;
+
+namespace System.Xml
+{
+	public abstract partial class XmlDictionaryWriter : XmlWriter
+	{
+		void CheckWriteArrayArguments (Array array, int offset, int length)
+		{
+			if (array == null)
+				throw new ArgumentNullException ("array");
+			if (offset < 0)
+				throw new ArgumentOutOfRangeException ("offset is negative");
+			if (offset > array.Length)
+				throw new ArgumentOutOfRangeException ("offset exceeds the length of the destination array");
+			if (length < 0)
+				throw new ArgumentOutOfRangeException ("length is negative");
+			if (length > array.Length - offset)
+				throw new ArgumentOutOfRangeException ("length + offset exceeds the length of the destination array");
+		}
+
+		void CheckDictionaryStringArgs (XmlDictionaryString localName, XmlDictionaryString namespaceUri)
+		{
+			if (localName == null)
+				throw new ArgumentNullException ("localName");
+			if (namespaceUri == null)
+				throw new ArgumentNullException ("namespaceUri");
+		}
+
+
+		public virtual void WriteArray (string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, bool [] array, int offset, int length)
+		{
+			CheckDictionaryStringArgs (localName, namespaceUri);
+			WriteArray (prefix, localName.Value, namespaceUri.Value, array, offset, length);
+		}
+
+		public virtual void WriteArray (string prefix, string localName, string namespaceUri, bool [] array, int offset, int length)
+		{
+			CheckWriteArrayArguments (array, offset, length);
+			for (int i = 0; i < length; i++) {
+				WriteStartElement (prefix, localName, namespaceUri);
+				WriteValue (array [offset + i]);
+				WriteEndElement ();
+			}
+
+		}
+
+		public virtual void WriteArray (string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, DateTime [] array, int offset, int length)
+		{
+			CheckDictionaryStringArgs (localName, namespaceUri);
+			WriteArray (prefix, localName.Value, namespaceUri.Value, array, offset, length);
+		}
+
+		public virtual void WriteArray (string prefix, string localName, string namespaceUri, DateTime [] array, int offset, int length)
+		{
+			CheckWriteArrayArguments (array, offset, length);
+			for (int i = 0; i < length; i++) {
+				WriteStartElement (prefix, localName, namespaceUri);
+				WriteValue (array [offset + i]);
+				WriteEndElement ();
+			}
+
+		}
+
+		public virtual void WriteArray (string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, decimal [] array, int offset, int length)
+		{
+			CheckDictionaryStringArgs (localName, namespaceUri);
+			WriteArray (prefix, localName.Value, namespaceUri.Value, array, offset, length);
+		}
+
+		public virtual void WriteArray (string prefix, string localName, string namespaceUri, decimal [] array, int offset, int length)
+		{
+			CheckWriteArrayArguments (array, offset, length);
+			for (int i = 0; i < length; i++) {
+				WriteStartElement (prefix, localName, namespaceUri);
+				WriteValue (array [offset + i]);
+				WriteEndElement ();
+			}
+
+		}
+
+		public virtual void WriteArray (string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, double [] array, int offset, int length)
+		{
+			CheckDictionaryStringArgs (localName, namespaceUri);
+			WriteArray (prefix, localName.Value, namespaceUri.Value, array, offset, length);
+		}
+
+		public virtual void WriteArray (string prefix, string localName, string namespaceUri, double [] array, int offset, int length)
+		{
+			CheckWriteArrayArguments (array, offset, length);
+			for (int i = 0; i < length; i++) {
+				WriteStartElement (prefix, localName, namespaceUri);
+				WriteValue (array [offset + i]);
+				WriteEndElement ();
+			}
+
+		}
+
+		public virtual void WriteArray (string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, Guid [] array, int offset, int length)
+		{
+			CheckDictionaryStringArgs (localName, namespaceUri);
+			WriteArray (prefix, localName.Value, namespaceUri.Value, array, offset, length);
+		}
+
+		public virtual void WriteArray (string prefix, string localName, string namespaceUri, Guid [] array, int offset, int length)
+		{
+			CheckWriteArrayArguments (array, offset, length);
+			for (int i = 0; i < length; i++) {
+				WriteStartElement (prefix, localName, namespaceUri);
+				WriteValue (array [offset + i]);
+				WriteEndElement ();
+			}
+
+		}
+
+		public virtual void WriteArray (string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, short [] array, int offset, int length)
+		{
+			CheckDictionaryStringArgs (localName, namespaceUri);
+			WriteArray (prefix, localName.Value, namespaceUri.Value, array, offset, length);
+		}
+
+		public virtual void WriteArray (string prefix, string localName, string namespaceUri, short [] array, int offset, int length)
+		{
+			CheckWriteArrayArguments (array, offset, length);
+			for (int i = 0; i < length; i++) {
+				WriteStartElement (prefix, localName, namespaceUri);
+				WriteValue (array [offset + i]);
+				WriteEndElement ();
+			}
+
+		}
+
+		public virtual void WriteArray (string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, int [] array, int offset, int length)
+		{
+			CheckDictionaryStringArgs (localName, namespaceUri);
+			WriteArray (prefix, localName.Value, namespaceUri.Value, array, offset, length);
+		}
+
+		public virtual void WriteArray (string prefix, string localName, string namespaceUri, int [] array, int offset, int length)
+		{
+			CheckWriteArrayArguments (array, offset, length);
+			for (int i = 0; i < length; i++) {
+				WriteStartElement (prefix, localName, namespaceUri);
+				WriteValue (array [offset + i]);
+				WriteEndElement ();
+			}
+
+		}
+
+		public virtual void WriteArray (string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, long [] array, int offset, int length)
+		{
+			CheckDictionaryStringArgs (localName, namespaceUri);
+			WriteArray (prefix, localName.Value, namespaceUri.Value, array, offset, length);
+		}
+
+		public virtual void WriteArray (string prefix, string localName, string namespaceUri, long [] array, int offset, int length)
+		{
+			CheckWriteArrayArguments (array, offset, length);
+			for (int i = 0; i < length; i++) {
+				WriteStartElement (prefix, localName, namespaceUri);
+				WriteValue (array [offset + i]);
+				WriteEndElement ();
+			}
+
+		}
+
+		public virtual void WriteArray (string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, float [] array, int offset, int length)
+		{
+			CheckDictionaryStringArgs (localName, namespaceUri);
+			WriteArray (prefix, localName.Value, namespaceUri.Value, array, offset, length);
+		}
+
+		public virtual void WriteArray (string prefix, string localName, string namespaceUri, float [] array, int offset, int length)
+		{
+			CheckWriteArrayArguments (array, offset, length);
+			for (int i = 0; i < length; i++) {
+				WriteStartElement (prefix, localName, namespaceUri);
+				WriteValue (array [offset + i]);
+				WriteEndElement ();
+			}
+
+		}
+
+		public virtual void WriteArray (string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, TimeSpan [] array, int offset, int length)
+		{
+			CheckDictionaryStringArgs (localName, namespaceUri);
+			WriteArray (prefix, localName.Value, namespaceUri.Value, array, offset, length);
+		}
+
+		public virtual void WriteArray (string prefix, string localName, string namespaceUri, TimeSpan [] array, int offset, int length)
+		{
+			CheckWriteArrayArguments (array, offset, length);
+			for (int i = 0; i < length; i++) {
+				WriteStartElement (prefix, localName, namespaceUri);
+				WriteValue (array [offset + i]);
+				WriteEndElement ();
+			}
+
+		}
+
+	}
+}

+ 302 - 0
mcs/class/System.Runtime.Serialization/System.Xml/XmlSimpleDictionaryReader.cs

@@ -0,0 +1,302 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+
+namespace System.Xml
+{
+	internal class XmlSimpleDictionaryReader :
+		XmlDictionaryReader, IXmlLineInfo, IXmlNamespaceResolver
+	{
+		XmlDictionary dict;
+		XmlReader reader;
+		XmlDictionaryReader as_dict_reader;
+		IXmlLineInfo as_line_info;
+		OnXmlDictionaryReaderClose onClose;
+
+		public XmlSimpleDictionaryReader (XmlReader reader)
+			: this (reader, null)
+		{
+		}
+
+		public XmlSimpleDictionaryReader (XmlReader reader,
+			XmlDictionary dictionary)
+			: this (reader, dictionary, null)
+		{
+		}
+
+		public XmlSimpleDictionaryReader (XmlReader reader,
+			XmlDictionary dictionary, OnXmlDictionaryReaderClose onClose)
+		{
+			this.reader = reader;
+			this.onClose = onClose;
+			as_line_info = reader as IXmlLineInfo;
+			as_dict_reader = reader as XmlDictionaryReader;
+
+			if (dictionary == null)
+				dictionary = new XmlDictionary ();
+			dict = dictionary;
+		}
+
+		#region IXmlLineInfo
+		public int LineNumber {
+			get { return as_line_info != null ? as_line_info.LineNumber : 0; }
+		}
+
+		public int LinePosition {
+			get { return as_line_info != null ? as_line_info.LinePosition : 0; }
+		}
+
+		public bool HasLineInfo ()
+		{
+			return as_line_info != null ? as_line_info.HasLineInfo () : false;
+		}
+		#endregion
+
+		#region XmlDictionaryReader
+
+		public override bool CanCanonicalize {
+			get { return as_dict_reader != null ? as_dict_reader.CanCanonicalize : false; }
+		}
+
+		public override void EndCanonicalization ()
+		{
+			if (as_dict_reader != null)
+				as_dict_reader.EndCanonicalization ();
+			else
+				throw new NotSupportedException ();
+		}
+
+		// no need to override for GetAttribute(), IndexOfLocalName(),
+		// IsLocalName(), IsNamespaceUri(), IsStartElement()
+
+		public override bool TryGetLocalNameAsDictionaryString (
+			out XmlDictionaryString localName)
+		{
+			// FIXME: find out when it returns true.
+			localName = null;
+			return false;
+//			if (!dict.TryLookup (LocalName, out localName))
+//				return false;
+//			return true;
+		}
+
+		public override bool TryGetNamespaceUriAsDictionaryString (
+			out XmlDictionaryString namespaceUri)
+		{
+			// FIXME: find out when it returns true.
+			namespaceUri = null;
+			return false;
+//			if (!dict.TryLookup (NamespaceURI, out namespaceUri))
+//				return false;
+//			return true;
+		}
+		#endregion
+
+		#region IXmlNamespaceResolver
+
+		public IDictionary<string,string> GetNamespacesInScope (
+			XmlNamespaceScope scope)
+		{
+			IXmlNamespaceResolver nsr = reader as IXmlNamespaceResolver;
+			return nsr.GetNamespacesInScope (scope);
+		}
+
+		public string LookupPrefix (string ns)
+		{
+			IXmlNamespaceResolver nsr = reader as IXmlNamespaceResolver;
+			return nsr.LookupPrefix (NameTable.Get (ns));
+		}
+
+		#endregion
+
+		#region XmlReader
+
+		public override int AttributeCount {
+			get { return reader.AttributeCount; }
+		}
+
+		public override string BaseURI {
+			get { return reader.BaseURI; }
+		}
+
+		public override int Depth {
+			get { return reader.Depth; }
+		}
+
+		public override XmlNodeType NodeType 
+		{
+			get { return reader.NodeType; }
+		}
+
+		public override string Name {
+			get { return reader.Name; }
+		}
+
+		public override string LocalName {
+			get { return reader.LocalName; }
+		}
+
+		public override string NamespaceURI {
+			get { return reader.NamespaceURI; }
+		}
+
+		public override string Prefix {
+			get { return reader.Prefix; }
+		}
+
+		public override bool HasValue {
+			get { return reader.HasValue; }
+		}
+
+		public override string Value {
+			get { return reader.Value; }
+		}
+
+		public override bool IsEmptyElement {
+			get { return reader.IsEmptyElement; }
+		}
+
+		public override bool IsDefault {
+			get { return reader.IsDefault; }
+		}
+
+		public override char QuoteChar {
+			get { return reader.QuoteChar; }
+		}
+
+		public override string XmlLang {
+			get { return reader.XmlLang; }
+		}
+
+		public override XmlSpace XmlSpace {
+			get { return reader.XmlSpace; }
+		}
+
+		public override string this [int i] {
+			get { return reader [i]; }
+		}
+
+		public override string this [string name] {
+			get { return reader [name]; }
+		}
+
+		public override string this [string localName, string namespaceURI] {
+			get { return reader [localName, namespaceURI]; }
+		}
+
+		public override bool EOF {
+			get { return reader.EOF; }
+		}
+
+		public override ReadState ReadState {
+			get { return reader.ReadState; }
+		}
+
+		public override XmlNameTable NameTable {
+			get { return reader.NameTable; }
+		}
+
+		public override string GetAttribute (string name)
+		{
+			return reader.GetAttribute (name);
+		}
+
+		public override string GetAttribute (string localName, string namespaceURI)
+		{
+			return reader.GetAttribute (localName, namespaceURI);
+		}
+
+		public override string GetAttribute (int i)
+		{
+			return reader.GetAttribute (i);
+		}
+
+		public override bool MoveToAttribute (string name)
+		{
+			return reader.MoveToAttribute (name);
+		}
+
+		public override bool MoveToAttribute (string localName, string namespaceURI)
+		{
+			return reader.MoveToAttribute (localName, namespaceURI);
+		}
+
+		public override void MoveToAttribute (int i)
+		{
+			reader.MoveToAttribute (i);
+		}
+
+		public override bool MoveToFirstAttribute ()
+		{
+			return reader.MoveToFirstAttribute ();
+		}
+
+		public override bool MoveToNextAttribute ()
+		{
+			return reader.MoveToNextAttribute ();
+		}
+
+		public override bool MoveToElement ()
+		{
+			return reader.MoveToElement ();
+		}
+
+		public override void Close ()
+		{
+			reader.Close ();
+			if (onClose != null)
+				onClose (this);
+		}
+
+		public override bool Read ()
+		{
+			if (!reader.Read ())
+				return false;
+			dict.Add (reader.Prefix);
+			dict.Add (reader.LocalName);
+			dict.Add (reader.NamespaceURI);
+			if (reader.MoveToFirstAttribute ()) {
+				do {
+					dict.Add (reader.Prefix);
+					dict.Add (reader.LocalName);
+					dict.Add (reader.NamespaceURI);
+					dict.Add (reader.Value);
+				} while (reader.MoveToNextAttribute ());
+				reader.MoveToElement ();
+			}
+			return true;
+		}
+
+		public override string ReadString ()
+		{
+			return reader.ReadString ();
+		}
+
+		public override string ReadInnerXml ()
+		{
+			return reader.ReadInnerXml ();
+		}
+
+		public override string ReadOuterXml ()
+		{
+			return reader.ReadOuterXml ();
+		}
+
+		public override string LookupNamespace (string prefix)
+		{
+			return reader.LookupNamespace (prefix);
+		}
+
+		public override void ResolveEntity ()
+		{
+			reader.ResolveEntity ();
+		}
+
+		public override bool ReadAttributeValue ()
+		{
+			return reader.ReadAttributeValue ();
+		}
+
+		#endregion
+	}
+}

+ 212 - 0
mcs/class/System.Runtime.Serialization/System.Xml/XmlSimpleDictionaryWriter.cs

@@ -0,0 +1,212 @@
+//
+// XmlDictionaryWriter.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+using System;
+using System.IO;
+using System.Text;
+
+namespace System.Xml
+{
+	internal class XmlSimpleDictionaryWriter : XmlDictionaryWriter
+	{
+		XmlWriter writer;
+
+		// FIXME: find out how soapCompliant argument is used.
+		public XmlSimpleDictionaryWriter (XmlWriter writer)
+		{
+			this.writer = writer;
+		}
+
+		public override void Close ()
+		{
+			writer.Close ();
+		}
+
+		public override void Flush ()
+		{
+			writer.Flush ();
+		}
+
+		public override string LookupPrefix (string ns)
+		{
+			return writer.LookupPrefix (ns);
+		}
+
+		public override void WriteBase64 (byte [] buffer, int index, int count)
+		{
+			writer.WriteBase64 (buffer, index, count);
+		}
+
+		public override void WriteBinHex (byte [] buffer, int index, int count)
+		{
+			writer.WriteBinHex (buffer, index, count);
+		}
+
+		public override void WriteCData (string text)
+		{
+			writer.WriteCData (text);
+		}
+
+		public override void WriteCharEntity (char ch)
+		{
+			writer.WriteCharEntity (ch);
+		}
+
+		public override void WriteChars (char [] buffer, int index, int count)
+		{
+			writer.WriteChars (buffer, index, count);
+		}
+
+		public override void WriteComment (string text)
+		{
+			writer.WriteComment (text);
+		}
+
+		public override void WriteDocType (string name, string pubid, string sysid, string subset)
+		{
+			writer.WriteDocType (name, pubid, sysid, subset);
+		}
+
+		public override void WriteEndAttribute ()
+		{
+			writer.WriteEndAttribute ();
+		}
+
+		public override void WriteEndDocument ()
+		{
+			writer.WriteEndDocument ();
+		}
+
+		public override void WriteEndElement ()
+		{
+			Depth--;
+			writer.WriteEndElement ();
+		}
+
+		public override void WriteEntityRef (string name)
+		{
+			writer.WriteEntityRef (name);
+		}
+
+		public override void WriteFullEndElement ()
+		{
+			writer.WriteFullEndElement ();
+		}
+
+		public override void WriteName (string name)
+		{
+			writer.WriteName (name);
+		}
+
+		public override void WriteNmToken (string name)
+		{
+			writer.WriteNmToken (name);
+		}
+
+		public override void WriteNode (XmlReader reader, bool defattr)
+		{
+			writer.WriteNode (reader, defattr);
+		}
+
+		public override void WriteProcessingInstruction (string name, string text)
+		{
+			writer.WriteProcessingInstruction (name, text);
+		}
+
+		public override void WriteQualifiedName (string localName, string ns)
+		{
+			writer.WriteQualifiedName (localName, ns);
+		}
+
+		public override void WriteRaw (string data)
+		{
+			writer.WriteRaw (data);
+		}
+
+		public override void WriteRaw (char [] buffer, int index, int count)
+		{
+			writer.WriteRaw (buffer, index, count);
+		}
+
+		public override void WriteStartAttribute (string prefix, string localName, string ns)
+		{
+			writer.WriteStartAttribute (prefix, localName, ns);
+		}
+
+		public override void WriteStartDocument (bool standalone)
+		{
+			writer.WriteStartDocument (standalone);
+		}
+
+		public override void WriteStartDocument ()
+		{
+			writer.WriteStartDocument ();
+		}
+
+		public override void WriteStartElement (string prefix, string localName, string ns)
+		{
+			Depth++;
+			writer.WriteStartElement (prefix, localName, ns);
+		}
+
+		public override void WriteString (string text)
+		{
+			writer.WriteString (text);
+		}
+
+		public override void WriteSurrogateCharEntity (char lowChar, char highChar)
+		{
+			writer.WriteSurrogateCharEntity (lowChar, highChar);
+		}
+
+		public override void WriteWhitespace (string ws)
+		{
+			writer.WriteWhitespace (ws);
+		}
+
+		public override WriteState WriteState {
+			get {
+				return writer.WriteState;
+			}
+		}
+
+		public override string XmlLang {
+			get {
+				return writer.XmlLang;
+			}
+		}
+
+		public override XmlSpace XmlSpace {
+			get {
+				return writer.XmlSpace;
+			}
+		}
+
+	}
+}
+#endif

+ 1 - 0
mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.AccessViolationException.xml

@@ -0,0 +1 @@
+<?xml version="1.0" encoding="utf-8"?><AccessViolationException xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.datacontract.org/2004/07/System"><ClassName i:type="x:string" xmlns="">System.AccessViolationException</ClassName><Message i:type="x:string" xmlns="">Attempted to read or write protected memory. This is often an indication that other memory is corrupt.</Message><Data i:nil="true" xmlns="" /><InnerException i:nil="true" xmlns="" /><HelpURL i:nil="true" xmlns="" /><StackTraceString i:nil="true" xmlns="" /><RemoteStackTraceString i:nil="true" xmlns="" /><RemoteStackIndex i:type="x:int" xmlns="">0</RemoteStackIndex><ExceptionMethod i:nil="true" xmlns="" /><HResult i:type="x:int" xmlns="">-2147467261</HResult><Source i:nil="true" xmlns="" /></AccessViolationException>

+ 1 - 0
mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.ActivationContext+ContextForm.xml

@@ -0,0 +1 @@
+<?xml version="1.0" encoding="utf-8"?><ActivationContext.ContextForm xmlns="http://schemas.datacontract.org/2004/07/System">Loose</ActivationContext.ContextForm>

+ 1 - 0
mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.AppDomainManagerInitializationOptions.xml

@@ -0,0 +1 @@
+<?xml version="1.0" encoding="utf-8"?><AppDomainManagerInitializationOptions xmlns="http://schemas.datacontract.org/2004/07/System">None</AppDomainManagerInitializationOptions>

+ 1 - 0
mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.AppDomainSetup.xml

@@ -0,0 +1 @@
+<?xml version="1.0" encoding="utf-8"?><AppDomainSetup xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/System"><_ActivationArguments xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Runtime.Hosting" i:nil="true" /><_AppBase i:nil="true" /><_AppDomainInitializer i:nil="true" /><_AppDomainInitializerArguments xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays" i:nil="true" /><_ApplicationTrust i:nil="true" /><_ConfigurationBytes i:nil="true" /><_DisableInterfaceCache>false</_DisableInterfaceCache><_Entries xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays" i:nil="true" /><_LoaderOptimization>NotSpecified</_LoaderOptimization></AppDomainSetup>

+ 1 - 0
mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.AppDomainUnloadedException.xml

@@ -0,0 +1 @@
+<?xml version="1.0" encoding="utf-8"?><AppDomainUnloadedException xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.datacontract.org/2004/07/System"><ClassName i:type="x:string" xmlns="">System.AppDomainUnloadedException</ClassName><Message i:type="x:string" xmlns="">Attempted to access an unloaded AppDomain.</Message><Data i:nil="true" xmlns="" /><InnerException i:nil="true" xmlns="" /><HelpURL i:nil="true" xmlns="" /><StackTraceString i:nil="true" xmlns="" /><RemoteStackTraceString i:nil="true" xmlns="" /><RemoteStackIndex i:type="x:int" xmlns="">0</RemoteStackIndex><ExceptionMethod i:nil="true" xmlns="" /><HResult i:type="x:int" xmlns="">-2146234348</HResult><Source i:nil="true" xmlns="" /></AppDomainUnloadedException>

+ 1 - 0
mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.ApplicationException.xml

@@ -0,0 +1 @@
+<?xml version="1.0" encoding="utf-8"?><ApplicationException xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.datacontract.org/2004/07/System"><ClassName i:type="x:string" xmlns="">System.ApplicationException</ClassName><Message i:type="x:string" xmlns="">Error in the application.</Message><Data i:nil="true" xmlns="" /><InnerException i:nil="true" xmlns="" /><HelpURL i:nil="true" xmlns="" /><StackTraceString i:nil="true" xmlns="" /><RemoteStackTraceString i:nil="true" xmlns="" /><RemoteStackIndex i:type="x:int" xmlns="">0</RemoteStackIndex><ExceptionMethod i:nil="true" xmlns="" /><HResult i:type="x:int" xmlns="">-2146232832</HResult><Source i:nil="true" xmlns="" /></ApplicationException>

+ 1 - 0
mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.ArgumentException.xml

@@ -0,0 +1 @@
+<?xml version="1.0" encoding="utf-8"?><ArgumentException xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.datacontract.org/2004/07/System"><ClassName i:type="x:string" xmlns="">System.ArgumentException</ClassName><Message i:type="x:string" xmlns="">Value does not fall within the expected range.</Message><Data i:nil="true" xmlns="" /><InnerException i:nil="true" xmlns="" /><HelpURL i:nil="true" xmlns="" /><StackTraceString i:nil="true" xmlns="" /><RemoteStackTraceString i:nil="true" xmlns="" /><RemoteStackIndex i:type="x:int" xmlns="">0</RemoteStackIndex><ExceptionMethod i:nil="true" xmlns="" /><HResult i:type="x:int" xmlns="">-2147024809</HResult><Source i:nil="true" xmlns="" /><ParamName i:nil="true" xmlns="" /></ArgumentException>

+ 1 - 0
mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.ArgumentNullException.xml

@@ -0,0 +1 @@
+<?xml version="1.0" encoding="utf-8"?><ArgumentNullException xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.datacontract.org/2004/07/System"><ClassName i:type="x:string" xmlns="">System.ArgumentNullException</ClassName><Message i:type="x:string" xmlns="">Value cannot be null.</Message><Data i:nil="true" xmlns="" /><InnerException i:nil="true" xmlns="" /><HelpURL i:nil="true" xmlns="" /><StackTraceString i:nil="true" xmlns="" /><RemoteStackTraceString i:nil="true" xmlns="" /><RemoteStackIndex i:type="x:int" xmlns="">0</RemoteStackIndex><ExceptionMethod i:nil="true" xmlns="" /><HResult i:type="x:int" xmlns="">-2147467261</HResult><Source i:nil="true" xmlns="" /><ParamName i:nil="true" xmlns="" /></ArgumentNullException>

+ 1 - 0
mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.ArgumentOutOfRangeException.xml

@@ -0,0 +1 @@
+<?xml version="1.0" encoding="utf-8"?><ArgumentOutOfRangeException xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.datacontract.org/2004/07/System"><ClassName i:type="x:string" xmlns="">System.ArgumentOutOfRangeException</ClassName><Message i:type="x:string" xmlns="">Specified argument was out of the range of valid values.</Message><Data i:nil="true" xmlns="" /><InnerException i:nil="true" xmlns="" /><HelpURL i:nil="true" xmlns="" /><StackTraceString i:nil="true" xmlns="" /><RemoteStackTraceString i:nil="true" xmlns="" /><RemoteStackIndex i:type="x:int" xmlns="">0</RemoteStackIndex><ExceptionMethod i:nil="true" xmlns="" /><HResult i:type="x:int" xmlns="">-2146233086</HResult><Source i:nil="true" xmlns="" /><ParamName i:nil="true" xmlns="" /><ActualValue i:nil="true" xmlns="" /></ArgumentOutOfRangeException>

+ 1 - 0
mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.ArithmeticException.xml

@@ -0,0 +1 @@
+<?xml version="1.0" encoding="utf-8"?><ArithmeticException xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.datacontract.org/2004/07/System"><ClassName i:type="x:string" xmlns="">System.ArithmeticException</ClassName><Message i:type="x:string" xmlns="">Overflow or underflow in the arithmetic operation.</Message><Data i:nil="true" xmlns="" /><InnerException i:nil="true" xmlns="" /><HelpURL i:nil="true" xmlns="" /><StackTraceString i:nil="true" xmlns="" /><RemoteStackTraceString i:nil="true" xmlns="" /><RemoteStackIndex i:type="x:int" xmlns="">0</RemoteStackIndex><ExceptionMethod i:nil="true" xmlns="" /><HResult i:type="x:int" xmlns="">-2147024362</HResult><Source i:nil="true" xmlns="" /></ArithmeticException>

+ 1 - 0
mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.ArrayTypeMismatchException.xml

@@ -0,0 +1 @@
+<?xml version="1.0" encoding="utf-8"?><ArrayTypeMismatchException xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.datacontract.org/2004/07/System"><ClassName i:type="x:string" xmlns="">System.ArrayTypeMismatchException</ClassName><Message i:type="x:string" xmlns="">Attempted to access an element as a type incompatible with the array.</Message><Data i:nil="true" xmlns="" /><InnerException i:nil="true" xmlns="" /><HelpURL i:nil="true" xmlns="" /><StackTraceString i:nil="true" xmlns="" /><RemoteStackTraceString i:nil="true" xmlns="" /><RemoteStackIndex i:type="x:int" xmlns="">0</RemoteStackIndex><ExceptionMethod i:nil="true" xmlns="" /><HResult i:type="x:int" xmlns="">-2146233085</HResult><Source i:nil="true" xmlns="" /></ArrayTypeMismatchException>

+ 1 - 0
mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.AttributeTargets.xml

@@ -0,0 +1 @@
+<?xml version="1.0" encoding="utf-8"?><AttributeTargets xmlns="http://schemas.datacontract.org/2004/07/System" />

+ 1 - 0
mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.BadImageFormatException.xml

@@ -0,0 +1 @@
+<?xml version="1.0" encoding="utf-8"?><BadImageFormatException xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.datacontract.org/2004/07/System"><ClassName i:type="x:string" xmlns="">System.BadImageFormatException</ClassName><Message i:type="x:string" xmlns="">Format of the executable (.exe) or library (.dll) is invalid.</Message><Data i:nil="true" xmlns="" /><InnerException i:nil="true" xmlns="" /><HelpURL i:nil="true" xmlns="" /><StackTraceString i:nil="true" xmlns="" /><RemoteStackTraceString i:nil="true" xmlns="" /><RemoteStackIndex i:type="x:int" xmlns="">0</RemoteStackIndex><ExceptionMethod i:nil="true" xmlns="" /><HResult i:type="x:int" xmlns="">-2147024885</HResult><Source i:nil="true" xmlns="" /><BadImageFormat_FileName i:nil="true" xmlns="" /><BadImageFormat_FusionLog i:nil="true" xmlns="" /></BadImageFormatException>

+ 1 - 0
mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.Base64FormattingOptions.xml

@@ -0,0 +1 @@
+<?xml version="1.0" encoding="utf-8"?><Base64FormattingOptions xmlns="http://schemas.datacontract.org/2004/07/System">None</Base64FormattingOptions>

+ 1 - 0
mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.Boolean.xml

@@ -0,0 +1 @@
+<?xml version="1.0" encoding="utf-8"?><boolean xmlns="http://schemas.microsoft.com/2003/10/Serialization/">false</boolean>

+ 1 - 0
mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.Byte.xml

@@ -0,0 +1 @@
+<?xml version="1.0" encoding="utf-8"?><unsignedByte xmlns="http://schemas.microsoft.com/2003/10/Serialization/">0</unsignedByte>

+ 1 - 0
mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.CannotUnloadAppDomainException.xml

@@ -0,0 +1 @@
+<?xml version="1.0" encoding="utf-8"?><CannotUnloadAppDomainException xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.datacontract.org/2004/07/System"><ClassName i:type="x:string" xmlns="">System.CannotUnloadAppDomainException</ClassName><Message i:type="x:string" xmlns="">Attempt to unload the AppDomain failed.</Message><Data i:nil="true" xmlns="" /><InnerException i:nil="true" xmlns="" /><HelpURL i:nil="true" xmlns="" /><StackTraceString i:nil="true" xmlns="" /><RemoteStackTraceString i:nil="true" xmlns="" /><RemoteStackIndex i:type="x:int" xmlns="">0</RemoteStackIndex><ExceptionMethod i:nil="true" xmlns="" /><HResult i:type="x:int" xmlns="">-2146234347</HResult><Source i:nil="true" xmlns="" /></CannotUnloadAppDomainException>

+ 1 - 0
mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.Char.xml

@@ -0,0 +1 @@
+<?xml version="1.0" encoding="utf-8"?><char xmlns="http://schemas.microsoft.com/2003/10/Serialization/">0</char>

+ 1 - 0
mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.Collections.ArrayList.xml

@@ -0,0 +1 @@
+<?xml version="1.0" encoding="utf-8"?><ArrayOfanyType xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays" />

+ 1 - 0
mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.Collections.CaseInsensitiveComparer.xml

@@ -0,0 +1 @@
+<?xml version="1.0" encoding="utf-8"?><CaseInsensitiveComparer xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/System.Collections"><m_compareInfo xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Globalization"><d2p1:culture>1033</d2p1:culture><d2p1:m_name>en-US</d2p1:m_name><d2p1:win32LCID>1033</d2p1:win32LCID></m_compareInfo></CaseInsensitiveComparer>

+ 1 - 0
mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.Collections.CaseInsensitiveHashCodeProvider.xml

@@ -0,0 +1 @@
+<?xml version="1.0" encoding="utf-8"?><CaseInsensitiveHashCodeProvider xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/System.Collections"><m_text xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Globalization"><d2p1:customCultureName i:nil="true" /><d2p1:m_isReadOnly>true</d2p1:m_isReadOnly><d2p1:m_listSeparator i:nil="true" /><d2p1:m_nDataItem>41</d2p1:m_nDataItem><d2p1:m_useUserOverride>true</d2p1:m_useUserOverride><d2p1:m_win32LangID>1033</d2p1:m_win32LangID></m_text></CaseInsensitiveHashCodeProvider>

+ 1 - 0
mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.Collections.DictionaryEntry.xml

@@ -0,0 +1 @@
+<?xml version="1.0" encoding="utf-8"?><DictionaryEntry xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/System.Collections"><_key i:nil="true" /><_value i:nil="true" /></DictionaryEntry>

+ 1 - 0
mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.Collections.Generic.KeyNotFoundException.xml

@@ -0,0 +1 @@
+<?xml version="1.0" encoding="utf-8"?><KeyNotFoundException xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.datacontract.org/2004/07/System.Collections.Generic"><ClassName i:type="x:string" xmlns="">System.Collections.Generic.KeyNotFoundException</ClassName><Message i:type="x:string" xmlns="">The given key was not present in the dictionary.</Message><Data i:nil="true" xmlns="" /><InnerException i:nil="true" xmlns="" /><HelpURL i:nil="true" xmlns="" /><StackTraceString i:nil="true" xmlns="" /><RemoteStackTraceString i:nil="true" xmlns="" /><RemoteStackIndex i:type="x:int" xmlns="">0</RemoteStackIndex><ExceptionMethod i:nil="true" xmlns="" /><HResult i:type="x:int" xmlns="">-2146232969</HResult><Source i:nil="true" xmlns="" /></KeyNotFoundException>

+ 1 - 0
mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.Collections.Hashtable.xml

@@ -0,0 +1 @@
+<?xml version="1.0" encoding="utf-8"?><ArrayOfKeyValueOfanyTypeanyType xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays" />

+ 1 - 0
mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.Collections.Queue.xml

@@ -0,0 +1 @@
+<?xml version="1.0" encoding="utf-8"?><Queue xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/System.Collections"><_array xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays"><d2p1:anyType i:nil="true" /><d2p1:anyType i:nil="true" /><d2p1:anyType i:nil="true" /><d2p1:anyType i:nil="true" /><d2p1:anyType i:nil="true" /><d2p1:anyType i:nil="true" /><d2p1:anyType i:nil="true" /><d2p1:anyType i:nil="true" /><d2p1:anyType i:nil="true" /><d2p1:anyType i:nil="true" /><d2p1:anyType i:nil="true" /><d2p1:anyType i:nil="true" /><d2p1:anyType i:nil="true" /><d2p1:anyType i:nil="true" /><d2p1:anyType i:nil="true" /><d2p1:anyType i:nil="true" /><d2p1:anyType i:nil="true" /><d2p1:anyType i:nil="true" /><d2p1:anyType i:nil="true" /><d2p1:anyType i:nil="true" /><d2p1:anyType i:nil="true" /><d2p1:anyType i:nil="true" /><d2p1:anyType i:nil="true" /><d2p1:anyType i:nil="true" /><d2p1:anyType i:nil="true" /><d2p1:anyType i:nil="true" /><d2p1:anyType i:nil="true" /><d2p1:anyType i:nil="true" /><d2p1:anyType i:nil="true" /><d2p1:anyType i:nil="true" /><d2p1:anyType i:nil="true" /><d2p1:anyType i:nil="true" /></_array><_growFactor>200</_growFactor><_head>0</_head><_size>0</_size><_tail>0</_tail><_version>0</_version></Queue>

+ 1 - 0
mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.Collections.SortedList.xml

@@ -0,0 +1 @@
+<?xml version="1.0" encoding="utf-8"?><ArrayOfKeyValueOfanyTypeanyType xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays" />

+ 1 - 0
mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.Collections.Specialized.HybridDictionary.xml

@@ -0,0 +1 @@
+<?xml version="1.0" encoding="utf-8"?><ArrayOfKeyValueOfanyTypeanyType xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays" />

+ 1 - 0
mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.Collections.Specialized.ListDictionary.xml

@@ -0,0 +1 @@
+<?xml version="1.0" encoding="utf-8"?><ArrayOfKeyValueOfanyTypeanyType xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays" />

+ 1 - 0
mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.Collections.Specialized.OrderedDictionary.xml

@@ -0,0 +1 @@
+<?xml version="1.0" encoding="utf-8"?><ArrayOfKeyValueOfanyTypeanyType xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays" />

+ 1 - 0
mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.Collections.Specialized.StringCollection.xml

@@ -0,0 +1 @@
+<?xml version="1.0" encoding="utf-8"?><ArrayOfanyType xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays" />

+ 1 - 0
mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.Collections.Specialized.StringDictionary.xml

@@ -0,0 +1 @@
+<?xml version="1.0" encoding="utf-8"?><StringDictionary xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/System.Collections.Specialized"><contents xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays" /></StringDictionary>

+ 1 - 0
mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.Collections.Stack.xml

@@ -0,0 +1 @@
+<?xml version="1.0" encoding="utf-8"?><Stack xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/System.Collections"><_array xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays"><d2p1:anyType i:nil="true" /><d2p1:anyType i:nil="true" /><d2p1:anyType i:nil="true" /><d2p1:anyType i:nil="true" /><d2p1:anyType i:nil="true" /><d2p1:anyType i:nil="true" /><d2p1:anyType i:nil="true" /><d2p1:anyType i:nil="true" /><d2p1:anyType i:nil="true" /><d2p1:anyType i:nil="true" /></_array><_size>0</_size><_version>0</_version></Stack>

+ 1 - 0
mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.ComponentModel.BindableSupport.xml

@@ -0,0 +1 @@
+<?xml version="1.0" encoding="utf-8"?><BindableSupport xmlns="http://schemas.datacontract.org/2004/07/System.ComponentModel">No</BindableSupport>

+ 1 - 0
mcs/class/System.Runtime.Serialization/Test/Resources/FrameworkTypes/System.ComponentModel.BindingDirection.xml

@@ -0,0 +1 @@
+<?xml version="1.0" encoding="utf-8"?><BindingDirection xmlns="http://schemas.datacontract.org/2004/07/System.ComponentModel">OneWay</BindingDirection>

部分文件因文件數量過多而無法顯示