diff options
author | Marek Safar <marek.safar@gmail.com> | 2015-02-13 16:45:46 +0300 |
---|---|---|
committer | Marek Safar <marek.safar@gmail.com> | 2015-02-13 16:45:46 +0300 |
commit | 09b16951bc707f28f17d5606a3865b6c000d7931 (patch) | |
tree | fa22297752308375dca142b88c1a72e7ae9e2386 /mcs/class/corlib | |
parent | 8157ba59cea0417d2ed045bbe811979af8d2cbda (diff) |
[corlib] UnitySerialization from reference sources
Diffstat (limited to 'mcs/class/corlib')
-rw-r--r-- | mcs/class/corlib/ReferenceSources/Empty.cs | 13 | ||||
-rw-r--r-- | mcs/class/corlib/System.Reflection/Assembly.cs | 6 | ||||
-rw-r--r-- | mcs/class/corlib/System.Reflection/Module.cs | 5 | ||||
-rw-r--r-- | mcs/class/corlib/System.Reflection/MonoAssembly.cs | 18 | ||||
-rw-r--r-- | mcs/class/corlib/System.Reflection/MonoModule.cs | 15 | ||||
-rw-r--r-- | mcs/class/corlib/System/DBNull.cs | 157 | ||||
-rw-r--r-- | mcs/class/corlib/System/MonoType.cs | 11 | ||||
-rw-r--r-- | mcs/class/corlib/System/Type.cs | 10 | ||||
-rw-r--r-- | mcs/class/corlib/System/UnitySerializationHolder.cs | 122 | ||||
-rw-r--r-- | mcs/class/corlib/corlib.dll.sources | 6 |
10 files changed, 56 insertions, 307 deletions
diff --git a/mcs/class/corlib/ReferenceSources/Empty.cs b/mcs/class/corlib/ReferenceSources/Empty.cs deleted file mode 100644 index ceff8d5232f..00000000000 --- a/mcs/class/corlib/ReferenceSources/Empty.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace System -{ - using System; - using System.Runtime.Remoting; - using System.Runtime.Serialization; - - [Serializable] - internal sealed class Empty - { - private Empty() { - } - } -}
\ No newline at end of file diff --git a/mcs/class/corlib/System.Reflection/Assembly.cs b/mcs/class/corlib/System.Reflection/Assembly.cs index 5401c0b7bca..f1ba85efdd7 100644 --- a/mcs/class/corlib/System.Reflection/Assembly.cs +++ b/mcs/class/corlib/System.Reflection/Assembly.cs @@ -201,13 +201,9 @@ namespace System.Reflection { } } - [SecurityPermission (SecurityAction.LinkDemand, SerializationFormatter = true)] public virtual void GetObjectData (SerializationInfo info, StreamingContext context) { - if (info == null) - throw new ArgumentNullException ("info"); - - UnitySerializationHolder.GetAssemblyData (this, info, context); + throw new NotImplementedException (); } public virtual bool IsDefined (Type attributeType, bool inherit) diff --git a/mcs/class/corlib/System.Reflection/Module.cs b/mcs/class/corlib/System.Reflection/Module.cs index a414acc3d5f..79bddc252ae 100644 --- a/mcs/class/corlib/System.Reflection/Module.cs +++ b/mcs/class/corlib/System.Reflection/Module.cs @@ -122,10 +122,7 @@ namespace System.Reflection { [SecurityPermission (SecurityAction.LinkDemand, SerializationFormatter = true)] public virtual void GetObjectData (SerializationInfo info, StreamingContext context) { - if (info == null) - throw new ArgumentNullException ("info"); - - UnitySerializationHolder.GetModuleData (this, info, context); + throw new NotImplementedException (); } [ComVisible (true)] diff --git a/mcs/class/corlib/System.Reflection/MonoAssembly.cs b/mcs/class/corlib/System.Reflection/MonoAssembly.cs index 80eb4c79d76..cb9faca36dc 100644 --- a/mcs/class/corlib/System.Reflection/MonoAssembly.cs +++ b/mcs/class/corlib/System.Reflection/MonoAssembly.cs @@ -34,14 +34,30 @@ using System.Runtime.InteropServices; using System.Reflection.Emit; #endif using System.Collections.Generic; +using System.Runtime.Serialization; namespace System.Reflection { + abstract class RuntimeAssembly : Assembly + { + public override void GetObjectData (SerializationInfo info, StreamingContext context) + { + if (info == null) + throw new ArgumentNullException ("info"); + + UnitySerializationHolder.GetUnitySerializationInfo (info, + UnitySerializationHolder.AssemblyUnity, + this.FullName, + this); + } + } + [ComVisible (true)] [ComDefaultInterfaceAttribute (typeof (_Assembly))] [Serializable] [ClassInterface(ClassInterfaceType.None)] - class MonoAssembly : Assembly { + class MonoAssembly : RuntimeAssembly + { public override Type GetType (string name, bool throwOnError, bool ignoreCase) diff --git a/mcs/class/corlib/System.Reflection/MonoModule.cs b/mcs/class/corlib/System.Reflection/MonoModule.cs index 19c756a0d65..f710da52cdd 100644 --- a/mcs/class/corlib/System.Reflection/MonoModule.cs +++ b/mcs/class/corlib/System.Reflection/MonoModule.cs @@ -34,7 +34,7 @@ using System.Runtime.InteropServices; using System.Security.Cryptography.X509Certificates; using System.Security; using System.Security.Permissions; - +using System.Runtime.Serialization; namespace System.Reflection { @@ -267,6 +267,14 @@ namespace System.Reflection { return res; } + public override void GetObjectData (SerializationInfo info, StreamingContext context) + { + if (info == null) + throw new ArgumentNullException ("info"); + + UnitySerializationHolder.GetUnitySerializationInfo (info, UnitySerializationHolder.ModuleUnity, this.ScopeName, this.GetRuntimeAssembly ()); + } + #if !NET_2_1 public @@ -291,5 +299,10 @@ namespace System.Reflection { public override IList<CustomAttributeData> GetCustomAttributesData () { return CustomAttributeData.GetCustomAttributes (this); } + + internal RuntimeAssembly GetRuntimeAssembly () + { + return (RuntimeAssembly)assembly; + } } } diff --git a/mcs/class/corlib/System/DBNull.cs b/mcs/class/corlib/System/DBNull.cs deleted file mode 100644 index e730cc8599d..00000000000 --- a/mcs/class/corlib/System/DBNull.cs +++ /dev/null @@ -1,157 +0,0 @@ -// -// System.DBNull.cs -// -// Authors: -// Duncan Mak (duncan@ximian.com) -// Ben Maurer (bmaurer@users.sourceforge.net) -// -// (C) 2002 Ximian, Inc. http://www.ximian.com -// (C) 2003 Ben Maurer -// - -// -// Copyright (C) 2004 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.Runtime.Serialization; -using System.Runtime.InteropServices; - -namespace System -{ - [Serializable] - [ComVisible (true)] - public sealed class DBNull : ISerializable, IConvertible - { - // Fields - public static readonly DBNull Value = new DBNull (); - - // Private constructor - private DBNull () - { - } - - private DBNull (SerializationInfo info, StreamingContext context) - { - throw new NotSupportedException (); - } - - // Methods - public void GetObjectData (SerializationInfo info, StreamingContext context) - { - UnitySerializationHolder.GetDBNullData (this, info, context); - } - - public TypeCode GetTypeCode () - { - return TypeCode.DBNull; - } - - bool IConvertible.ToBoolean (IFormatProvider provider) - { - throw new InvalidCastException (); - } - - byte IConvertible.ToByte (IFormatProvider provider) - { - throw new InvalidCastException (); - } - - char IConvertible.ToChar (IFormatProvider provider) - { - throw new InvalidCastException (); - } - - DateTime IConvertible.ToDateTime (IFormatProvider provider) - { - throw new InvalidCastException (); - } - - decimal IConvertible.ToDecimal (IFormatProvider provider) - { - throw new InvalidCastException (); - } - - double IConvertible.ToDouble (IFormatProvider provider) - { - throw new InvalidCastException (); - } - - short IConvertible.ToInt16 (IFormatProvider provider) - { - throw new InvalidCastException (); - } - - int IConvertible.ToInt32 (IFormatProvider provider) - { - throw new InvalidCastException (); - } - - long IConvertible.ToInt64 (IFormatProvider provider) - { - throw new InvalidCastException (); - } - - sbyte IConvertible.ToSByte (IFormatProvider provider) - { - throw new InvalidCastException (); - } - - float IConvertible.ToSingle (IFormatProvider provider) - { - throw new InvalidCastException (); - } - - object IConvertible.ToType (Type targetType, IFormatProvider provider) - { - if (targetType == typeof (string)) - return String.Empty; - if (targetType == typeof (DBNull)) - return this; - throw new InvalidCastException (); - } - - ushort IConvertible.ToUInt16 (IFormatProvider provider) - { - throw new InvalidCastException (); - } - - uint IConvertible.ToUInt32 (IFormatProvider provider) - { - throw new InvalidCastException (); - } - - ulong IConvertible.ToUInt64 (IFormatProvider provider) - { - throw new InvalidCastException (); - } - - public override string ToString () - { - return String.Empty; - } - - public string ToString (IFormatProvider provider) - { - return String.Empty; - } - } -} diff --git a/mcs/class/corlib/System/MonoType.cs b/mcs/class/corlib/System/MonoType.cs index b7e0ee70e00..d415645f5e2 100644 --- a/mcs/class/corlib/System/MonoType.cs +++ b/mcs/class/corlib/System/MonoType.cs @@ -51,7 +51,16 @@ namespace System abstract class RuntimeType : TypeInfo { + internal RuntimeAssembly GetRuntimeAssembly () + { + return (RuntimeAssembly) Assembly; + } + internal virtual bool IsSzArray { + get { + return IsArrayImpl () && GetArrayRank () == 1; + } + } } [Serializable] @@ -656,7 +665,7 @@ namespace System public void GetObjectData(SerializationInfo info, StreamingContext context) { - UnitySerializationHolder.GetTypeData (this, info, context); + UnitySerializationHolder.GetUnitySerializationInfo(info, this); } public override string ToString() diff --git a/mcs/class/corlib/System/Type.cs b/mcs/class/corlib/System/Type.cs index bbd5bbbc749..1475736d7d5 100644 --- a/mcs/class/corlib/System/Type.cs +++ b/mcs/class/corlib/System/Type.cs @@ -1618,6 +1618,16 @@ namespace System { } } + internal Type GetRootElementType() + { + Type rootElementType = this; + + while (rootElementType.HasElementType) + rootElementType = rootElementType.GetElementType(); + + return rootElementType; + } + #if !MOBILE void _Type.GetIDsOfNames ([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId) { diff --git a/mcs/class/corlib/System/UnitySerializationHolder.cs b/mcs/class/corlib/System/UnitySerializationHolder.cs deleted file mode 100644 index 33b323c2a69..00000000000 --- a/mcs/class/corlib/System/UnitySerializationHolder.cs +++ /dev/null @@ -1,122 +0,0 @@ -// -// System.UnitySerializationHolder.cs -// -// Author: -// Lluis Sanchez Gual (lsg@ctv.es) -// -// (C) 2003 Lluis Sanchez Gual - -// -// Copyright (C) 2004 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.Reflection; -using System.Runtime.Serialization; - -namespace System -{ - [Serializable] - internal class UnitySerializationHolder : IObjectReference, ISerializable - { - string _data; - UnityType _unityType; - string _assemblyName; - - // FIXME: there must be other types that use UnitySerializationHolder for - // serialization, but I don't know yet which ones. - - enum UnityType: byte - { - DBNull = 2, - Type = 4, - Module = 5, - Assembly = 6 - } - - UnitySerializationHolder (SerializationInfo info, StreamingContext ctx) - { - _data = info.GetString ("Data"); - _unityType = (UnityType) info.GetInt32 ("UnityType"); - _assemblyName = info.GetString ("AssemblyName"); - } - - public static void GetTypeData (Type instance, SerializationInfo info, StreamingContext ctx) - { - info.AddValue ("Data", instance.FullName); - info.AddValue ("UnityType", (int) UnityType.Type); - info.AddValue ("AssemblyName", instance.Assembly.FullName); - info.SetType (typeof (UnitySerializationHolder)); - } - - public static void GetDBNullData (DBNull instance, SerializationInfo info, StreamingContext ctx) - { - info.AddValue ("Data", null); - info.AddValue ("UnityType", (int) UnityType.DBNull); - info.AddValue ("AssemblyName", instance.GetType().Assembly.FullName); - info.SetType (typeof (UnitySerializationHolder)); - } - - public static void GetAssemblyData (Assembly instance, SerializationInfo info, StreamingContext ctx) - { - info.AddValue ("Data", instance.FullName); - info.AddValue ("UnityType", (int) UnityType.Assembly); - info.AddValue ("AssemblyName", instance.FullName); - info.SetType (typeof (UnitySerializationHolder)); - } - - public static void GetModuleData (Module instance, SerializationInfo info, StreamingContext ctx) - { - info.AddValue ("Data", instance.ScopeName); - info.AddValue ("UnityType", (int) UnityType.Module); - info.AddValue ("AssemblyName", instance.Assembly.FullName); - info.SetType (typeof (UnitySerializationHolder)); - } - - public virtual void GetObjectData (SerializationInfo info, StreamingContext context) - { - // Not needed. - throw new NotSupportedException(); - } - - public virtual object GetRealObject (StreamingContext context) - { - switch (_unityType) { - case UnityType.Type: { - Assembly assembly = Assembly.Load (_assemblyName); - return assembly.GetType (_data); - } - case UnityType.DBNull: - return DBNull.Value; - case UnityType.Module: { - Assembly assembly = Assembly.Load (_assemblyName); - return assembly.GetModule (_data); - } - case UnityType.Assembly: - return Assembly.Load (_data); - default: - throw new NotSupportedException (Locale.GetText - ("UnitySerializationHolder does not support this type.")); - } - } - } -} diff --git a/mcs/class/corlib/corlib.dll.sources b/mcs/class/corlib/corlib.dll.sources index cc33b475644..a3f8bcda68a 100644 --- a/mcs/class/corlib/corlib.dll.sources +++ b/mcs/class/corlib/corlib.dll.sources @@ -130,7 +130,6 @@ System/ContextStaticAttribute.cs System/ControlCharacters.cs System/CrossAppDomainDelegate.cs System/DataMisalignedException.cs -System/DBNull.cs System/Delegate.cs System/DelegateSerializationHolder.cs System/DivideByZeroException.cs @@ -263,7 +262,6 @@ System/UIntPtr.cs System/UnauthorizedAccessException.cs System/UnhandledExceptionEventArgs.cs System/UnhandledExceptionEventHandler.cs -System/UnitySerializationHolder.cs System/ValueType.cs System/Variant.cs System/Void.cs @@ -1435,7 +1433,6 @@ ReferenceSources/BCLDebug.cs ReferenceSources/CalendarData.cs ReferenceSources/CompatibilitySwitches.cs ReferenceSources/CultureData.cs -ReferenceSources/Empty.cs ReferenceSources/Environment.cs ReferenceSources/ExecutionContext.cs ReferenceSources/HashHelpers.cs @@ -1459,6 +1456,8 @@ ReferenceSources/JitHelpers.cs ../../../external/referencesource/mscorlib/system/datetimeoffset.cs ../../../external/referencesource/mscorlib/system/dayofweek.cs ../../../external/referencesource/mscorlib/system/decimal.cs +../../../external/referencesource/mscorlib/system/dbnull.cs +../../../external/referencesource/mscorlib/system/empty.cs ../../../external/referencesource/mscorlib/system/guid.cs ../../../external/referencesource/mscorlib/system/int16.cs ../../../external/referencesource/mscorlib/system/int32.cs @@ -1476,6 +1475,7 @@ ReferenceSources/JitHelpers.cs ../../../external/referencesource/mscorlib/system/uint16.cs ../../../external/referencesource/mscorlib/system/uint32.cs ../../../external/referencesource/mscorlib/system/uint64.cs +../../../external/referencesource/mscorlib/system/unityserializationholder.cs ../../../external/referencesource/mscorlib/system/version.cs ../../../external/referencesource/mscorlib/system/collections/arraylist.cs |