Changes to throw PlatformNotSupportedException from ISerializable.GetObjectData and serialization constructors on non-Serializable types. Also removes private serialization constructors and some unneeded code that was used to support serializing non-serializable types. A few tests testing GetObjectData implementations are also removed. For Exception types, we call base instead of throwing from GetObjectData to be consistent with the many Exceptions that don't override GetObjectData
<Compile Include="$(BclSourcesRoot)\System\Reflection\MdFieldInfo.cs" />
<Compile Include="$(BclSourcesRoot)\System\Reflection\MdImport.cs" />
<Compile Include="$(BclSourcesRoot)\System\Reflection\MemberInfo.Internal.cs" />
- <Compile Include="$(BclSourcesRoot)\System\Reflection\MemberSerializationStringGenerator.cs" />
<Compile Include="$(BclSourcesRoot)\System\Reflection\MethodBase.CoreCLR.cs" />
<Compile Include="$(BclSourcesRoot)\System\Reflection\MethodBody.cs" />
<Compile Include="$(BclSourcesRoot)\System\Reflection\RtFieldInfo.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Reflection\ManifestResourceInfo.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Reflection\MemberFilter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Reflection\MemberInfo.cs" />
- <Compile Include="$(MSBuildThisFileDirectory)System\Reflection\MemberInfoSerializationHolder.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Reflection\MemberTypes.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Reflection\MethodAttributes.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Reflection\MethodBase.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\UnauthorizedAccessException.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)System\UnhandledExceptionEventArgs.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)System\UnhandledExceptionEventHandler.cs"/>
- <Compile Include="$(MSBuildThisFileDirectory)System\UnitySerializationHolder.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)System\ValueTuple.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)System\Version.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)System\Void.cs"/>
HResult = __HResults.COR_E_APPLICATION;
}
- protected ApplicationException(SerializationInfo info, StreamingContext context) : base(info, context) { }
+ protected ApplicationException(SerializationInfo info, StreamingContext context) : base(info, context)
+ {
+ throw new PlatformNotSupportedException();
+ }
}
}
protected ArgumentException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
- _paramName = info.GetString("ParamName");
+ throw new PlatformNotSupportedException();
}
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
- info.AddValue("ParamName", _paramName, typeof(String));
}
public override String Message
HResult = __HResults.E_POINTER;
}
- protected ArgumentNullException(SerializationInfo info, StreamingContext context) : base(info, context) { }
+ protected ArgumentNullException(SerializationInfo info, StreamingContext context) : base(info, context)
+ {
+ throw new PlatformNotSupportedException();
+ }
}
}
protected ArgumentOutOfRangeException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
- _actualValue = info.GetValue("ActualValue", typeof(Object));
+ throw new PlatformNotSupportedException();
}
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
- info.AddValue("ActualValue", _actualValue, typeof(Object));
}
public override String Message
HResult = __HResults.COR_E_ARITHMETIC;
}
- protected ArithmeticException(SerializationInfo info, StreamingContext context) : base(info, context) { }
+ protected ArithmeticException(SerializationInfo info, StreamingContext context) : base(info, context)
+ {
+ throw new PlatformNotSupportedException();
+ }
}
}
HResult = __HResults.COR_E_ARRAYTYPEMISMATCH;
}
- protected ArrayTypeMismatchException(SerializationInfo info, StreamingContext context) : base(info, context) { }
+ protected ArrayTypeMismatchException(SerializationInfo info, StreamingContext context) : base(info, context)
+ {
+ throw new PlatformNotSupportedException();
+ }
}
}
protected BadImageFormatException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
- _fileName = info.GetString("BadImageFormat_FileName");
- _fusionLog = info.GetString("BadImageFormat_FusionLog");
+ throw new PlatformNotSupportedException();
}
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
-
- info.AddValue("BadImageFormat_FileName", _fileName, typeof(String));
- info.AddValue("BadImageFormat_FusionLog", _fusionLog, typeof(String));
}
public override String Message
HResult = __HResults.COR_E_KEYNOTFOUND;
}
- protected KeyNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) { }
+ protected KeyNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context)
+ {
+ throw new PlatformNotSupportedException();
+ }
}
}
private DBNull()
{
}
-
- private DBNull(SerializationInfo info, StreamingContext context)
- {
- throw new NotSupportedException(SR.NotSupported_DBNullSerial);
- }
-
+
public static readonly DBNull Value = new DBNull();
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
- UnitySerializationHolder.GetUnitySerializationInfo(info, UnitySerializationHolder.NullUnity, null, null);
+ throw new PlatformNotSupportedException();
}
public override string ToString()
{
HResult = __HResults.COR_E_DATAMISALIGNED;
}
-
- internal DataMisalignedException(SerializationInfo info, StreamingContext context) : base(info, context) { }
}
}
HResult = __HResults.COR_E_DIVIDEBYZERO;
}
- protected DivideByZeroException(SerializationInfo info, StreamingContext context) : base(info, context) { }
+ protected DivideByZeroException(SerializationInfo info, StreamingContext context) : base(info, context)
+ {
+ throw new PlatformNotSupportedException();
+ }
}
}
protected DllNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context)
{
+ throw new PlatformNotSupportedException();
}
}
}
{
HResult = __HResults.COR_E_DUPLICATEWAITOBJECT;
}
-
- // This constructor is required for serialization
- protected DuplicateWaitObjectException(SerializationInfo info, StreamingContext context) : base(info, context) { }
+
+ protected DuplicateWaitObjectException(SerializationInfo info, StreamingContext context) : base(info, context)
+ {
+ throw new PlatformNotSupportedException();
+ }
}
}
HResult = __HResults.COR_E_ENTRYPOINTNOTFOUND;
}
- protected EntryPointNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) { }
+ protected EntryPointNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context)
+ {
+ throw new PlatformNotSupportedException();
+ }
}
}
{
HResult = __HResults.COR_E_EXECUTIONENGINE;
}
-
- internal ExecutionEngineException(SerializationInfo info, StreamingContext context) : base(info, context) { }
}
}
HResult = __HResults.COR_E_FIELDACCESS;
}
- protected FieldAccessException(SerializationInfo info, StreamingContext context) : base(info, context) { }
+ protected FieldAccessException(SerializationInfo info, StreamingContext context) : base(info, context)
+ {
+ throw new PlatformNotSupportedException();
+ }
}
}
HResult = __HResults.COR_E_FORMAT;
}
- protected FormatException(SerializationInfo info, StreamingContext context) : base(info, context) { }
+ protected FormatException(SerializationInfo info, StreamingContext context) : base(info, context)
+ {
+ throw new PlatformNotSupportedException();
+ }
}
}
protected CultureNotFoundException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
- _invalidCultureId = (int?)info.GetValue("InvalidCultureId", typeof(int?));
- _invalidCultureName = (string)info.GetValue("InvalidCultureName", typeof(string));
+ throw new PlatformNotSupportedException();
}
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
- info.AddValue("InvalidCultureId", _invalidCultureId, typeof(int?));
- info.AddValue("InvalidCultureName", _invalidCultureName, typeof(string));
}
public virtual Nullable<int> InvalidCultureId
protected DirectoryNotFoundException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
+ throw new PlatformNotSupportedException();
}
}
}
protected EndOfStreamException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
+ throw new PlatformNotSupportedException();
}
}
}
protected FileLoadException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
- // Base class constructor will check info != null.
-
- FileName = info.GetString("FileLoad_FileName");
- FusionLog = info.GetString("FileLoad_FusionLog");
+ throw new PlatformNotSupportedException();
}
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
- // Serialize data for our base classes. base will verify info != null.
base.GetObjectData(info, context);
-
- // Serialize data for this class
- info.AddValue("FileLoad_FileName", FileName, typeof(string));
- info.AddValue("FileLoad_FusionLog", FusionLog, typeof(string));
}
}
}
protected FileNotFoundException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
- // Base class constructor will check info != null.
-
- FileName = info.GetString("FileNotFound_FileName");
- FusionLog = info.GetString("FileNotFound_FusionLog");
+ throw new PlatformNotSupportedException();
}
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
- // Serialize data for our base classes. base will verify info != null.
base.GetObjectData(info, context);
-
- // Serialize data for this class
- info.AddValue("FileNotFound_FileName", FileName, typeof(string));
- info.AddValue("FileNotFound_FusionLog", FusionLog, typeof(string));
}
}
}
protected PathTooLongException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
+ throw new PlatformNotSupportedException();
}
}
}
{
HResult = __HResults.COR_E_INDEXOUTOFRANGE;
}
-
- internal IndexOutOfRangeException(SerializationInfo info, StreamingContext context) : base(info, context) { }
}
}
{
HResult = __HResults.COR_E_INSUFFICIENTEXECUTIONSTACK;
}
-
- internal InsufficientExecutionStackException(SerializationInfo info, StreamingContext context) : base(info, context) { }
}
}
HResult = errorCode;
}
- protected InvalidCastException(SerializationInfo info, StreamingContext context) : base(info, context) { }
+ protected InvalidCastException(SerializationInfo info, StreamingContext context) : base(info, context)
+ {
+ throw new PlatformNotSupportedException();
+ }
}
}
HResult = __HResults.COR_E_INVALIDOPERATION;
}
- protected InvalidOperationException(SerializationInfo info, StreamingContext context) : base(info, context) { }
+ protected InvalidOperationException(SerializationInfo info, StreamingContext context) : base(info, context)
+ {
+ throw new PlatformNotSupportedException();
+ }
}
}
{
HResult = __HResults.COR_E_INVALIDPROGRAM;
}
-
- internal InvalidProgramException(SerializationInfo info, StreamingContext context) : base(info, context) { }
}
}
{
}
- protected InvalidTimeZoneException(SerializationInfo info, StreamingContext context) : base(info, context) { }
+ protected InvalidTimeZoneException(SerializationInfo info, StreamingContext context) : base(info, context)
+ {
+ throw new PlatformNotSupportedException();
+ }
}
}
HResult = __HResults.COR_E_MEMBERACCESS;
}
- protected MemberAccessException(SerializationInfo info, StreamingContext context) : base(info, context) { }
+ protected MemberAccessException(SerializationInfo info, StreamingContext context) : base(info, context)
+ {
+ throw new PlatformNotSupportedException();
+ }
}
}
HResult = __HResults.COR_E_METHODACCESS;
}
- protected MethodAccessException(SerializationInfo info, StreamingContext context) : base(info, context) { }
+ protected MethodAccessException(SerializationInfo info, StreamingContext context) : base(info, context)
+ {
+ throw new PlatformNotSupportedException();
+ }
}
}
protected MissingMethodException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
+ throw new PlatformNotSupportedException();
}
public override string Message
{
HResult = __HResults.COR_E_MULTICASTNOTSUPPORTED;
}
-
- internal MulticastNotSupportedException(SerializationInfo info, StreamingContext context) : base(info, context) { }
}
}
protected NotFiniteNumberException(SerializationInfo info, StreamingContext context) : base(info, context)
{
- _offendingNumber = info.GetInt32("OffendingNumber");
+ throw new PlatformNotSupportedException();
}
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
- info.AddValue("OffendingNumber", _offendingNumber, typeof(Int32));
}
public double OffendingNumber
HResult = __HResults.E_NOTIMPL;
}
- protected NotImplementedException(SerializationInfo info, StreamingContext context) : base(info, context) { }
+ protected NotImplementedException(SerializationInfo info, StreamingContext context) : base(info, context)
+ {
+ throw new PlatformNotSupportedException();
+ }
}
}
HResult = __HResults.COR_E_NOTSUPPORTED;
}
- protected NotSupportedException(SerializationInfo info, StreamingContext context) : base(info, context) { }
+ protected NotSupportedException(SerializationInfo info, StreamingContext context) : base(info, context)
+ {
+ throw new PlatformNotSupportedException();
+ }
}
}
HResult = __HResults.COR_E_NULLREFERENCE;
}
- protected NullReferenceException(SerializationInfo info, StreamingContext context) : base(info, context) { }
+ protected NullReferenceException(SerializationInfo info, StreamingContext context) : base(info, context)
+ {
+ throw new PlatformNotSupportedException();
+ }
}
}
protected ObjectDisposedException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
- _objectName = info.GetString("ObjectName");
+ throw new PlatformNotSupportedException();
}
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
- info.AddValue("ObjectName", ObjectName, typeof(String));
}
/// <devdoc>
protected OperationCanceledException(SerializationInfo info, StreamingContext context) : base(info, context)
{
+ throw new PlatformNotSupportedException();
}
}
}
HResult = __HResults.COR_E_OVERFLOW;
}
- protected OverflowException(SerializationInfo info, StreamingContext context) : base(info, context) { }
+ protected OverflowException(SerializationInfo info, StreamingContext context) : base(info, context)
+ {
+ throw new PlatformNotSupportedException();
+ }
}
}
HResult = __HResults.COR_E_PLATFORMNOTSUPPORTED;
}
- protected PlatformNotSupportedException(SerializationInfo info, StreamingContext context) : base(info, context) { }
+ protected PlatformNotSupportedException(SerializationInfo info, StreamingContext context) : base(info, context)
+ {
+ throw new PlatformNotSupportedException();
+ }
}
}
HResult = __HResults.COR_E_RANK;
}
- protected RankException(SerializationInfo info, StreamingContext context) : base(info, context) { }
+ protected RankException(SerializationInfo info, StreamingContext context) : base(info, context)
+ {
+ throw new PlatformNotSupportedException();
+ }
}
}
{
HResult = __HResults.COR_E_AMBIGUOUSMATCH;
}
-
- internal AmbiguousMatchException(SerializationInfo info, StreamingContext context)
- : base(info, context)
- {
- }
}
}
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()
{
protected CustomAttributeFormatException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
+ throw new PlatformNotSupportedException();
}
}
}
protected InvalidFilterCriteriaException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
+ throw new PlatformNotSupportedException();
}
}
}
+++ /dev/null
-// 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
-{
-#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
- }
-}
-
void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
{
- if (info == null)
- throw new ArgumentNullException(nameof(info));
-
- UnitySerializationHolder.GetUnitySerializationInfo(info, this);
+ throw new PlatformNotSupportedException();
}
}
}
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();
_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)
void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
{
- info.AddValue("_ptr", new IntPtr(_ptr));
- info.AddValue("_ptrType", _ptrType);
+ throw new PlatformNotSupportedException();
}
internal Type GetPointerType() => _ptrType;
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; }
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)
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) { }
protected TargetException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
+ throw new PlatformNotSupportedException();
}
}
}
{
HResult = __HResults.COR_E_TARGETINVOCATION;
}
-
- internal TargetInvocationException(SerializationInfo info, StreamingContext context)
- : base(info, context)
- {
- }
}
}
{
HResult = __HResults.COR_E_TARGETPARAMCOUNT;
}
-
- internal TargetParameterCountException(SerializationInfo info, StreamingContext context)
- : base(info, context)
- {
- }
}
}
protected MissingManifestResourceException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
+ throw new PlatformNotSupportedException();
}
}
}
protected MissingSatelliteAssemblyException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
+ throw new PlatformNotSupportedException();
}
public String CultureName
protected ExternalException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
+ throw new PlatformNotSupportedException();
}
public virtual int ErrorCode
protected SerializationException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
+ throw new PlatformNotSupportedException();
}
}
}
protected CryptographicException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
+ throw new PlatformNotSupportedException();
}
}
}
protected SecurityException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
+ throw new PlatformNotSupportedException();
}
public override string ToString() => base.ToString();
protected VerificationException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
+ throw new PlatformNotSupportedException();
}
}
}
{
HResult = __HResults.COR_E_STACKOVERFLOW;
}
-
- internal StackOverflowException(SerializationInfo info, StreamingContext context) : base(info, context) { }
}
}
HResult = __HResults.COR_E_SYSTEM;
}
- protected SystemException(SerializationInfo info, StreamingContext context) : base(info, context) { }
+ protected SystemException(SerializationInfo info, StreamingContext context) : base(info, context)
+ {
+ throw new PlatformNotSupportedException();
+ }
}
}
// base calls reset
}
- // Constructor called by serialization, have to handle deserializing from Everett
- internal UTF8Encoder(SerializationInfo info, StreamingContext context)
- {
- // Any info?
- if (info == null) throw new ArgumentNullException(nameof(info));
- Contract.EndContractBlock();
-
- // Get common info
- this.m_encoding = (Encoding)info.GetValue("encoding", typeof(Encoding));
-
- // SurrogateChar happens to mean the same thing
- this.surrogateChar = (int)info.GetValue("surrogateChar", typeof(int));
-
- try
- {
- this.m_fallback = (EncoderFallback)info.GetValue("m_fallback", typeof(EncoderFallback));
- }
- catch (SerializationException)
- {
- this.m_fallback = null;
- }
- }
-
- // ISerializable implementation, get data for this object
+ // ISerializable implementation
void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
{
- // Any info?
- if (info == null) throw new ArgumentNullException(nameof(info));
- Contract.EndContractBlock();
-
- // Save Whidbey data
- // Just need Everett maxCharSize (BaseCodePageEncoding) or m_maxByteSize (MLangBaseCodePageEncoding)
- info.AddValue("encoding", this.m_encoding);
- info.AddValue("surrogateChar", this.surrogateChar);
-
- info.AddValue("m_fallback", this.m_fallback);
-
- // Extra stuff for Everett that Whidbey doesn't use
- info.AddValue("storedSurrogate", this.surrogateChar > 0 ? true : false);
- info.AddValue("mustFlush", false); // Everett doesn't actually use this either, but it accidently serialized it!
+ throw new PlatformNotSupportedException();
}
public override void Reset()
// Constructor called by serialization, have to handle deserializing from Everett
internal UTF8Decoder(SerializationInfo info, StreamingContext context)
{
- // Any info?
- if (info == null) throw new ArgumentNullException(nameof(info));
- Contract.EndContractBlock();
-
- // Get common info
- this.m_encoding = (Encoding)info.GetValue("encoding", typeof(Encoding));
-
- try
- {
- // Get whidbey version of bits
- this.bits = (int)info.GetValue("wbits", typeof(int));
- this.m_fallback = (DecoderFallback)info.GetValue("m_fallback", typeof(DecoderFallback));
- }
- catch (SerializationException)
- {
- // Everett calls bits bits instead of wbits, so this is Everett
- this.bits = 0;
- this.m_fallback = null;
- }
+ throw new PlatformNotSupportedException();
}
// ISerializable implementation, get data for this object
void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
{
- // Any info?
- if (info == null) throw new ArgumentNullException(nameof(info));
- Contract.EndContractBlock();
-
- // Save new Whidbey data
- info.AddValue("encoding", this.m_encoding);
- info.AddValue("wbits", this.bits); // Special whidbey bits name
- info.AddValue("m_fallback", this.m_fallback);
-
- // Everett has extra stuff, we set it all to 0 in case this deserializes in Everett
- info.AddValue("bits", (int)0);
- info.AddValue("trailCount", (int)0);
- info.AddValue("isSurrogate", false);
- info.AddValue("byteSequence", (int)0);
+ throw new PlatformNotSupportedException();
}
public override void Reset()
{
// base calls reset
}
-
- // Constructor called by serialization, have to handle deserializing from Everett
+
internal Decoder(SerializationInfo info, StreamingContext context)
{
- // Any info?
- if (info == null) throw new ArgumentNullException(nameof(info));
- Contract.EndContractBlock();
-
- // Get Common Info
- this.lastByte = (int)info.GetValue("lastByte", typeof(int));
-
- try
- {
- // Try the encoding, which is only serialized in Whidbey
- this.m_encoding = (Encoding)info.GetValue("m_encoding", typeof(Encoding));
- this.lastChar = (char)info.GetValue("lastChar", typeof(char));
- this.m_fallback = (DecoderFallback)info.GetValue("m_fallback", typeof(DecoderFallback));
- }
- catch (SerializationException)
- {
- // Everett didn't serialize the UnicodeEncoding, get the default one
- bool bigEndian = (bool)info.GetValue("bigEndian", typeof(bool));
- this.m_encoding = new UnicodeEncoding(bigEndian, false);
- }
+ throw new PlatformNotSupportedException();
}
- // ISerializable implementation, get data for this object
+ // ISerializable implementation
void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
{
- // Any info?
- if (info == null) throw new ArgumentNullException(nameof(info));
- Contract.EndContractBlock();
-
- // Save Whidbey data
- info.AddValue("m_encoding", this.m_encoding);
- info.AddValue("m_fallback", this.m_fallback);
- info.AddValue("lastChar", this.lastChar); // Unused by everett so it'll probably get lost
- info.AddValue("lastByte", this.lastByte);
-
- // Everett Only
- info.AddValue("bigEndian", ((UnicodeEncoding)(this.m_encoding)).bigEndian);
+ throw new PlatformNotSupportedException();
}
public override void Reset()
protected AbandonedMutexException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
+ throw new PlatformNotSupportedException();
}
private void SetupException(int location, WaitHandle handle)
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
- if (info == null)
- {
- throw new ArgumentNullException(nameof(info));
- }
- Contract.EndContractBlock();
- }
-
- private ExecutionContext(SerializationInfo info, StreamingContext context)
- {
+ throw new PlatformNotSupportedException();
}
public static ExecutionContext Capture()
{
}
- protected LockRecursionException(SerializationInfo info, StreamingContext context) : base(info, context) { }
+ protected LockRecursionException(SerializationInfo info, StreamingContext context) : base(info, context)
+ {
+ throw new PlatformNotSupportedException();
+ }
}
}
protected SemaphoreFullException(SerializationInfo info, StreamingContext context) : base(info, context)
{
+ throw new PlatformNotSupportedException();
}
}
}
protected SynchronizationLockException(SerializationInfo info, StreamingContext context) : base(info, context)
{
+ throw new PlatformNotSupportedException();
}
}
}
/// <param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext"/> that contains contextual information about the source or destination. </param>
protected TaskCanceledException(SerializationInfo info, StreamingContext context) : base(info, context)
{
+ throw new PlatformNotSupportedException();
}
/// <summary>
protected TaskSchedulerException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
+ throw new PlatformNotSupportedException();
}
}
}
HResult = __HResults.COR_E_THREADABORTED;
}
- internal ThreadAbortException(SerializationInfo info, StreamingContext context)
- : base(info, context)
- {
- }
-
public object ExceptionState => null;
}
}
{
HResult = __HResults.COR_E_THREADSTART;
}
-
- internal ThreadStartException(SerializationInfo info, StreamingContext context)
- : base(info, context)
- {
- }
}
}
protected ThreadStateException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
+ throw new PlatformNotSupportedException();
}
}
}
protected WaitHandleCannotBeOpenedException(SerializationInfo info, StreamingContext context) : base(info, context)
{
+ throw new PlatformNotSupportedException();
}
}
}
{
}
- protected TimeZoneNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) { }
+ protected TimeZoneNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context)
+ {
+ throw new PlatformNotSupportedException();
+ }
}
}
HResult = __HResults.COR_E_TIMEOUT;
}
- protected TimeoutException(SerializationInfo info, StreamingContext context) : base(info, context) { }
+ protected TimeoutException(SerializationInfo info, StreamingContext context) : base(info, context)
+ {
+ throw new PlatformNotSupportedException();
+ }
}
}
HResult = __HResults.COR_E_TYPEACCESS;
}
- protected TypeAccessException(SerializationInfo info, StreamingContext context) : base(info, context) { }
+ protected TypeAccessException(SerializationInfo info, StreamingContext context) : base(info, context)
+ {
+ throw new PlatformNotSupportedException();
+ }
}
}
HResult = __HResults.COR_E_TYPEINITIALIZATION;
}
- internal TypeInitializationException(SerializationInfo info, StreamingContext context)
- : base(info, context)
- {
- _typeName = info.GetString("TypeName");
- }
-
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
- info.AddValue("TypeName", TypeName, typeof(String));
}
public String TypeName
{
HResult = __HResults.COR_E_TYPEUNLOADED;
}
-
- //
- // This constructor is required for serialization;
- //
+
protected TypeUnloadedException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
+ throw new PlatformNotSupportedException();
}
}
}
HResult = __HResults.COR_E_UNAUTHORIZEDACCESS;
}
- protected UnauthorizedAccessException(SerializationInfo info, StreamingContext context) : base(info, context) { }
+ protected UnauthorizedAccessException(SerializationInfo info, StreamingContext context) : base(info, context)
+ {
+ throw new PlatformNotSupportedException();
+ }
}
}
+++ /dev/null
-// 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.Runtime.Serialization;
-using System.Reflection;
-using System.Globalization;
-using System.Runtime.Versioning;
-using System.Collections.Generic;
-using System.Diagnostics.Contracts;
-
-namespace System
-{
- // Holds classes (Empty, Null, Missing) for which we guarantee that there is only ever one instance of.
-#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 UnitySerializationHolder : ISerializable, IObjectReference
- {
-#region Internal Constants
- internal const int EmptyUnity = 0x0001;
- internal const int NullUnity = 0x0002;
- internal const int MissingUnity = 0x0003;
- internal const int RuntimeTypeUnity = 0x0004;
- public const int ModuleUnity = 0x0005;
- public const int AssemblyUnity = 0x0006;
- internal const int GenericParameterTypeUnity = 0x0007;
- internal const int PartialInstantiationTypeUnity = 0x0008;
-
- internal const int Pointer = 0x0001;
- internal const int Array = 0x0002;
- internal const int SzArray = 0x0003;
- internal const int ByRef = 0x0004;
-#endregion
-
-#region Internal Static Members
- internal static void GetUnitySerializationInfo(SerializationInfo info, Missing missing)
- {
- info.SetType(typeof(UnitySerializationHolder));
- info.AddValue("UnityType", MissingUnity);
- }
-
- internal static Type AddElementTypes(SerializationInfo info, Type type)
- {
- List<int> elementTypes = new List<int>();
- while (type.HasElementType)
- {
- if (type.IsSZArray)
- {
- elementTypes.Add(SzArray);
- }
- else if (type.IsArray)
- {
- elementTypes.Add(type.GetArrayRank());
- elementTypes.Add(Array);
- }
- else if (type.IsPointer)
- {
- elementTypes.Add(Pointer);
- }
- else if (type.IsByRef)
- {
- elementTypes.Add(ByRef);
- }
-
- type = type.GetElementType();
- }
-
- info.AddValue("ElementTypes", elementTypes.ToArray(), typeof(int[]));
-
- return type;
- }
-
- internal Type MakeElementTypes(Type type)
- {
- for (int i = _elementTypes.Length - 1; i >= 0; i--)
- {
- if (_elementTypes[i] == SzArray)
- {
- type = type.MakeArrayType();
- }
- else if (_elementTypes[i] == Array)
- {
- type = type.MakeArrayType(_elementTypes[--i]);
- }
- else if ((_elementTypes[i] == Pointer))
- {
- type = type.MakePointerType();
- }
- else if ((_elementTypes[i] == ByRef))
- {
- type = type.MakeByRefType();
- }
- }
-
- return type;
- }
-
- public static void GetUnitySerializationInfo(SerializationInfo info, Type type)
- {
- Type rootElementType = type;
- while (rootElementType.HasElementType)
- {
- rootElementType = rootElementType.GetElementType();
- }
-
- if (rootElementType.IsGenericParameter)
- {
- type = AddElementTypes(info, type);
- info.SetType(typeof(UnitySerializationHolder));
- info.AddValue("UnityType", GenericParameterTypeUnity);
- info.AddValue("GenericParameterPosition", type.GenericParameterPosition);
- info.AddValue("DeclaringMethod", type.DeclaringMethod, typeof(MethodBase));
- info.AddValue("DeclaringType", type.DeclaringType, typeof(Type));
-
- return;
- }
-
- int unityType = RuntimeTypeUnity;
-
- if (!type.IsGenericTypeDefinition && type.ContainsGenericParameters)
- {
- // Partial instantiation
- unityType = PartialInstantiationTypeUnity;
- type = AddElementTypes(info, type);
- info.AddValue("GenericArguments", type.GetGenericArguments(), typeof(Type[]));
- type = type.GetGenericTypeDefinition();
- }
-
- GetUnitySerializationInfo(info, unityType, type.FullName, type.Assembly);
- }
-
- public static void GetUnitySerializationInfo(
- SerializationInfo info, int unityType, string data, Assembly assembly)
- {
- // A helper method that returns the SerializationInfo that a class utilizing
- // UnitySerializationHelper should return from a call to GetObjectData. It contains
- // the unityType (defined above) and any optional data (used only for the reflection
- // types.)
-
- info.SetType(typeof(UnitySerializationHolder));
- info.AddValue("Data", data, typeof(string));
- info.AddValue("UnityType", unityType);
-
- string assemName;
-
- if (assembly == null)
- {
- assemName = string.Empty;
- }
- else
- {
- assemName = assembly.FullName;
- }
-
- info.AddValue("AssemblyName", assemName);
- }
-#endregion
-
-#region Private Data Members
- private readonly Type[] _instantiation;
- private readonly int[] _elementTypes;
- private readonly int _genericParameterPosition;
- private readonly Type _declaringType;
- private readonly MethodBase _declaringMethod;
- private readonly string _data;
- private readonly string _assemblyName;
- private int _unityType;
-#endregion
-
-#region Constructor
- public UnitySerializationHolder(SerializationInfo info, StreamingContext context)
- {
- if (info == null)
- throw new ArgumentNullException(nameof(info));
- Contract.EndContractBlock();
-
- _unityType = info.GetInt32("UnityType");
-
- if (_unityType == MissingUnity)
- return;
-
- if (_unityType == GenericParameterTypeUnity)
- {
- _declaringMethod = info.GetValue("DeclaringMethod", typeof(MethodBase)) as MethodBase;
- _declaringType = info.GetValue("DeclaringType", typeof(Type)) as Type;
- _genericParameterPosition = info.GetInt32("GenericParameterPosition");
- _elementTypes = info.GetValue("ElementTypes", typeof(int[])) as int[];
-
- return;
- }
-
- if (_unityType == PartialInstantiationTypeUnity)
- {
- _instantiation = info.GetValue("GenericArguments", typeof(Type[])) as Type[];
- _elementTypes = info.GetValue("ElementTypes", typeof(int[])) as int[];
- }
-
- _data = info.GetString("Data");
- _assemblyName = info.GetString("AssemblyName");
- }
-#endregion
-
-#region Private Methods
- private void ThrowInsufficientInformation(string field)
- {
- throw new SerializationException(
- SR.Format(SR.Serialization_InsufficientDeserializationState, field));
- }
-#endregion
-
-#region ISerializable
- public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
- {
- throw new NotSupportedException(SR.NotSupported_UnitySerHolder);
- }
-#endregion
-
-#region IObjectReference
- public virtual object GetRealObject(StreamingContext context)
- {
- // GetRealObject uses the data we have in _data and _unityType to do a lookup on the correct
- // object to return. We have specific code here to handle the different types which we support.
- // The reflection types (Assembly, Module, and Type) have to be looked up through their static
- // accessors by name.
-
- Assembly assembly;
-
- switch (_unityType)
- {
- case EmptyUnity:
- {
- return Empty.Value;
- }
-
- case NullUnity:
- {
- return DBNull.Value;
- }
-
- case MissingUnity:
- {
- return Missing.Value;
- }
-
- case PartialInstantiationTypeUnity:
- {
- _unityType = RuntimeTypeUnity;
- Type definition = GetRealObject(context) as Type;
- _unityType = PartialInstantiationTypeUnity;
-
- if (_instantiation[0] == null)
- return null;
-
- return MakeElementTypes(definition.MakeGenericType(_instantiation));
- }
-
- case GenericParameterTypeUnity:
- {
- if (_declaringMethod == null && _declaringType == null)
- ThrowInsufficientInformation("DeclaringMember");
-
- if (_declaringMethod != null)
- return _declaringMethod.GetGenericArguments()[_genericParameterPosition];
-
- return MakeElementTypes(_declaringType.GetGenericArguments()[_genericParameterPosition]);
- }
-
- case RuntimeTypeUnity:
- {
- if (_data == null || _data.Length == 0)
- ThrowInsufficientInformation("Data");
-
- if (_assemblyName == null)
- ThrowInsufficientInformation("AssemblyName");
-
- if (_assemblyName.Length == 0)
- return Type.GetType(_data, true, false);
-
- assembly = Assembly.Load(_assemblyName);
-
- Type t = assembly.GetType(_data, true, false);
-
- return t;
- }
-
- case ModuleUnity:
- {
- if (_data == null || _data.Length == 0)
- ThrowInsufficientInformation("Data");
-
- if (_assemblyName == null)
- ThrowInsufficientInformation("AssemblyName");
-
- assembly = Assembly.Load(_assemblyName);
-
- Module namedModule = assembly.GetModule(_data);
-
- if (namedModule == null)
- throw new SerializationException(
- SR.Format(SR.Serialization_UnableToFindModule, _data, _assemblyName));
-
- return namedModule;
- }
-
- case AssemblyUnity:
- {
- if (_data == null || _data.Length == 0)
- ThrowInsufficientInformation("Data");
-
- if (_assemblyName == null)
- ThrowInsufficientInformation("AssemblyName");
-
- assembly = Assembly.Load(_assemblyName);
-
- return assembly;
- }
-
- default:
- throw new ArgumentException(SR.Argument_InvalidUnity);
- }
- }
-#endregion
- }
-}
HResult = __HResults.E_POINTER;
}
- protected AccessViolationException(SerializationInfo info, StreamingContext context) : base(info, context) { }
+ protected AccessViolationException(SerializationInfo info, StreamingContext context) : base(info, context)
+ {
+ throw new PlatformNotSupportedException();
+ }
#pragma warning disable 169 // Field is not used from managed.
private IntPtr _ip; // Address of faulting instruction.
//
protected AppDomainUnloadedException(SerializationInfo info, StreamingContext context) : base(info, context)
{
+ throw new PlatformNotSupportedException();
}
}
}
m_compareInfo = culture.CompareInfo;
}
- private Comparer(SerializationInfo info, StreamingContext context)
- {
- m_compareInfo = null;
- SerializationInfoEnumerator enumerator = info.GetEnumerator();
- while (enumerator.MoveNext())
- {
- switch (enumerator.Name)
- {
- case CompareInfoName:
- m_compareInfo = (CompareInfo)info.GetValue(CompareInfoName, typeof(CompareInfo));
- break;
- }
- }
- }
-
// Compares two Objects by calling CompareTo. If a ==
// b,0 is returned. If a implements
// IComparable, a.CompareTo(b) is returned. If a
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
- if (info == null)
- {
- throw new ArgumentNullException(nameof(info));
- }
- Contract.EndContractBlock();
-
- if (m_compareInfo != null)
- {
- info.AddValue(CompareInfoName, m_compareInfo);
- }
+ throw new PlatformNotSupportedException();
}
}
}
public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
{
- if (info == null)
- {
- throw new ArgumentNullException(nameof(info));
- }
- Contract.EndContractBlock();
- // This is imperfect - it only works well if all other writes are
- // also using our synchronized wrapper. But it's still a good idea.
- lock (SyncRoot)
- {
- // This method hasn't been fully tweaked to be safe for a concurrent writer.
- int oldVersion = version;
- info.AddValue(LoadFactorName, loadFactor);
- info.AddValue(VersionName, version);
-
- //
- // We need to maintain serialization compatibility with Everett and RTM.
- // If the comparer is null or a compatible comparer, serialize Hashtable
- // in a format that can be deserialized on Everett and RTM.
- //
-#pragma warning disable 618
- IEqualityComparer keyComparerForSerilization = _keycomparer;
-
- if (keyComparerForSerilization == null)
- {
- info.AddValue(ComparerName, null, typeof(IComparer));
- info.AddValue(HashCodeProviderName, null, typeof(IHashCodeProvider));
- }
- else if (keyComparerForSerilization is CompatibleComparer)
- {
- CompatibleComparer c = keyComparerForSerilization as CompatibleComparer;
- info.AddValue(ComparerName, c.Comparer, typeof(IComparer));
- info.AddValue(HashCodeProviderName, c.HashCodeProvider, typeof(IHashCodeProvider));
- }
- else
- {
- info.AddValue(KeyComparerName, keyComparerForSerilization, typeof(IEqualityComparer));
- }
-#pragma warning restore 618
-
- info.AddValue(HashSizeName, buckets.Length); //This is the length of the bucket array.
- Object[] serKeys = new Object[count];
- Object[] serValues = new Object[count];
- CopyKeys(serKeys, 0);
- CopyValues(serValues, 0);
- info.AddValue(KeysName, serKeys, typeof(Object[]));
- info.AddValue(ValuesName, serValues, typeof(Object[]));
-
- // Explicitly check to see if anyone changed the Hashtable while we
- // were serializing it. That's a race condition in their code.
- if (version != oldVersion)
- throw new InvalidOperationException(SR.GetResourceString(ResId.InvalidOperation_EnumFailedVersion));
- }
+ throw new PlatformNotSupportedException();
}
//
==============================================================================*/
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
- if (info == null)
- {
- throw new ArgumentNullException(nameof(info));
- }
- Contract.EndContractBlock();
- // Our serialization code hasn't been fully tweaked to be safe
- // for a concurrent writer.
- lock (_table.SyncRoot)
- {
- info.AddValue("ParentTable", _table, typeof(Hashtable));
- }
+ throw new PlatformNotSupportedException();
}
public override int Count
public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
{
- throw new NotSupportedException();
+ throw new PlatformNotSupportedException();
}
+
//
// internal implementation details (FCALLS and utilities)
//
_Condition = condition;
}
- private ContractException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
- : base(info, context)
- {
- _Kind = (ContractFailureKind)info.GetInt32("Kind");
- _UserMessage = info.GetString("UserMessage");
- _Condition = info.GetString("Condition");
- }
-
public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
{
base.GetObjectData(info, context);
-
- info.AddValue("Kind", _Kind);
- info.AddValue("UserMessage", _UserMessage);
- info.AddValue("Condition", _Condition);
}
}
}
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
- if (info == null)
- {
- throw new ArgumentNullException(nameof(info));
- }
- Contract.EndContractBlock();
- UnitySerializationHolder.GetUnitySerializationInfo(info, UnitySerializationHolder.EmptyUnity, null, null);
+ throw new PlatformNotSupportedException();
}
}
}
_stackTraceString = info.GetString("StackTraceString");
_remoteStackTraceString = info.GetString("RemoteStackTraceString");
_remoteStackIndex = info.GetInt32("RemoteStackIndex");
-
- _exceptionMethodString = (String)(info.GetValue("ExceptionMethod", typeof(String)));
+
HResult = info.GetInt32("HResult");
_source = info.GetString("Source");
{
return null;
}
-
- if (_exceptionMethodString != null)
- {
- _exceptionMethod = GetExceptionMethodFromString();
- }
- else
- {
- _exceptionMethod = GetExceptionMethodFromStackTrace();
- }
+
+ _exceptionMethod = GetExceptionMethodFromStackTrace();
return _exceptionMethod;
}
return s;
}
- private String GetExceptionMethodString()
- {
- MethodBase methBase = GetTargetSiteInternal();
- if (methBase == null)
- {
- return null;
- }
- if (methBase is System.Reflection.Emit.DynamicMethod.RTDynamicMethod)
- {
- // DynamicMethods cannot be serialized
- return null;
- }
-
- // Note that the newline separator is only a separator, chosen such that
- // it won't (generally) occur in a method name. This string is used
- // only for serialization of the Exception Method.
- char separator = '\n';
- StringBuilder result = new StringBuilder();
- if (methBase is ConstructorInfo)
- {
- RuntimeConstructorInfo rci = (RuntimeConstructorInfo)methBase;
- Type t = rci.ReflectedType;
- result.Append((int)MemberTypes.Constructor);
- result.Append(separator);
- result.Append(rci.Name);
- if (t != null)
- {
- result.Append(separator);
- result.Append(t.Assembly.FullName);
- result.Append(separator);
- result.Append(t.FullName);
- }
- result.Append(separator);
- result.Append(rci.ToString());
- }
- else
- {
- Debug.Assert(methBase is MethodInfo, "[Exception.GetExceptionMethodString]methBase is MethodInfo");
- RuntimeMethodInfo rmi = (RuntimeMethodInfo)methBase;
- Type t = rmi.DeclaringType;
- result.Append((int)MemberTypes.Method);
- result.Append(separator);
- result.Append(rmi.Name);
- result.Append(separator);
- result.Append(rmi.Module.Assembly.FullName);
- result.Append(separator);
- if (t != null)
- {
- result.Append(t.FullName);
- result.Append(separator);
- }
- result.Append(rmi.ToString());
- }
-
- return result.ToString();
- }
-
- private MethodBase GetExceptionMethodFromString()
- {
- Debug.Assert(_exceptionMethodString != null, "Method string cannot be NULL!");
- String[] args = _exceptionMethodString.Split(new char[] { '\0', '\n' });
- if (args.Length != 5)
- {
- throw new SerializationException();
- }
- SerializationInfo si = new SerializationInfo(typeof(MemberInfoSerializationHolder), new FormatterConverter());
- si.AddValue("MemberType", (int)Int32.Parse(args[0], CultureInfo.InvariantCulture), typeof(Int32));
- si.AddValue("Name", args[1], typeof(String));
- si.AddValue("AssemblyName", args[2], typeof(String));
- si.AddValue("ClassName", args[3]);
- si.AddValue("Signature", args[4]);
- MethodBase result;
- StreamingContext sc = new StreamingContext(StreamingContextStates.All);
- try
- {
- result = (MethodBase)new MemberInfoSerializationHolder(si, sc).GetRealObject(sc);
- }
- catch (SerializationException)
- {
- result = null;
- }
- return result;
- }
-
protected event EventHandler<SafeSerializationEventArgs> SerializeObjectState
{
add { throw new PlatformNotSupportedException(SR.PlatformNotSupported_SecureBinarySerialization); }
info.AddValue("StackTraceString", tempStackTraceString, typeof(String));
info.AddValue("RemoteStackTraceString", _remoteStackTraceString, typeof(String));
info.AddValue("RemoteStackIndex", _remoteStackIndex, typeof(Int32));
- info.AddValue("ExceptionMethod", GetExceptionMethodString(), typeof(String));
+ info.AddValue("ExceptionMethod", null, typeof(String));
info.AddValue("HResult", HResult);
info.AddValue("Source", _source, typeof(String));
private String _className; //Needed for serialization.
private MethodBase _exceptionMethod; //Needed for serialization.
- private String _exceptionMethodString; //Needed for serialization.
+ private String _exceptionMethodString; //Needed for serialization.
internal String _message;
private IDictionary _data;
private Exception _innerException;
protected DriveNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context)
{
+ throw new PlatformNotSupportedException();
}
}
}
protected IOException(SerializationInfo info, StreamingContext context) : base(info, context)
{
+ throw new PlatformNotSupportedException();
}
}
}
{
HResult = __HResults.COR_E_INSUFFICIENTMEMORY;
}
-
- private InsufficientMemoryException(SerializationInfo info, StreamingContext context) : base(info, context)
- {
- }
}
}
protected MissingFieldException(SerializationInfo info, StreamingContext context) : base(info, context)
{
+ throw new PlatformNotSupportedException();
}
public override String Message
protected MissingMemberException(SerializationInfo info, StreamingContext context) : base(info, context)
{
- ClassName = (String)info.GetString("MMClassName");
- MemberName = (String)info.GetString("MMMemberName");
- Signature = (byte[])info.GetValue("MMSignature", typeof(byte[]));
+ throw new PlatformNotSupportedException();
}
public override String Message
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
- if (info == null)
- {
- throw new ArgumentNullException(nameof(info));
- }
- Contract.EndContractBlock();
base.GetObjectData(info, context);
- info.AddValue("MMClassName", ClassName, typeof(String));
- info.AddValue("MMMemberName", MemberName, typeof(String));
- info.AddValue("MMSignature", Signature, typeof(byte[]));
}
protected OutOfMemoryException(SerializationInfo info, StreamingContext context) : base(info, context)
{
+ throw new PlatformNotSupportedException();
}
}
}
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
- if (info == null)
- throw new ArgumentNullException(nameof(info));
- Contract.EndContractBlock();
-
- //Allocate the serialization info and serialize our static data.
- info.AddValue("_Name", _Name);
- info.AddValue("_PublicKey", _PublicKey, typeof(byte[]));
- info.AddValue("_PublicKeyToken", _PublicKeyToken, typeof(byte[]));
-#if FEATURE_USE_LCID
- info.AddValue("_CultureInfo", (_CultureInfo == null) ? -1 : _CultureInfo.LCID);
-#endif
- info.AddValue("_CodeBase", _CodeBase);
- info.AddValue("_Version", _Version);
- info.AddValue("_HashAlgorithm", _HashAlgorithm, typeof(AssemblyHashAlgorithm));
- info.AddValue("_HashAlgorithmForControl", _HashAlgorithmForControl, typeof(AssemblyHashAlgorithm));
- info.AddValue("_StrongNameKeyPair", _StrongNameKeyPair, typeof(StrongNameKeyPair));
- info.AddValue("_VersionCompatibility", _VersionCompatibility, typeof(AssemblyVersionCompatibility));
- info.AddValue("_Flags", _Flags, typeof(AssemblyNameFlags));
- info.AddValue("_HashForControl", _HashForControl, typeof(byte[]));
+ throw new PlatformNotSupportedException();
}
public void OnDeserialization(Object sender)
m_siInfo = null;
}
- // Constructs a new AssemblyName during deserialization.
- internal AssemblyName(SerializationInfo info, StreamingContext context)
- {
- //The graph is not valid until OnDeserialization() has been called.
- m_siInfo = info;
- }
-
public AssemblyName(String assemblyName)
{
if (assemblyName == null)
+++ /dev/null
-// 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.Text;
-using System.Reflection;
-using System.Diagnostics;
-using System.Collections.Generic;
-
-namespace System
-{
- internal static class MemberSerializationStringGenerator
- {
- //
- // Generate the "Signature2" binary serialization string for PropertyInfos
- //
- // Because the string is effectively a file format for serialized Reflection objects, it must be exactly correct. If missing
- // metadata prevents generating the string, this method throws a MissingMetadata exception.
- //
- public static string SerializationToString(this PropertyInfo property) => ((RuntimePropertyInfo)property).SerializationToString();
-
- //
- // Generate the "Signature2" binary serialization string for ConstructorInfos
- //
- // Because the string is effectively a file format for serialized Reflection objects, it must be exactly correct. If missing
- // metadata prevents generating the string, this method throws a MissingMetadata exception.
- //
- public static string SerializationToString(this ConstructorInfo constructor) => ((RuntimeConstructorInfo)constructor).SerializationToString();
-
- //
- // Generate the "Signature2" binary serialization string for MethodInfos
- //
- // Because the string is effectively a file format for serialized Reflection objects, it must be exactly correct. If missing
- // metadata prevents generating the string, this method throws a MissingMetadata exception.
- //
- public static string SerializationToString(this MethodInfo method) => ((RuntimeMethodInfo)method).SerializationToString();
- }
-}
// ISerializable implementation
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
- if (info == null)
- throw new ArgumentNullException(nameof(info));
-
- Contract.EndContractBlock();
-
- UnitySerializationHolder.GetUnitySerializationInfo(info,
- UnitySerializationHolder.AssemblyUnity,
- this.FullName,
- this);
+ throw new PlatformNotSupportedException();
}
public override Module ManifestModule
#region ISerializable Implementation
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
- if (info == null)
- throw new ArgumentNullException(nameof(info));
- Contract.EndContractBlock();
- MemberInfoSerializationHolder.GetSerializationInfo(info, this);
+ throw new PlatformNotSupportedException();
}
internal string SerializationToString()
#region ISerializable
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
- if (info == null)
- throw new ArgumentNullException(nameof(info));
- Contract.EndContractBlock();
-
- MemberInfoSerializationHolder.GetSerializationInfo(info, this);
+ throw new PlatformNotSupportedException();
}
#endregion
#region ISerializable Implementation
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
- if (info == null)
- throw new ArgumentNullException(nameof(info));
- Contract.EndContractBlock();
-
- MemberInfoSerializationHolder.GetSerializationInfo(info, this);
+ throw new PlatformNotSupportedException();
}
#endregion
}
#region ISerializable Implementation
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
- if (info == null)
- throw new ArgumentNullException(nameof(info));
- Contract.EndContractBlock();
-
- if (m_reflectedTypeCache.IsGlobal)
- throw new NotSupportedException(SR.NotSupported_GlobalMethodSerialization);
-
- MemberInfoSerializationHolder.GetSerializationInfo(info, this);
+ throw new PlatformNotSupportedException();
}
internal string SerializationToString()
#region Public Virtuals
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
- if (info == null)
- {
- throw new ArgumentNullException(nameof(info));
- }
- Contract.EndContractBlock();
- UnitySerializationHolder.GetUnitySerializationInfo(info, UnitySerializationHolder.ModuleUnity, this.ScopeName, this.GetRuntimeAssembly());
+ throw new PlatformNotSupportedException();
}
public override Type GetType(String className, bool throwOnError, bool ignoreCase)
#region VTS magic to serialize/deserialized to/from pre-Whidbey endpoints.
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
- if (info == null)
- throw new ArgumentNullException(nameof(info));
- Contract.EndContractBlock();
-
- // We could be serializing for consumption by a pre-Whidbey
- // endpoint. Therefore we set up all the serialized fields to look
- // just like a v1.0/v1.1 instance.
-
- // Need to set the type to ParameterInfo so that pre-Whidbey and Whidbey code
- // can deserialize this. This is also why we cannot simply use [OnSerializing].
- info.SetType(typeof(ParameterInfo));
-
- // Use the properties intead of the fields in case the fields haven't been et
- // _importer, bExtraConstChecked, and m_cachedData don't need to be set
-
- // Now set the legacy fields that the current implementation doesn't
- // use any more. Note that _importer is a raw pointer that should
- // never have been serialized in V1. We set it to zero here; if the
- // deserializer uses it (by calling GetCustomAttributes() on this
- // instance) they'll AV, but at least it will be a well defined
- // exception and not a random AV.
-
- info.AddValue("AttrsImpl", Attributes);
- info.AddValue("ClassImpl", ParameterType);
- info.AddValue("DefaultValueImpl", DefaultValue);
- info.AddValue("MemberImpl", Member);
- info.AddValue("NameImpl", Name);
- info.AddValue("PositionImpl", Position);
- info.AddValue("_token", m_tkParamDef);
+ throw new PlatformNotSupportedException();
}
#endregion
#region ISerializable Implementation
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
- if (info == null)
- throw new ArgumentNullException(nameof(info));
- Contract.EndContractBlock();
-
- MemberInfoSerializationHolder.GetSerializationInfo(info, this);
+ throw new PlatformNotSupportedException();
}
internal string SerializationToString()
#region ISerializable
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
- if (info == null)
- throw new ArgumentNullException(nameof(info));
- Contract.EndContractBlock();
-
- UnitySerializationHolder.GetUnitySerializationInfo(info, this);
+ throw new PlatformNotSupportedException();
}
#endregion
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
- if (info == null)
- {
- throw new ArgumentNullException(nameof(info));
- }
- Contract.EndContractBlock();
base.GetObjectData(info, context);
- info.AddValue("WrappedException", m_wrappedException, typeof(Object));
- }
-
- internal RuntimeWrappedException(SerializationInfo info, StreamingContext context)
- : base(info, context)
- {
- m_wrappedException = info.GetValue("WrappedException", typeof(Object));
}
}
}
protected COMException(SerializationInfo info, StreamingContext context) : base(info, context)
{
+ throw new PlatformNotSupportedException();
}
public override String ToString()
protected InvalidComObjectException(SerializationInfo info, StreamingContext context) : base(info, context)
{
+ throw new PlatformNotSupportedException();
}
}
}
protected InvalidOleVariantTypeException(SerializationInfo info, StreamingContext context) : base(info, context)
{
+ throw new PlatformNotSupportedException();
}
}
}
protected MarshalDirectiveException(SerializationInfo info, StreamingContext context) : base(info, context)
{
+ throw new PlatformNotSupportedException();
}
}
}
protected SEHException(SerializationInfo info, StreamingContext context) : base(info, context)
{
+ throw new PlatformNotSupportedException();
}
// Exceptions can be resumable, meaning a filtered exception
protected SafeArrayRankMismatchException(SerializationInfo info, StreamingContext context) : base(info, context)
{
+ throw new PlatformNotSupportedException();
}
}
}
protected SafeArrayTypeMismatchException(SerializationInfo info, StreamingContext context) : base(info, context)
{
+ throw new PlatformNotSupportedException();
}
}
}
return new MetadataImport(_GetMetadataImport(type), type);
}
- private RuntimeTypeHandle(SerializationInfo info, StreamingContext context)
- {
- if (info == null)
- throw new ArgumentNullException(nameof(info));
- Contract.EndContractBlock();
-
- RuntimeType m = (RuntimeType)info.GetValue("TypeObj", typeof(RuntimeType));
-
- m_type = m;
-
- if (m_type == null)
- throw new SerializationException(SR.Serialization_InsufficientState);
- }
-
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
- if (info == null)
- throw new ArgumentNullException(nameof(info));
- Contract.EndContractBlock();
-
- if (m_type == null)
- throw new SerializationException(SR.Serialization_InvalidFieldState);
-
- info.AddValue("TypeObj", m_type, typeof(RuntimeType));
+ throw new PlatformNotSupportedException();
}
}
}
// ISerializable interface
- private RuntimeMethodHandle(SerializationInfo info, StreamingContext context)
- {
- if (info == null)
- throw new ArgumentNullException(nameof(info));
- Contract.EndContractBlock();
-
- MethodBase m = (MethodBase)info.GetValue("MethodObj", typeof(MethodBase));
-
- m_value = m.MethodHandle.m_value;
-
- if (m_value == null)
- throw new SerializationException(SR.Serialization_InsufficientState);
- }
-
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
- if (info == null)
- throw new ArgumentNullException(nameof(info));
- Contract.EndContractBlock();
-
- if (m_value == null)
- throw new SerializationException(SR.Serialization_InvalidFieldState);
-
- // This is either a RuntimeMethodInfo or a RuntimeConstructorInfo
- MethodBase methodInfo = RuntimeType.GetMethodBase(m_value);
-
- info.AddValue("MethodObj", methodInfo, typeof(MethodBase));
+ throw new PlatformNotSupportedException();
}
public IntPtr Value
internal static extern bool AcquiresContextFromThis(RuntimeFieldHandleInternal field);
// ISerializable interface
- private RuntimeFieldHandle(SerializationInfo info, StreamingContext context)
- {
- if (info == null)
- throw new ArgumentNullException(nameof(info));
- Contract.EndContractBlock();
-
- FieldInfo f = (RuntimeFieldInfo)info.GetValue("FieldObj", typeof(RuntimeFieldInfo));
-
- if (f == null)
- throw new SerializationException(SR.Serialization_InsufficientState);
-
- m_ptr = f.FieldHandle.m_ptr;
-
- if (m_ptr == null)
- throw new SerializationException(SR.Serialization_InsufficientState);
- }
-
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
- if (info == null)
- throw new ArgumentNullException(nameof(info));
- Contract.EndContractBlock();
-
- if (m_ptr == null)
- throw new SerializationException(SR.Serialization_InvalidFieldState);
-
- RuntimeFieldInfo fldInfo = (RuntimeFieldInfo)RuntimeType.GetFieldInfo(this.GetRuntimeFieldInfo());
-
- info.AddValue("FieldObj", fldInfo, typeof(RuntimeFieldInfo));
+ throw new PlatformNotSupportedException();
}
}
internal DecoderFallbackException(SerializationInfo info, StreamingContext context) : base(info, context)
{
+ throw new PlatformNotSupportedException();
}
public DecoderFallbackException(
#region Serialization
- // Constructor called by serialization. called during deserialization.
- internal DecoderNLS(SerializationInfo info, StreamingContext context)
- {
- throw new NotSupportedException(
- String.Format(
- System.Globalization.CultureInfo.CurrentCulture,
- SR.NotSupported_TypeCannotDeserialized, this.GetType()));
- }
-
- // ISerializable implementation. called during serialization.
+ // ISerializable implementation.
void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
{
- SerializeDecoder(info);
- info.AddValue("encoding", this.m_encoding);
- info.SetType(typeof(Encoding.DefaultDecoder));
+ throw new PlatformNotSupportedException();
}
#endregion Serialization
HResult = __HResults.COR_E_ARGUMENT;
}
- internal EncoderFallbackException(SerializationInfo info, StreamingContext context) : base(info, context)
- {
- }
-
internal EncoderFallbackException(
String message, char charUnknown, int index) : base(message)
{
#region Serialization
- // Constructor called by serialization. called during deserialization.
- internal EncoderNLS(SerializationInfo info, StreamingContext context)
- {
- throw new NotSupportedException(
- String.Format(
- System.Globalization.CultureInfo.CurrentCulture,
- SR.NotSupported_TypeCannotDeserialized, this.GetType()));
- }
-
- // ISerializable implementation. called during serialization.
+ // ISerializable implementation.
void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
{
- SerializeEncoder(info);
- info.AddValue("encoding", this.m_encoding);
- info.AddValue("charLeftOver", this.charLeftOver);
- info.SetType(typeof(Encoding.DefaultEncoder));
+ throw new PlatformNotSupportedException();
}
#endregion Serialization
m_hasInitializedEncoding = true;
}
- // Constructor called by serialization, have to handle deserializing from Everett
- internal DefaultEncoder(SerializationInfo info, StreamingContext context)
- {
- if (info == null) throw new ArgumentNullException(nameof(info));
- Contract.EndContractBlock();
-
- // All we have is our encoding
- m_encoding = (Encoding)info.GetValue("encoding", typeof(Encoding));
-
- try
- {
- this.m_fallback = (EncoderFallback)info.GetValue("m_fallback", typeof(EncoderFallback));
- this.charLeftOver = (Char)info.GetValue("charLeftOver", typeof(Char));
- }
- catch (SerializationException)
- {
- }
- }
-
// Just get it from GetEncoding
public Object GetRealObject(StreamingContext context)
{
// ISerializable implementation, get data for this object
void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
{
- // Any info?
- if (info == null) throw new ArgumentNullException(nameof(info));
- Contract.EndContractBlock();
-
- // All we have is our encoding
- info.AddValue("encoding", m_encoding);
+ throw new PlatformNotSupportedException();
}
// Returns the number of bytes the next call to GetBytes will
m_hasInitializedEncoding = true;
}
- // Constructor called by serialization, have to handle deserializing from Everett
- internal DefaultDecoder(SerializationInfo info, StreamingContext context)
- {
- // Any info?
- if (info == null) throw new ArgumentNullException(nameof(info));
- Contract.EndContractBlock();
-
- // All we have is our encoding
- m_encoding = (Encoding)info.GetValue("encoding", typeof(Encoding));
-
- try
- {
- this.m_fallback = (DecoderFallback)info.GetValue("m_fallback", typeof(DecoderFallback));
- }
- catch (SerializationException)
- {
- m_fallback = null;
- }
- }
-
// Just get it from GetEncoding
public Object GetRealObject(StreamingContext context)
{
return decoder;
}
- // ISerializable implementation, get data for this object
+ // ISerializable implementation
void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
{
- // Any info?
- if (info == null) throw new ArgumentNullException(nameof(info));
- Contract.EndContractBlock();
-
- // All we have is our encoding
- info.AddValue("encoding", m_encoding);
+ throw new PlatformNotSupportedException();
}
// Returns the number of characters the next call to GetChars will
{
}
- // Constructor called by serialization.
- // Note: We use the base GetObjectData however
- internal Latin1Encoding(SerializationInfo info, StreamingContext context) :
- base(Encoding.ISO_8859_1)
- {
- // Set up our base, also throws if info was empty
- DeserializeEncoding(info, context);
-
- // Nothing unique to Whidbey for Latin1
- }
-
- // ISerializable implementation, serialize it as a CodePageEncoding
+ // ISerializable implementation
void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
{
- // Make sure to get the base stuff too This throws if info is null
- SerializeEncoding(info, context);
- Debug.Assert(info != null, "[Latin1Encoding.GetObjectData] Expected null info to throw");
-
- // In Everett this is a CodePageEncoding, so it needs maxCharSize
- info.AddValue("CodePageEncoding+maxCharSize", 1);
-
- // And extras for Everett's wierdness
- info.AddValue("CodePageEncoding+m_codePage", this.CodePage);
- info.AddValue("CodePageEncoding+dataItem", null);
+ throw new PlatformNotSupportedException();
}
// GetByteCount
// base calls reset
}
- // Constructor called by serialization, have to handle deserializing from Everett
- internal Decoder(SerializationInfo info, StreamingContext context)
- {
- // Any info?
- if (info == null) throw new ArgumentNullException(nameof(info));
- Contract.EndContractBlock();
-
- // Get common info
- this.bits = (int)info.GetValue("bits", typeof(int));
- this.bitCount = (int)info.GetValue("bitCount", typeof(int));
- this.firstByte = (bool)info.GetValue("firstByte", typeof(bool));
- this.m_encoding = (Encoding)info.GetValue("encoding", typeof(Encoding));
- }
-
// ISerializable implementation, get data for this object
void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
{
- // Any info?
- if (info == null) throw new ArgumentNullException(nameof(info));
- Contract.EndContractBlock();
-
- // Save Whidbey data
- info.AddValue("encoding", this.m_encoding);
- info.AddValue("bits", this.bits);
- info.AddValue("bitCount", this.bitCount);
- info.AddValue("firstByte", this.firstByte);
+ throw new PlatformNotSupportedException();
}
public override void Reset()
// base calls reset
}
- // Constructor called by serialization, have to handle deserializing from Everett
- internal Encoder(SerializationInfo info, StreamingContext context)
- {
- // Any info?
- if (info == null) throw new ArgumentNullException(nameof(info));
- Contract.EndContractBlock();
-
- // Get common info
- this.bits = (int)info.GetValue("bits", typeof(int));
- this.bitCount = (int)info.GetValue("bitCount", typeof(int));
- this.m_encoding = (Encoding)info.GetValue("encoding", typeof(Encoding));
- }
-
- // ISerializable implementation, get data for this object
+ // ISerializable implementation
void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
{
- // Any info?
- if (info == null) throw new ArgumentNullException(nameof(info));
- Contract.EndContractBlock();
-
- // Save Whidbey data
- info.AddValue("encoding", this.m_encoding);
- info.AddValue("bits", this.bits);
- info.AddValue("bitCount", this.bitCount);
+ throw new PlatformNotSupportedException();
}
public override void Reset()
protected ThreadInterruptedException(SerializationInfo info, StreamingContext context) : base(info, context)
{
+ throw new PlatformNotSupportedException();
}
}
}
protected TypeLoadException(SerializationInfo info, StreamingContext context) : base(info, context)
{
- if (info == null)
- throw new ArgumentNullException(nameof(info));
- Contract.EndContractBlock();
-
- ClassName = info.GetString("TypeLoadClassName");
- AssemblyName = info.GetString("TypeLoadAssemblyName");
- MessageArg = info.GetString("TypeLoadMessageArg");
- ResourceId = info.GetInt32("TypeLoadResourceID");
+ throw new PlatformNotSupportedException();
}
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
[SuppressUnmanagedCodeSecurity]
private static extern void GetTypeLoadExceptionMessage(int resourceId, StringHandleOnStack retString);
- //We can rely on the serialization mechanism on Exception to handle most of our needs, but
- //we need to add a few fields of our own.
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
- if (info == null)
- throw new ArgumentNullException(nameof(info));
- Contract.EndContractBlock();
-
base.GetObjectData(info, context);
- info.AddValue("TypeLoadClassName", ClassName, typeof(String));
- info.AddValue("TypeLoadAssemblyName", AssemblyName, typeof(String));
- info.AddValue("TypeLoadMessageArg", MessageArg, typeof(String));
- info.AddValue("TypeLoadResourceID", ResourceId);
}
// If ClassName != null, GetMessage will construct on the fly using it
{
// Console.WriteLine("Incorrect exception and/or message. Expected RuntimeWrappedException: An object that does not derive "+
// "from System.Exception has been wrapped in a RuntimeWrappedException.\n But actually got: " + ex.InnerException);
- retVal = -1;
+ return -1;
}
StreamingContext ctx;
-
-// TODO: Expose once we have access to FormatterConverter
-// var info = new SerializationInfo(typeof(RuntimeWrappedException), new FormatterConverter());
-// ex.GetObjectData(info,ctx);
-//
- try
- {
- ex.GetObjectData(null,ctx);
- }
- catch (ArgumentNullException ex1)
- {
- retVal = 100;
- }
- catch (Exception ex1)
- {
- retVal = -1;
- }
+
+ retVal = 100;
}