diff options
author | Jiyoung Yun <jy910.yun@samsung.com> | 2017-06-13 18:47:36 +0900 |
---|---|---|
committer | Jiyoung Yun <jy910.yun@samsung.com> | 2017-06-13 18:47:36 +0900 |
commit | 61d6a817e39d3bae0f47dbc09838d51db22a5d30 (patch) | |
tree | cb37caa1784bc738b976273335d6ed04a7cc80b0 /src/mscorlib/shared/System/Reflection | |
parent | 5b975f8233e8c8d17b215372f89ca713b45d6a0b (diff) | |
download | coreclr-61d6a817e39d3bae0f47dbc09838d51db22a5d30.tar.gz coreclr-61d6a817e39d3bae0f47dbc09838d51db22a5d30.tar.bz2 coreclr-61d6a817e39d3bae0f47dbc09838d51db22a5d30.zip |
Imported Upstream version 2.0.0.11992upstream/2.0.0.11992
Diffstat (limited to 'src/mscorlib/shared/System/Reflection')
18 files changed, 177 insertions, 417 deletions
diff --git a/src/mscorlib/shared/System/Reflection/AmbiguousMatchException.cs b/src/mscorlib/shared/System/Reflection/AmbiguousMatchException.cs index 459a19cb71..a0075bbc0b 100644 --- a/src/mscorlib/shared/System/Reflection/AmbiguousMatchException.cs +++ b/src/mscorlib/shared/System/Reflection/AmbiguousMatchException.cs @@ -6,7 +6,6 @@ using System.Runtime.Serialization; namespace System.Reflection { - [Serializable] public sealed class AmbiguousMatchException : SystemException { public AmbiguousMatchException() @@ -26,10 +25,5 @@ namespace System.Reflection { HResult = __HResults.COR_E_AMBIGUOUSMATCH; } - - internal AmbiguousMatchException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } } } diff --git a/src/mscorlib/shared/System/Reflection/Assembly.cs b/src/mscorlib/shared/System/Reflection/Assembly.cs index d35ffc7066..b965c9f7fb 100644 --- a/src/mscorlib/shared/System/Reflection/Assembly.cs +++ b/src/mscorlib/shared/System/Reflection/Assembly.cs @@ -125,7 +125,10 @@ namespace System.Reflection public virtual FileStream[] GetFiles() => GetFiles(getResourceModules: false); public virtual FileStream[] GetFiles(bool getResourceModules) { throw NotImplemented.ByDesign; } - public virtual void GetObjectData(SerializationInfo info, StreamingContext context) { throw NotImplemented.ByDesign; } + public virtual void GetObjectData(SerializationInfo info, StreamingContext context) + { + throw new PlatformNotSupportedException(); + } public override string ToString() { diff --git a/src/mscorlib/shared/System/Reflection/AssemblyNameFormatter.cs b/src/mscorlib/shared/System/Reflection/AssemblyNameFormatter.cs new file mode 100644 index 0000000000..7c4a980079 --- /dev/null +++ b/src/mscorlib/shared/System/Reflection/AssemblyNameFormatter.cs @@ -0,0 +1,156 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.IO; +using System.Text; +using System.Globalization; +using System.Collections.Generic; + +namespace System.Reflection +{ + internal static class AssemblyNameFormatter + { + public static string ComputeDisplayName(string name, Version version, string cultureName, byte[] pkt, AssemblyNameFlags flags, AssemblyContentType contentType) + { + const int PUBLIC_KEY_TOKEN_LEN = 8; + + if (name == string.Empty) + throw new FileLoadException(); + + StringBuilder sb = new StringBuilder(); + if (name != null) + { + sb.AppendQuoted(name); + } + + if (version != null) + { + Version canonicalizedVersion = version.CanonicalizeVersion(); + if (canonicalizedVersion.Major != ushort.MaxValue) + { + sb.Append(", Version="); + sb.Append(canonicalizedVersion.Major); + + if (canonicalizedVersion.Minor != ushort.MaxValue) + { + sb.Append('.'); + sb.Append(canonicalizedVersion.Minor); + + if (canonicalizedVersion.Build != ushort.MaxValue) + { + sb.Append('.'); + sb.Append(canonicalizedVersion.Build); + + if (canonicalizedVersion.Revision != ushort.MaxValue) + { + sb.Append('.'); + sb.Append(canonicalizedVersion.Revision); + } + } + } + } + } + + if (cultureName != null) + { + if (cultureName == string.Empty) + cultureName = "neutral"; + sb.Append(", Culture="); + sb.AppendQuoted(cultureName); + } + + if (pkt != null) + { + if (pkt.Length > PUBLIC_KEY_TOKEN_LEN) + throw new ArgumentException(); + + sb.Append(", PublicKeyToken="); + if (pkt.Length == 0) + sb.Append("null"); + else + { + foreach (byte b in pkt) + { + sb.Append(b.ToString("x2", CultureInfo.InvariantCulture)); + } + } + } + + if (0 != (flags & AssemblyNameFlags.Retargetable)) + sb.Append(", Retargetable=Yes"); + + if (contentType == AssemblyContentType.WindowsRuntime) + sb.Append(", ContentType=WindowsRuntime"); + + // NOTE: By design (desktop compat) AssemblyName.FullName and ToString() do not include ProcessorArchitecture. + + return sb.ToString(); + } + + private static void AppendQuoted(this StringBuilder sb, string s) + { + bool needsQuoting = false; + const char quoteChar = '\"'; + + //@todo: App-compat: You can use double or single quotes to quote a name, and Fusion (or rather the IdentityAuthority) picks one + // by some algorithm. Rather than guess at it, I'll just use double-quote consistently. + if (s != s.Trim() || s.Contains("\"") || s.Contains("\'")) + needsQuoting = true; + + if (needsQuoting) + sb.Append(quoteChar); + + for (int i = 0; i < s.Length; i++) + { + bool addedEscape = false; + foreach (KeyValuePair<char, string> kv in EscapeSequences) + { + string escapeReplacement = kv.Value; + if (!(s[i] == escapeReplacement[0])) + continue; + if ((s.Length - i) < escapeReplacement.Length) + continue; + string prefix = s.Substring(i, escapeReplacement.Length); + if (prefix == escapeReplacement) + { + sb.Append('\\'); + sb.Append(kv.Key); + addedEscape = true; + } + } + + if (!addedEscape) + sb.Append(s[i]); + } + + if (needsQuoting) + sb.Append(quoteChar); + } + + private static Version CanonicalizeVersion(this Version version) + { + ushort major = (ushort)version.Major; + ushort minor = (ushort)version.Minor; + ushort build = (ushort)version.Build; + ushort revision = (ushort)version.Revision; + + if (major == version.Major && minor == version.Minor && build == version.Build && revision == version.Revision) + return version; + + return new Version(major, minor, build, revision); + } + + public static KeyValuePair<char, string>[] EscapeSequences = + { + new KeyValuePair<char, string>('\\', "\\"), + new KeyValuePair<char, string>(',', ","), + new KeyValuePair<char, string>('=', "="), + new KeyValuePair<char, string>('\'', "'"), + new KeyValuePair<char, string>('\"', "\""), + new KeyValuePair<char, string>('n', Environment.NewLine), + new KeyValuePair<char, string>('t', "\t"), + }; + } +} + diff --git a/src/mscorlib/shared/System/Reflection/CustomAttributeFormatException.cs b/src/mscorlib/shared/System/Reflection/CustomAttributeFormatException.cs index 6e11540505..13766ae8d0 100644 --- a/src/mscorlib/shared/System/Reflection/CustomAttributeFormatException.cs +++ b/src/mscorlib/shared/System/Reflection/CustomAttributeFormatException.cs @@ -6,7 +6,6 @@ using System.Runtime.Serialization; namespace System.Reflection { - [Serializable] public class CustomAttributeFormatException : FormatException { public CustomAttributeFormatException() @@ -28,6 +27,7 @@ namespace System.Reflection protected CustomAttributeFormatException(SerializationInfo info, StreamingContext context) : base(info, context) { + throw new PlatformNotSupportedException(); } } } diff --git a/src/mscorlib/shared/System/Reflection/DefaultMemberAttribute.cs b/src/mscorlib/shared/System/Reflection/DefaultMemberAttribute.cs index 3511433713..585fdb07cd 100644 --- a/src/mscorlib/shared/System/Reflection/DefaultMemberAttribute.cs +++ b/src/mscorlib/shared/System/Reflection/DefaultMemberAttribute.cs @@ -4,7 +4,6 @@ namespace System.Reflection { - [Serializable] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface)] public sealed class DefaultMemberAttribute : Attribute { diff --git a/src/mscorlib/shared/System/Reflection/InvalidFilterCriteriaException.cs b/src/mscorlib/shared/System/Reflection/InvalidFilterCriteriaException.cs index e3f882c409..07880a768d 100644 --- a/src/mscorlib/shared/System/Reflection/InvalidFilterCriteriaException.cs +++ b/src/mscorlib/shared/System/Reflection/InvalidFilterCriteriaException.cs @@ -6,7 +6,6 @@ using System.Runtime.Serialization; namespace System.Reflection { - [Serializable] public class InvalidFilterCriteriaException : ApplicationException { public InvalidFilterCriteriaException() @@ -28,6 +27,7 @@ namespace System.Reflection protected InvalidFilterCriteriaException(SerializationInfo info, StreamingContext context) : base(info, context) { + throw new PlatformNotSupportedException(); } } } diff --git a/src/mscorlib/shared/System/Reflection/MemberInfoSerializationHolder.cs b/src/mscorlib/shared/System/Reflection/MemberInfoSerializationHolder.cs deleted file mode 100644 index dfc56667bd..0000000000 --- a/src/mscorlib/shared/System/Reflection/MemberInfoSerializationHolder.cs +++ /dev/null @@ -1,315 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Runtime.Serialization; -using System.Globalization; -using System.Diagnostics.Contracts; - -namespace System.Reflection -{ - [Serializable] -#if CORECLR - internal -#else - public // On CoreRT, this must be public because of the Reflection.Core/CoreLib divide and the need to whitelist past the ReflectionBlock. -#endif - class MemberInfoSerializationHolder : ISerializable, IObjectReference - { - #region Staitc Public Members - public static void GetSerializationInfo(SerializationInfo info, FieldInfo f) - { - // Compat: Serializing ToString() since the full framework does it but the deserialization logic makes no use of it. - GetSerializationInfo(info, f.Name, f.ReflectedType, f.ToString(), MemberTypes.Field); - } - - public static void GetSerializationInfo(SerializationInfo info, EventInfo e) - { - GetSerializationInfo(info, e.Name, e.ReflectedType, null, MemberTypes.Event); - } - - public static void GetSerializationInfo(SerializationInfo info, ConstructorInfo c) - { - GetSerializationInfo(info, c.Name, c.ReflectedType, c.ToString(), c.SerializationToString(), MemberTypes.Constructor, genericArguments: null); - } - - public static void GetSerializationInfo(SerializationInfo info, MethodInfo m) - { - Type[] genericArguments = m.IsConstructedGenericMethod ? m.GetGenericArguments() : null; - GetSerializationInfo(info, m.Name, m.ReflectedType, m.ToString(), m.SerializationToString(), MemberTypes.Method, genericArguments); - } - - public static void GetSerializationInfo(SerializationInfo info, PropertyInfo p) - { - GetSerializationInfo(info, p.Name, p.ReflectedType, p.ToString(), p.SerializationToString(), MemberTypes.Property, genericArguments: null); - } - #endregion - - #region Private Static Members - private static void GetSerializationInfo(SerializationInfo info, string name, Type reflectedClass, string signature, MemberTypes type) - { - GetSerializationInfo(info, name, reflectedClass, signature, null, type, null); - } - - private static void GetSerializationInfo( - SerializationInfo info, - string name, - Type reflectedClass, - string signature, - string signature2, - MemberTypes type, - Type[] genericArguments) - { - if (info == null) - throw new ArgumentNullException(nameof(info)); - Contract.EndContractBlock(); - - string assemblyName = reflectedClass.Module.Assembly.FullName; - string typeName = reflectedClass.FullName; - - info.SetType(typeof(MemberInfoSerializationHolder)); - info.AddValue("Name", name, typeof(string)); - info.AddValue("AssemblyName", assemblyName, typeof(string)); - info.AddValue("ClassName", typeName, typeof(string)); - info.AddValue("Signature", signature, typeof(string)); - info.AddValue("Signature2", signature2, typeof(string)); - info.AddValue("MemberType", (int)type); - info.AddValue("GenericArguments", genericArguments, typeof(Type[])); - } - #endregion - - #region Private Data Members - private readonly string _memberName; - private readonly Type _reflectedType; - // _signature stores the ToString() representation of the member which is sometimes ambiguous. - // Mulitple overloads of the same methods or properties can identical ToString(). - // _signature2 stores the SerializationToString() representation which should be unique for each member. - // It is only written and used by post 4.0 CLR versions. - private readonly string _signature; - private readonly string _signature2; - private readonly MemberTypes _memberType; - private readonly SerializationInfo _info; - #endregion - - #region Constructor - // Needs to be public so it can be whitelisted in Reflection. - public MemberInfoSerializationHolder(SerializationInfo info, StreamingContext context) - { - if (info == null) - throw new ArgumentNullException(nameof(info)); - Contract.EndContractBlock(); - - string assemblyName = info.GetString("AssemblyName"); - string typeName = info.GetString("ClassName"); - - if (assemblyName == null || typeName == null) - throw new SerializationException(SR.Serialization_InsufficientState); - - Assembly assem = Assembly.Load(assemblyName); - _reflectedType = assem.GetType(typeName, true, false); - _memberName = info.GetString("Name"); - _signature = info.GetString("Signature"); - // Only v4.0 and later generates and consumes Signature2 - _signature2 = (string)info.GetValueNoThrow("Signature2", typeof(string)); - _memberType = (MemberTypes)info.GetInt32("MemberType"); - _info = info; - } - #endregion - - #region ISerializable - public virtual void GetObjectData(SerializationInfo info, StreamingContext context) - { - throw new NotSupportedException(); - } - #endregion - - #region IObjectReference - public virtual object GetRealObject(StreamingContext context) - { - if (_memberName == null || _reflectedType == null || _memberType == 0) - throw new SerializationException(SR.Serialization_InsufficientState); - - BindingFlags bindingFlags = - BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | - BindingFlags.Static | BindingFlags.OptionalParamBinding; - - switch (_memberType) - { - #region case MemberTypes.Field: - case MemberTypes.Field: - { - FieldInfo[] fields = _reflectedType.GetMember(_memberName, MemberTypes.Field, bindingFlags) as FieldInfo[]; - - if (fields.Length == 0) - throw new SerializationException(SR.Format(SR.Serialization_UnknownMember, _memberName)); - - return fields[0]; - } - #endregion - - #region case MemberTypes.Event: - case MemberTypes.Event: - { - EventInfo[] events = _reflectedType.GetMember(_memberName, MemberTypes.Event, bindingFlags) as EventInfo[]; - - if (events.Length == 0) - throw new SerializationException(SR.Format(SR.Serialization_UnknownMember, _memberName)); - - return events[0]; - } - #endregion - - #region case MemberTypes.Property: - case MemberTypes.Property: - { - PropertyInfo[] properties = _reflectedType.GetMember(_memberName, MemberTypes.Property, bindingFlags) as PropertyInfo[]; - - if (properties.Length == 0) - throw new SerializationException(SR.Format(SR.Serialization_UnknownMember, _memberName)); - - if (properties.Length == 1) - return properties[0]; - - if (properties.Length > 1) - { - for (int i = 0; i < properties.Length; i++) - { - if (_signature2 != null) - { - if (properties[i].SerializationToString().Equals(_signature2)) - return properties[i]; - } - else - { - if ((properties[i]).ToString().Equals(_signature)) - return properties[i]; - } - } - } - - throw new SerializationException(SR.Format(SR.Serialization_UnknownMember, _memberName)); - } - #endregion - - #region case MemberTypes.Constructor: - case MemberTypes.Constructor: - { - if (_signature == null) - throw new SerializationException(SR.Serialization_NullSignature); - - ConstructorInfo[] constructors = _reflectedType.GetMember(_memberName, MemberTypes.Constructor, bindingFlags) as ConstructorInfo[]; - - if (constructors.Length == 1) - return constructors[0]; - - if (constructors.Length > 1) - { - for (int i = 0; i < constructors.Length; i++) - { - if (_signature2 != null) - { - if (constructors[i].SerializationToString().Equals(_signature2)) - return constructors[i]; - } - else - { - if (constructors[i].ToString().Equals(_signature)) - return constructors[i]; - } - } - } - - throw new SerializationException(SR.Format(SR.Serialization_UnknownMember, _memberName)); - } - #endregion - - #region case MemberTypes.Method: - case MemberTypes.Method: - { - MethodInfo methodInfo = null; - - if (_signature == null) - throw new SerializationException(SR.Serialization_NullSignature); - - Type[] genericArguments = _info.GetValueNoThrow("GenericArguments", typeof(Type[])) as Type[]; - - MethodInfo[] methods = _reflectedType.GetMember(_memberName, MemberTypes.Method, bindingFlags) as MethodInfo[]; - - if (methods.Length == 1) - methodInfo = methods[0]; - - else if (methods.Length > 1) - { - for (int i = 0; i < methods.Length; i++) - { - if (_signature2 != null) - { - if (methods[i].SerializationToString().Equals(_signature2)) - { - methodInfo = methods[i]; - break; - } - } - else - { - if (methods[i].ToString().Equals(_signature)) - { - methodInfo = methods[i]; - break; - } - } - - // Handle generic methods specially since the signature match above probably won't work (the candidate - // method info hasn't been instantiated). If our target method is generic as well we can skip this. - if (genericArguments != null && methods[i].IsGenericMethod) - { - if (methods[i].GetGenericArguments().Length == genericArguments.Length) - { - MethodInfo candidateMethod = methods[i].MakeGenericMethod(genericArguments); - - if (_signature2 != null) - { - if (candidateMethod.SerializationToString().Equals(_signature2)) - { - methodInfo = candidateMethod; - break; - } - } - else - { - if (candidateMethod.ToString().Equals(_signature)) - { - methodInfo = candidateMethod; - break; - } - } - } - } - } - } - - if (methodInfo == null) - throw new SerializationException(SR.Format(SR.Serialization_UnknownMember, _memberName)); - - if (!methodInfo.IsGenericMethodDefinition) - return methodInfo; - - if (genericArguments == null) - return methodInfo; - - if (genericArguments[0] == null) - return null; - - return methodInfo.MakeGenericMethod(genericArguments); - } - #endregion - - default: - throw new ArgumentException(SR.Serialization_MemberTypeNotRecognized); - } - } - #endregion - } -} - diff --git a/src/mscorlib/shared/System/Reflection/Missing.cs b/src/mscorlib/shared/System/Reflection/Missing.cs index fa32d43ccb..46ab32fccf 100644 --- a/src/mscorlib/shared/System/Reflection/Missing.cs +++ b/src/mscorlib/shared/System/Reflection/Missing.cs @@ -6,7 +6,6 @@ using System.Runtime.Serialization; namespace System.Reflection { - [Serializable] public sealed class Missing : ISerializable { public static readonly Missing Value = new Missing(); @@ -15,10 +14,7 @@ namespace System.Reflection void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) { - if (info == null) - throw new ArgumentNullException(nameof(info)); - - UnitySerializationHolder.GetUnitySerializationInfo(info, this); + throw new PlatformNotSupportedException(); } } } diff --git a/src/mscorlib/shared/System/Reflection/Module.cs b/src/mscorlib/shared/System/Reflection/Module.cs index 56f83c40d9..7822e9ff10 100644 --- a/src/mscorlib/shared/System/Reflection/Module.cs +++ b/src/mscorlib/shared/System/Reflection/Module.cs @@ -110,7 +110,10 @@ namespace System.Reflection public Type ResolveType(int metadataToken) => ResolveType(metadataToken, null, null); public virtual Type ResolveType(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) { throw NotImplemented.ByDesign; } - public virtual void GetObjectData(SerializationInfo info, StreamingContext context) { throw NotImplemented.ByDesign; } + public virtual void GetObjectData(SerializationInfo info, StreamingContext context) + { + throw new PlatformNotSupportedException(); + } public override bool Equals(object o) => base.Equals(o); public override int GetHashCode() => base.GetHashCode(); diff --git a/src/mscorlib/shared/System/Reflection/ParameterInfo.cs b/src/mscorlib/shared/System/Reflection/ParameterInfo.cs index 94bfffaa53..fd130e569b 100644 --- a/src/mscorlib/shared/System/Reflection/ParameterInfo.cs +++ b/src/mscorlib/shared/System/Reflection/ParameterInfo.cs @@ -54,46 +54,7 @@ namespace System.Reflection public object GetRealObject(StreamingContext context) { - // Once all the serializable fields have come in we can set up the real - // instance based on just two of them (MemberImpl and PositionImpl). - - if (MemberImpl == null) - throw new SerializationException(SR.Serialization_InsufficientState); - - ParameterInfo[] args = null; - - switch (MemberImpl.MemberType) - { - case MemberTypes.Constructor: - case MemberTypes.Method: - if (PositionImpl == -1) - { - if (MemberImpl.MemberType == MemberTypes.Method) - return ((MethodInfo)MemberImpl).ReturnParameter; - else - throw new SerializationException(SR.Serialization_BadParameterInfo); - } - else - { - args = ((MethodBase)MemberImpl).GetParametersNoCopy(); - - if (args != null && PositionImpl < args.Length) - return args[PositionImpl]; - else - throw new SerializationException(SR.Serialization_BadParameterInfo); - } - - case MemberTypes.Property: - args = ((PropertyInfo)MemberImpl).GetIndexParameters(); - - if (args != null && PositionImpl > -1 && PositionImpl < args.Length) - return args[PositionImpl]; - else - throw new SerializationException(SR.Serialization_BadParameterInfo); - - default: - throw new SerializationException(SR.Serialization_NoParameterInfo); - } + throw new PlatformNotSupportedException(); } public override string ToString() => ParameterType.FormatTypeName() + " " + Name; diff --git a/src/mscorlib/shared/System/Reflection/ParameterModifier.cs b/src/mscorlib/shared/System/Reflection/ParameterModifier.cs index 18d6cf669d..640fee284a 100644 --- a/src/mscorlib/shared/System/Reflection/ParameterModifier.cs +++ b/src/mscorlib/shared/System/Reflection/ParameterModifier.cs @@ -4,7 +4,6 @@ namespace System.Reflection { - [Serializable] public struct ParameterModifier { private readonly bool[] _byRef; diff --git a/src/mscorlib/shared/System/Reflection/Pointer.cs b/src/mscorlib/shared/System/Reflection/Pointer.cs index 13a5efff46..55376c66c0 100644 --- a/src/mscorlib/shared/System/Reflection/Pointer.cs +++ b/src/mscorlib/shared/System/Reflection/Pointer.cs @@ -7,7 +7,6 @@ using System.Runtime.Serialization; namespace System.Reflection { - [Serializable] [CLSCompliant(false)] public sealed unsafe class Pointer : ISerializable { @@ -22,14 +21,6 @@ namespace System.Reflection _ptrType = ptrType; } - private Pointer(SerializationInfo info, StreamingContext context) - { - _ptr = ((IntPtr)(info.GetValue("_ptr", typeof(IntPtr)))).ToPointer(); - _ptrType = (Type)info.GetValue("_ptrType", typeof(Type)); - if (!_ptrType.IsRuntimeImplemented()) - throw new SerializationException(SR.Arg_MustBeType); - } - public static object Box(void* ptr, Type type) { if (type == null) @@ -51,8 +42,7 @@ namespace System.Reflection void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) { - info.AddValue("_ptr", new IntPtr(_ptr)); - info.AddValue("_ptrType", _ptrType); + throw new PlatformNotSupportedException(); } internal Type GetPointerType() => _ptrType; diff --git a/src/mscorlib/shared/System/Reflection/ReflectionTypeLoadException.cs b/src/mscorlib/shared/System/Reflection/ReflectionTypeLoadException.cs index 772620cf84..ca0c6ab0db 100644 --- a/src/mscorlib/shared/System/Reflection/ReflectionTypeLoadException.cs +++ b/src/mscorlib/shared/System/Reflection/ReflectionTypeLoadException.cs @@ -6,7 +6,6 @@ using System.Runtime.Serialization; namespace System.Reflection { - [Serializable] public sealed class ReflectionTypeLoadException : SystemException, ISerializable { public ReflectionTypeLoadException(Type[] classes, Exception[] exceptions) @@ -25,18 +24,9 @@ namespace System.Reflection HResult = __HResults.COR_E_REFLECTIONTYPELOAD; } - internal ReflectionTypeLoadException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - Types = (Type[])(info.GetValue("Types", typeof(Type[]))); - LoaderExceptions = (Exception[])(info.GetValue("Exceptions", typeof(Exception[]))); - } - public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); - info.AddValue("Types", Types, typeof(Type[])); - info.AddValue("Exceptions", LoaderExceptions, typeof(Exception[])); } public Type[] Types { get; } diff --git a/src/mscorlib/shared/System/Reflection/StrongNameKeyPair.cs b/src/mscorlib/shared/System/Reflection/StrongNameKeyPair.cs index c04ddd6d1a..6efa626946 100644 --- a/src/mscorlib/shared/System/Reflection/StrongNameKeyPair.cs +++ b/src/mscorlib/shared/System/Reflection/StrongNameKeyPair.cs @@ -7,7 +7,6 @@ using System.Runtime.Serialization; namespace System.Reflection { - [Serializable] public class StrongNameKeyPair : IDeserializationCallback, ISerializable { private bool _keyPairExported; @@ -42,10 +41,7 @@ namespace System.Reflection protected StrongNameKeyPair(SerializationInfo info, StreamingContext context) { - _keyPairExported = (bool)info.GetValue("_keyPairExported", typeof(bool)); - _keyPairArray = (byte[])info.GetValue("_keyPairArray", typeof(byte[])); - _keyPairContainer = (string)info.GetValue("_keyPairContainer", typeof(string)); - _publicKey = (byte[])info.GetValue("_publicKey", typeof(byte[])); + throw new PlatformNotSupportedException(); } public StrongNameKeyPair(string keyPairContainer) @@ -63,12 +59,12 @@ namespace System.Reflection void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) { - info.AddValue("_keyPairExported", _keyPairExported); - info.AddValue("_keyPairArray", _keyPairArray); - info.AddValue("_keyPairContainer", _keyPairContainer); - info.AddValue("_publicKey", _publicKey); + throw new PlatformNotSupportedException(); } - void IDeserializationCallback.OnDeserialization(object sender) { } + void IDeserializationCallback.OnDeserialization(object sender) + { + throw new PlatformNotSupportedException(); + } } } diff --git a/src/mscorlib/shared/System/Reflection/TargetException.cs b/src/mscorlib/shared/System/Reflection/TargetException.cs index 03f8730cdd..6e43f56fa4 100644 --- a/src/mscorlib/shared/System/Reflection/TargetException.cs +++ b/src/mscorlib/shared/System/Reflection/TargetException.cs @@ -6,7 +6,6 @@ using System.Runtime.Serialization; namespace System.Reflection { - [Serializable] public class TargetException : ApplicationException { public TargetException() @@ -28,6 +27,7 @@ namespace System.Reflection protected TargetException(SerializationInfo info, StreamingContext context) : base(info, context) { + throw new PlatformNotSupportedException(); } } } diff --git a/src/mscorlib/shared/System/Reflection/TargetInvocationException.cs b/src/mscorlib/shared/System/Reflection/TargetInvocationException.cs index e934e5bde7..8d0bfef40d 100644 --- a/src/mscorlib/shared/System/Reflection/TargetInvocationException.cs +++ b/src/mscorlib/shared/System/Reflection/TargetInvocationException.cs @@ -6,7 +6,6 @@ using System.Runtime.Serialization; namespace System.Reflection { - [Serializable] public sealed class TargetInvocationException : ApplicationException { public TargetInvocationException(Exception inner) @@ -20,10 +19,5 @@ namespace System.Reflection { HResult = __HResults.COR_E_TARGETINVOCATION; } - - internal TargetInvocationException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } } } diff --git a/src/mscorlib/shared/System/Reflection/TargetParameterCountException.cs b/src/mscorlib/shared/System/Reflection/TargetParameterCountException.cs index c3604548e6..e200cdb94f 100644 --- a/src/mscorlib/shared/System/Reflection/TargetParameterCountException.cs +++ b/src/mscorlib/shared/System/Reflection/TargetParameterCountException.cs @@ -6,7 +6,6 @@ using System.Runtime.Serialization; namespace System.Reflection { - [Serializable] public sealed class TargetParameterCountException : ApplicationException { public TargetParameterCountException() @@ -26,10 +25,5 @@ namespace System.Reflection { HResult = __HResults.COR_E_TARGETPARAMCOUNT; } - - internal TargetParameterCountException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } } } diff --git a/src/mscorlib/shared/System/Reflection/TypeDelegator.cs b/src/mscorlib/shared/System/Reflection/TypeDelegator.cs index 7f928d2486..bcbff05d62 100644 --- a/src/mscorlib/shared/System/Reflection/TypeDelegator.cs +++ b/src/mscorlib/shared/System/Reflection/TypeDelegator.cs @@ -10,7 +10,6 @@ using CultureInfo = System.Globalization.CultureInfo; namespace System.Reflection { - [Serializable] public class TypeDelegator : TypeInfo { public override bool IsAssignableFrom(TypeInfo typeInfo) @@ -100,6 +99,7 @@ namespace System.Reflection protected override TypeAttributes GetAttributeFlagsImpl() => typeImpl.Attributes; + public override bool IsTypeDefinition => typeImpl.IsTypeDefinition; public override bool IsSZArray => typeImpl.IsSZArray; protected override bool IsArrayImpl() => typeImpl.IsArray; |