ISerializable cleanup (#11873)
authorMorgan Brown <morganbr@users.noreply.github.com>
Sat, 27 May 2017 00:45:37 +0000 (17:45 -0700)
committerGitHub <noreply@github.com>
Sat, 27 May 2017 00:45:37 +0000 (17:45 -0700)
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

130 files changed:
src/mscorlib/System.Private.CoreLib.csproj
src/mscorlib/shared/System.Private.CoreLib.Shared.projitems
src/mscorlib/shared/System/ApplicationException.cs
src/mscorlib/shared/System/ArgumentException.cs
src/mscorlib/shared/System/ArgumentNullException.cs
src/mscorlib/shared/System/ArgumentOutOfRangeException.cs
src/mscorlib/shared/System/ArithmeticException.cs
src/mscorlib/shared/System/ArrayTypeMismatchException.cs
src/mscorlib/shared/System/BadImageFormatException.cs
src/mscorlib/shared/System/Collections/Generic/KeyNotFoundException.cs
src/mscorlib/shared/System/DBNull.cs
src/mscorlib/shared/System/DataMisalignedException.cs
src/mscorlib/shared/System/DivideByZeroException.cs
src/mscorlib/shared/System/DllNotFoundException.cs
src/mscorlib/shared/System/DuplicateWaitObjectException.cs
src/mscorlib/shared/System/EntryPointNotFoundException.cs
src/mscorlib/shared/System/ExecutionEngineException.cs
src/mscorlib/shared/System/FieldAccessException.cs
src/mscorlib/shared/System/FormatException.cs
src/mscorlib/shared/System/Globalization/CultureNotFoundException.cs
src/mscorlib/shared/System/IO/DirectoryNotFoundException.cs
src/mscorlib/shared/System/IO/EndOfStreamException.cs
src/mscorlib/shared/System/IO/FileLoadException.cs
src/mscorlib/shared/System/IO/FileNotFoundException.cs
src/mscorlib/shared/System/IO/PathTooLongException.cs
src/mscorlib/shared/System/IndexOutOfRangeException.cs
src/mscorlib/shared/System/InsufficientExecutionStackException.cs
src/mscorlib/shared/System/InvalidCastException.cs
src/mscorlib/shared/System/InvalidOperationException.cs
src/mscorlib/shared/System/InvalidProgramException.cs
src/mscorlib/shared/System/InvalidTimeZoneException.cs
src/mscorlib/shared/System/MemberAccessException.cs
src/mscorlib/shared/System/MethodAccessException.cs
src/mscorlib/shared/System/MissingMethodException.cs
src/mscorlib/shared/System/MulticastNotSupportedException.cs
src/mscorlib/shared/System/NotFiniteNumberException.cs
src/mscorlib/shared/System/NotImplementedException.cs
src/mscorlib/shared/System/NotSupportedException.cs
src/mscorlib/shared/System/NullReferenceException.cs
src/mscorlib/shared/System/ObjectDisposedException.cs
src/mscorlib/shared/System/OperationCanceledException.cs
src/mscorlib/shared/System/OverflowException.cs
src/mscorlib/shared/System/PlatformNotSupportedException.cs
src/mscorlib/shared/System/RankException.cs
src/mscorlib/shared/System/Reflection/AmbiguousMatchException.cs
src/mscorlib/shared/System/Reflection/Assembly.cs
src/mscorlib/shared/System/Reflection/CustomAttributeFormatException.cs
src/mscorlib/shared/System/Reflection/InvalidFilterCriteriaException.cs
src/mscorlib/shared/System/Reflection/MemberInfoSerializationHolder.cs [deleted file]
src/mscorlib/shared/System/Reflection/Missing.cs
src/mscorlib/shared/System/Reflection/Module.cs
src/mscorlib/shared/System/Reflection/Pointer.cs
src/mscorlib/shared/System/Reflection/ReflectionTypeLoadException.cs
src/mscorlib/shared/System/Reflection/StrongNameKeyPair.cs
src/mscorlib/shared/System/Reflection/TargetException.cs
src/mscorlib/shared/System/Reflection/TargetInvocationException.cs
src/mscorlib/shared/System/Reflection/TargetParameterCountException.cs
src/mscorlib/shared/System/Resources/MissingManifestResourceException.cs
src/mscorlib/shared/System/Resources/MissingSatelliteAssemblyException.cs
src/mscorlib/shared/System/Runtime/InteropServices/ExternalException.cs
src/mscorlib/shared/System/Runtime/Serialization/SerializationException.cs
src/mscorlib/shared/System/Security/CryptographicException.cs
src/mscorlib/shared/System/Security/SecurityException.cs
src/mscorlib/shared/System/Security/VerificationException.cs
src/mscorlib/shared/System/StackOverflowException.cs
src/mscorlib/shared/System/SystemException.cs
src/mscorlib/shared/System/Text/UTF8Encoding.cs
src/mscorlib/shared/System/Text/UnicodeEncoding.cs
src/mscorlib/shared/System/Threading/AbandonedMutexException.cs
src/mscorlib/shared/System/Threading/ExecutionContext.cs
src/mscorlib/shared/System/Threading/LockRecursionException.cs
src/mscorlib/shared/System/Threading/SemaphoreFullException.cs
src/mscorlib/shared/System/Threading/SynchronizationLockException.cs
src/mscorlib/shared/System/Threading/Tasks/TaskCanceledException.cs
src/mscorlib/shared/System/Threading/Tasks/TaskSchedulerException.cs
src/mscorlib/shared/System/Threading/ThreadAbortException.cs
src/mscorlib/shared/System/Threading/ThreadStartException.cs
src/mscorlib/shared/System/Threading/ThreadStateException.cs
src/mscorlib/shared/System/Threading/WaitHandleCannotBeOpenedException.cs
src/mscorlib/shared/System/TimeZoneNotFoundException.cs
src/mscorlib/shared/System/TimeoutException.cs
src/mscorlib/shared/System/TypeAccessException.cs
src/mscorlib/shared/System/TypeInitializationException.cs
src/mscorlib/shared/System/TypeUnloadedException.cs
src/mscorlib/shared/System/UnauthorizedAccessException.cs
src/mscorlib/shared/System/UnitySerializationHolder.cs [deleted file]
src/mscorlib/src/System/AccessViolationException.cs
src/mscorlib/src/System/AppDomainUnloadedException.cs
src/mscorlib/src/System/Collections/Comparer.cs
src/mscorlib/src/System/Collections/Hashtable.cs
src/mscorlib/src/System/Delegate.cs
src/mscorlib/src/System/Diagnostics/Contracts/ContractsBCL.cs
src/mscorlib/src/System/Empty.cs
src/mscorlib/src/System/Exception.cs
src/mscorlib/src/System/IO/DriveNotFoundException.cs
src/mscorlib/src/System/IO/IOException.cs
src/mscorlib/src/System/InsufficientMemoryException.cs
src/mscorlib/src/System/MissingFieldException.cs
src/mscorlib/src/System/MissingMemberException.cs
src/mscorlib/src/System/OutOfMemoryException.cs
src/mscorlib/src/System/Reflection/AssemblyName.cs
src/mscorlib/src/System/Reflection/MemberSerializationStringGenerator.cs [deleted file]
src/mscorlib/src/System/Reflection/RuntimeAssembly.cs
src/mscorlib/src/System/Reflection/RuntimeConstructorInfo.cs
src/mscorlib/src/System/Reflection/RuntimeEventInfo.cs
src/mscorlib/src/System/Reflection/RuntimeFieldInfo.cs
src/mscorlib/src/System/Reflection/RuntimeMethodInfo.cs
src/mscorlib/src/System/Reflection/RuntimeModule.cs
src/mscorlib/src/System/Reflection/RuntimeParameterInfo.cs
src/mscorlib/src/System/Reflection/RuntimePropertyInfo.cs
src/mscorlib/src/System/RtType.cs
src/mscorlib/src/System/Runtime/CompilerServices/RuntimeWrappedException.cs
src/mscorlib/src/System/Runtime/InteropServices/COMException.cs
src/mscorlib/src/System/Runtime/InteropServices/InvalidComObjectException.cs
src/mscorlib/src/System/Runtime/InteropServices/InvalidOleVariantTypeException.cs
src/mscorlib/src/System/Runtime/InteropServices/MarshalDirectiveException.cs
src/mscorlib/src/System/Runtime/InteropServices/SEHException.cs
src/mscorlib/src/System/Runtime/InteropServices/SafeArrayRankMismatchException.cs
src/mscorlib/src/System/Runtime/InteropServices/SafeArrayTypeMismatchException.cs
src/mscorlib/src/System/RuntimeHandles.cs
src/mscorlib/src/System/Text/DecoderExceptionFallback.cs
src/mscorlib/src/System/Text/DecoderNLS.cs
src/mscorlib/src/System/Text/EncoderExceptionFallback.cs
src/mscorlib/src/System/Text/EncoderNLS.cs
src/mscorlib/src/System/Text/Encoding.cs
src/mscorlib/src/System/Text/Latin1Encoding.cs
src/mscorlib/src/System/Text/UTF7Encoding.cs
src/mscorlib/src/System/Threading/ThreadInterruptedException.cs
src/mscorlib/src/System/TypeLoadException.cs
tests/src/baseservices/compilerservices/RuntimeWrappedException/RuntimeWrappedException.cs

index 662a771..4d3be41 100644 (file)
     <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" />
index 26cb558..7454068 100644 (file)
     <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"/>
index 89c665c..cb98902 100644 (file)
@@ -50,6 +50,9 @@ namespace System
             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();
+        }
     }
 }
index ce045f1..de2d775 100644 (file)
@@ -64,13 +64,12 @@ namespace System
         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
index 343cadc..74b39fe 100644 (file)
@@ -47,6 +47,9 @@ namespace System
             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();
+        }
     }
 }
index 08592aa..4721a50 100644 (file)
@@ -61,13 +61,12 @@ namespace System
         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
index cd77965..2c8abe5 100644 (file)
@@ -45,6 +45,9 @@ namespace System
             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();
+        }
     }
 }
index b6ce5fa..d06a450 100644 (file)
@@ -45,6 +45,9 @@ namespace System
             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();
+        }
     }
 }
index 2ceaa8b..6bed5e9 100644 (file)
@@ -56,16 +56,12 @@ namespace System
         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
index fa4de83..cdd6faf 100644 (file)
@@ -27,6 +27,9 @@ namespace System.Collections.Generic
             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();
+        }
     }
 }
index 507cccb..4f4d64b 100644 (file)
@@ -11,17 +11,12 @@ namespace System
         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()
index 9c02fc2..ff5b29f 100644 (file)
@@ -32,7 +32,5 @@ namespace System
         {
             HResult = __HResults.COR_E_DATAMISALIGNED;
         }
-
-        internal DataMisalignedException(SerializationInfo info, StreamingContext context) : base(info, context) { }
     }
 }
index f5911f2..0fad2f8 100644 (file)
@@ -35,6 +35,9 @@ namespace System
             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();
+        }
     }
 }
index fc63bc5..8c69e45 100644 (file)
@@ -38,6 +38,7 @@ namespace System
 
         protected DllNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context)
         {
+            throw new PlatformNotSupportedException();
         }
     }
 }
index d9075df..7eadead 100644 (file)
@@ -57,8 +57,10 @@ namespace System
         {
             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();
+        }
     }
 }
index 0859eb4..0b881ce 100644 (file)
@@ -36,6 +36,9 @@ namespace System
             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();
+        }
     }
 }
index ae3a8db..b89f6d9 100644 (file)
@@ -40,7 +40,5 @@ namespace System
         {
             HResult = __HResults.COR_E_EXECUTIONENGINE;
         }
-
-        internal ExecutionEngineException(SerializationInfo info, StreamingContext context) : base(info, context) { }
     }
 }
index 109bd77..b56d749 100644 (file)
@@ -33,6 +33,9 @@ namespace System
             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();
+        }
     }
 }
index 68e1f4f..9baaac2 100644 (file)
@@ -35,6 +35,9 @@ namespace System
             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();
+        }
     }
 }
index 2b333ee..dde1a8b 100644 (file)
@@ -58,15 +58,12 @@ namespace System.Globalization
         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
index 04e3791..de09760 100644 (file)
@@ -35,6 +35,7 @@ namespace System.IO
         protected DirectoryNotFoundException(SerializationInfo info, StreamingContext context)
             : base(info, context)
         {
+            throw new PlatformNotSupportedException();
         }
     }
 }
index df9ea17..68e1b2c 100644 (file)
@@ -29,6 +29,7 @@ namespace System.IO
         protected EndOfStreamException(SerializationInfo info, StreamingContext context)
             : base(info, context)
         {
+            throw new PlatformNotSupportedException();
         }
     }
 }
index dc8cf0f..6fdf2d5 100644 (file)
@@ -82,20 +82,12 @@ namespace System.IO
         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));
         }
     }
 }
index 2a94665..374c976 100644 (file)
@@ -93,20 +93,12 @@ namespace System.IO
         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));
         }
     }
 }
index 46e9bd6..64c8e6c 100644 (file)
@@ -31,6 +31,7 @@ namespace System.IO
         protected PathTooLongException(SerializationInfo info, StreamingContext context)
             : base(info, context)
         {
+            throw new PlatformNotSupportedException();
         }
     }
 }
index 0225a60..d5b24b3 100644 (file)
@@ -34,7 +34,5 @@ namespace System
         {
             HResult = __HResults.COR_E_INDEXOUTOFRANGE;
         }
-
-        internal IndexOutOfRangeException(SerializationInfo info, StreamingContext context) : base(info, context) { }
     }
 }
index be647e3..41df3ae 100644 (file)
@@ -25,7 +25,5 @@ namespace System
         {
             HResult = __HResults.COR_E_INSUFFICIENTEXECUTIONSTACK;
         }
-
-        internal InsufficientExecutionStackException(SerializationInfo info, StreamingContext context) : base(info, context) { }
     }
 }
index 88ee399..cf359ac 100644 (file)
@@ -38,6 +38,9 @@ namespace System
             HResult = errorCode;
         }
 
-        protected InvalidCastException(SerializationInfo info, StreamingContext context) : base(info, context) { }
+        protected InvalidCastException(SerializationInfo info, StreamingContext context) : base(info, context)
+        {
+            throw new PlatformNotSupportedException();
+        }
     }
 }
index ab01183..ad743e0 100644 (file)
@@ -36,6 +36,9 @@ namespace System
             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();
+        }
     }
 }
index a5f798c..47e7325 100644 (file)
@@ -34,7 +34,5 @@ namespace System
         {
             HResult = __HResults.COR_E_INVALIDPROGRAM;
         }
-
-        internal InvalidProgramException(SerializationInfo info, StreamingContext context) : base(info, context) { }
     }
 }
index 09eed88..8b300f4 100644 (file)
@@ -22,6 +22,9 @@ namespace System
         {
         }
 
-        protected InvalidTimeZoneException(SerializationInfo info, StreamingContext context) : base(info, context) { }
+        protected InvalidTimeZoneException(SerializationInfo info, StreamingContext context) : base(info, context)
+        {
+            throw new PlatformNotSupportedException();
+        }
     }
 }
index 074699d..abca952 100644 (file)
@@ -42,6 +42,9 @@ namespace System
             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();
+        }
     }
 }
index 515458c..2c9c998 100644 (file)
@@ -33,6 +33,9 @@ namespace System
             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();
+        }
     }
 }
index 2bb92e1..967f434 100644 (file)
@@ -44,6 +44,7 @@ namespace System
         protected MissingMethodException(SerializationInfo info, StreamingContext context)
             : base(info, context)
         {
+            throw new PlatformNotSupportedException();
         }
 
         public override string Message
index 5b1f41e..493671e 100644 (file)
@@ -30,7 +30,5 @@ namespace System
         {
             HResult = __HResults.COR_E_MULTICASTNOTSUPPORTED;
         }
-
-        internal MulticastNotSupportedException(SerializationInfo info, StreamingContext context) : base(info, context) { }
     }
 }
index f14f3a3..99882b9 100644 (file)
@@ -53,13 +53,12 @@ namespace System
 
         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
index 7d562ed..ae62527 100644 (file)
@@ -34,6 +34,9 @@ namespace System
             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();
+        }
     }
 }
index 6d68b07..8532e5a 100644 (file)
@@ -35,6 +35,9 @@ namespace System
             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();
+        }
     }
 }
index fb98868..f689345 100644 (file)
@@ -35,6 +35,9 @@ namespace System
             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();
+        }
     }
 }
index abeefca..6e8e6b2 100644 (file)
@@ -41,13 +41,12 @@ namespace System
         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>
index cd1f328..2c76548 100644 (file)
@@ -67,6 +67,7 @@ namespace System
 
         protected OperationCanceledException(SerializationInfo info, StreamingContext context) : base(info, context)
         {
+            throw new PlatformNotSupportedException();
         }
     }
 }
index d32df8b..4052e41 100644 (file)
@@ -35,6 +35,9 @@ namespace System
             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();
+        }
     }
 }
index fa708c9..f679ac9 100644 (file)
@@ -35,6 +35,9 @@ namespace System
             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();
+        }
     }
 }
index 8762aa2..15759ea 100644 (file)
@@ -36,6 +36,9 @@ namespace System
             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();
+        }
     }
 }
index 4e14e1f..a0075bb 100644 (file)
@@ -25,10 +25,5 @@ namespace System.Reflection
         {
             HResult = __HResults.COR_E_AMBIGUOUSMATCH;
         }
-
-        internal AmbiguousMatchException(SerializationInfo info, StreamingContext context)
-            : base(info, context)
-        {
-        }
     }
 }
index d35ffc7..b965c9f 100644 (file)
@@ -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()
         {
index 29bf7f0..13766ae 100644 (file)
@@ -27,6 +27,7 @@ namespace System.Reflection
         protected CustomAttributeFormatException(SerializationInfo info, StreamingContext context)
             : base(info, context)
         {
+            throw new PlatformNotSupportedException();
         }
     }
 }
index c7644b8..07880a7 100644 (file)
@@ -27,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 (file)
index ee14ab2..0000000
+++ /dev/null
@@ -1,314 +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
-{
-#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
-    }
-}
-
index 1782910..46ab32f 100644 (file)
@@ -14,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();
         }
     }
 }
index 56f83c4..7822e9f 100644 (file)
@@ -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();
index d93e5b0..55376c6 100644 (file)
@@ -21,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)
@@ -50,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;
index 1a59c20..ca0c6ab 100644 (file)
@@ -24,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; }
index 03fbb91..c11ee42 100644 (file)
@@ -41,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)
@@ -62,10 +59,7 @@ 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) { }
index 16b4a14..6e43f56 100644 (file)
@@ -27,6 +27,7 @@ namespace System.Reflection
         protected TargetException(SerializationInfo info, StreamingContext context)
             : base(info, context)
         {
+            throw new PlatformNotSupportedException();
         }
     }
 }
index 8c98e5c..8d0bfef 100644 (file)
@@ -19,10 +19,5 @@ namespace System.Reflection
         {
             HResult = __HResults.COR_E_TARGETINVOCATION;
         }
-
-        internal TargetInvocationException(SerializationInfo info, StreamingContext context)
-            : base(info, context)
-        {
-        }
     }
 }
index befe6b2..e200cdb 100644 (file)
@@ -25,10 +25,5 @@ namespace System.Reflection
         {
             HResult = __HResults.COR_E_TARGETPARAMCOUNT;
         }
-
-        internal TargetParameterCountException(SerializationInfo info, StreamingContext context)
-            : base(info, context)
-        {
-        }
     }
 }
index ce2c4c7..ec81439 100644 (file)
@@ -30,6 +30,7 @@ namespace System.Resources
         protected MissingManifestResourceException(SerializationInfo info, StreamingContext context)
             : base(info, context)
         {
+            throw new PlatformNotSupportedException();
         }
     }
 }
index 8a9289b..d2ddc99 100644 (file)
@@ -52,6 +52,7 @@ namespace System.Resources
         protected MissingSatelliteAssemblyException(SerializationInfo info, StreamingContext context)
             : base(info, context)
         {
+            throw new PlatformNotSupportedException();
         }
 
         public String CultureName
index f349a5b..81b9a46 100644 (file)
@@ -50,6 +50,7 @@ namespace System.Runtime.InteropServices
         protected ExternalException(SerializationInfo info, StreamingContext context)
             : base(info, context)
         {
+            throw new PlatformNotSupportedException();
         }
 
         public virtual int ErrorCode
index b11daa5..bfe3313 100644 (file)
@@ -33,6 +33,7 @@ namespace System.Runtime.Serialization
         protected SerializationException(SerializationInfo info, StreamingContext context)
             : base(info, context)
         {
+            throw new PlatformNotSupportedException();
         }
     }
 }
index 62613c9..7c4fa17 100644 (file)
@@ -38,6 +38,7 @@ namespace System.Security.Cryptography
         protected CryptographicException(SerializationInfo info, StreamingContext context)
             : base(info, context)
         {
+            throw new PlatformNotSupportedException();
         }
     }
 }
index 6baba64..538f475 100644 (file)
@@ -45,6 +45,7 @@ namespace System.Security
         protected SecurityException(SerializationInfo info, StreamingContext context)
             : base(info, context)
         {
+            throw new PlatformNotSupportedException();
         }
 
         public override string ToString() => base.ToString();
index 5a93b35..ea5a759 100644 (file)
@@ -29,6 +29,7 @@ namespace System.Security
         protected VerificationException(SerializationInfo info, StreamingContext context)
             : base(info, context)
         {
+            throw new PlatformNotSupportedException();
         }
     }
 }
index 2975253..fb0e882 100644 (file)
@@ -34,7 +34,5 @@ namespace System
         {
             HResult = __HResults.COR_E_STACKOVERFLOW;
         }
-
-        internal StackOverflowException(SerializationInfo info, StreamingContext context) : base(info, context) { }
     }
 }
index 9961df3..d5bcde7 100644 (file)
@@ -26,6 +26,9 @@ namespace System
             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();
+        }
     }
 }
index e91b889..ee5c92c 100644 (file)
@@ -2530,46 +2530,10 @@ namespace System.Text
                 // 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()
@@ -2604,44 +2568,13 @@ namespace System.Text
             // 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()
index 1b60b5b..846946c 100644 (file)
@@ -1991,47 +1991,16 @@ namespace System.Text
             {
                 // 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()
index 7a0169f..15bc5a7 100644 (file)
@@ -61,6 +61,7 @@ namespace System.Threading
         protected AbandonedMutexException(SerializationInfo info, StreamingContext context)
             : base(info, context)
         {
+            throw new PlatformNotSupportedException();
         }
 
         private void SetupException(int location, WaitHandle handle)
index b2cd71b..a573af3 100644 (file)
@@ -70,15 +70,7 @@ namespace System.Threading
 
         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()
index a9f0c56..86e1903 100644 (file)
@@ -23,6 +23,9 @@ namespace System.Threading
         {
         }
 
-        protected LockRecursionException(SerializationInfo info, StreamingContext context) : base(info, context) { }
+        protected LockRecursionException(SerializationInfo info, StreamingContext context) : base(info, context)
+        {
+            throw new PlatformNotSupportedException();
+        }
     }
 }
index b583138..777463b 100644 (file)
@@ -23,6 +23,7 @@ namespace System.Threading
 
         protected SemaphoreFullException(SerializationInfo info, StreamingContext context) : base(info, context)
         {
+            throw new PlatformNotSupportedException();
         }
     }
 }
index e21d0c3..c64fc9c 100644 (file)
@@ -38,6 +38,7 @@ namespace System.Threading
 
         protected SynchronizationLockException(SerializationInfo info, StreamingContext context) : base(info, context)
         {
+            throw new PlatformNotSupportedException();
         }
     }
 }
index ee03204..6657bcd 100644 (file)
@@ -70,6 +70,7 @@ namespace System.Threading.Tasks
         /// <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>
index 70e13f2..2888415 100644 (file)
@@ -71,6 +71,7 @@ namespace System.Threading.Tasks
         protected TaskSchedulerException(SerializationInfo info, StreamingContext context)
             : base(info, context)
         {
+            throw new PlatformNotSupportedException();
         }
     }
 }
index f4e2ea6..5773f27 100644 (file)
@@ -25,11 +25,6 @@ namespace System.Threading
             HResult = __HResults.COR_E_THREADABORTED;
         }
 
-        internal ThreadAbortException(SerializationInfo info, StreamingContext context)
-            : base(info, context)
-        {
-        }
-
         public object ExceptionState => null;
     }
 }
index 9812de3..7a87943 100644 (file)
@@ -19,10 +19,5 @@ namespace System.Threading
         {
             HResult = __HResults.COR_E_THREADSTART;
         }
-
-        internal ThreadStartException(SerializationInfo info, StreamingContext context)
-            : base(info, context)
-        {
-        }
     }
 }
index a186acd..9477cb1 100644 (file)
@@ -39,6 +39,7 @@ namespace System.Threading
         protected ThreadStateException(SerializationInfo info, StreamingContext context)
             : base(info, context)
         {
+            throw new PlatformNotSupportedException();
         }
     }
 }
index 02dad47..770e70d 100644 (file)
@@ -25,6 +25,7 @@ namespace System.Threading
 
         protected WaitHandleCannotBeOpenedException(SerializationInfo info, StreamingContext context) : base(info, context)
         {
+            throw new PlatformNotSupportedException();
         }
     }
 }
index acb1b6f..5b7ce10 100644 (file)
@@ -22,6 +22,9 @@ namespace System
         {
         }
 
-        protected TimeZoneNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) { }
+        protected TimeZoneNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context)
+        {
+            throw new PlatformNotSupportedException();
+        }
     }
 }
index 92780a8..4ba95bc 100644 (file)
@@ -35,6 +35,9 @@ namespace System
             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();
+        }
     }
 }
index 3561abe..302dcb1 100644 (file)
@@ -28,6 +28,9 @@ namespace System
             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();
+        }
     }
 }
index 53dd80e..8d0b8a9 100644 (file)
@@ -51,16 +51,9 @@ namespace System
             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
index 296a820..c7ed71c 100644 (file)
@@ -25,13 +25,11 @@ namespace System
         {
             HResult = __HResults.COR_E_TYPEUNLOADED;
         }
-
-        //
-        // This constructor is required for serialization;
-        //
+        
         protected TypeUnloadedException(SerializationInfo info, StreamingContext context)
             : base(info, context)
         {
+            throw new PlatformNotSupportedException();
         }
     }
 }
index ceb0186..667d576 100644 (file)
@@ -39,6 +39,9 @@ namespace System
             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();
+        }
     }
 }
diff --git a/src/mscorlib/shared/System/UnitySerializationHolder.cs b/src/mscorlib/shared/System/UnitySerializationHolder.cs
deleted file mode 100644 (file)
index 57eed72..0000000
+++ /dev/null
@@ -1,328 +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.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
-    }
-}
index 2ca2497..23d086f 100644 (file)
@@ -36,7 +36,10 @@ namespace System
             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.
index f2836bf..a5e74e2 100644 (file)
@@ -29,6 +29,7 @@ namespace System
         //
         protected AppDomainUnloadedException(SerializationInfo info, StreamingContext context) : base(info, context)
         {
+            throw new PlatformNotSupportedException();
         }
     }
 }
index 754b44d..76e19e7 100644 (file)
@@ -43,21 +43,6 @@ namespace System.Collections
             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 
@@ -91,16 +76,7 @@ namespace System.Collections
 
         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();
         }
     }
 }
index 033afe1..fb5034f 100644 (file)
@@ -918,58 +918,7 @@ namespace System.Collections
 
         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();
         }
 
         //
@@ -1185,17 +1134,7 @@ namespace System.Collections
             ==============================================================================*/
             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
index 8c4516a..8a97636 100644 (file)
@@ -544,8 +544,9 @@ namespace System
 
         public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
         {
-            throw new NotSupportedException();
+            throw new PlatformNotSupportedException();
         }
+
         //
         // internal implementation details (FCALLS and utilities)
         //
index c5b5ab4..d29b860 100644 (file)
@@ -217,21 +217,9 @@ namespace System.Diagnostics.Contracts
             _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);
         }
     }
 }
index 10fc697..2b585b3 100644 (file)
@@ -28,12 +28,7 @@ namespace System
 
         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();
         }
     }
 }
index 263b6b3..8d01b4c 100644 (file)
@@ -83,8 +83,7 @@ namespace System
             _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");
 
@@ -293,15 +292,8 @@ namespace System
             {
                 return null;
             }
-
-            if (_exceptionMethodString != null)
-            {
-                _exceptionMethod = GetExceptionMethodFromString();
-            }
-            else
-            {
-                _exceptionMethod = GetExceptionMethodFromStackTrace();
-            }
+            
+            _exceptionMethod = GetExceptionMethodFromStackTrace();
             return _exceptionMethod;
         }
 
@@ -434,90 +426,6 @@ namespace System
             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); }
@@ -559,7 +467,7 @@ namespace System
             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));
 
@@ -748,7 +656,7 @@ namespace System
 
         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;
index 2e37a13..7e9b0c9 100644 (file)
@@ -33,6 +33,7 @@ namespace System.IO
 
         protected DriveNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context)
         {
+            throw new PlatformNotSupportedException();
         }
     }
 }
index 1a49ec7..65504de 100644 (file)
@@ -67,6 +67,7 @@ namespace System.IO
 
         protected IOException(SerializationInfo info, StreamingContext context) : base(info, context)
         {
+            throw new PlatformNotSupportedException();
         }
     }
 }
index 6990b57..8f7aa96 100644 (file)
@@ -41,9 +41,5 @@ namespace System
         {
             HResult = __HResults.COR_E_INSUFFICIENTMEMORY;
         }
-
-        private InsufficientMemoryException(SerializationInfo info, StreamingContext context) : base(info, context)
-        {
-        }
     }
 }
index 0a91dd2..668d5f2 100644 (file)
@@ -39,6 +39,7 @@ namespace System
 
         protected MissingFieldException(SerializationInfo info, StreamingContext context) : base(info, context)
         {
+            throw new PlatformNotSupportedException();
         }
 
         public override String Message
index 92454c3..1fb0c55 100644 (file)
@@ -43,9 +43,7 @@ namespace System
 
         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
@@ -76,15 +74,7 @@ namespace System
 
         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[]));
         }
 
 
index 7ffb029..3bec542 100644 (file)
@@ -39,6 +39,7 @@ namespace System
 
         protected OutOfMemoryException(SerializationInfo info, StreamingContext context) : base(info, context)
         {
+            throw new PlatformNotSupportedException();
         }
     }
 }
index ba6208f..8ba4152 100644 (file)
@@ -298,25 +298,7 @@ namespace System.Reflection
 
         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)
@@ -355,13 +337,6 @@ namespace System.Reflection
             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)
diff --git a/src/mscorlib/src/System/Reflection/MemberSerializationStringGenerator.cs b/src/mscorlib/src/System/Reflection/MemberSerializationStringGenerator.cs
deleted file mode 100644 (file)
index d25c746..0000000
+++ /dev/null
@@ -1,39 +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.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();
-    }
-}
index 2072ec4..5d842b3 100644 (file)
@@ -259,15 +259,7 @@ namespace System.Reflection
         // 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
index 5a43ee4..72b2591 100644 (file)
@@ -466,10 +466,7 @@ namespace System.Reflection
         #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()
index eb79ea7..414b1ef 100644 (file)
@@ -159,11 +159,7 @@ namespace System.Reflection
         #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
 
index 950eac7..3c6e949 100644 (file)
@@ -126,11 +126,7 @@ namespace System.Reflection
         #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
     }
index 40da97c..6d90bf7 100644 (file)
@@ -773,14 +773,7 @@ namespace System.Reflection
         #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()
index b5020a7..f9b7337 100644 (file)
@@ -447,12 +447,7 @@ namespace System.Reflection
         #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)
index 846ec1d..d21af03 100644 (file)
@@ -163,35 +163,7 @@ namespace System.Reflection
         #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
 
index fc388ed..8010789 100644 (file)
@@ -452,11 +452,7 @@ namespace System.Reflection
         #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()
index 3634a69..8fdc85a 100644 (file)
@@ -4447,11 +4447,7 @@ namespace System
         #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
 
index 2554820..df52f30 100644 (file)
@@ -35,19 +35,7 @@ namespace System.Runtime.CompilerServices
 
         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));
         }
     }
 }
index a195616..8ee10ed 100644 (file)
@@ -50,6 +50,7 @@ namespace System.Runtime.InteropServices
 
         protected COMException(SerializationInfo info, StreamingContext context) : base(info, context)
         {
+            throw new PlatformNotSupportedException();
         }
 
         public override String ToString()
index 30c2c66..bf89df9 100644 (file)
@@ -39,6 +39,7 @@ namespace System.Runtime.InteropServices
 
         protected InvalidComObjectException(SerializationInfo info, StreamingContext context) : base(info, context)
         {
+            throw new PlatformNotSupportedException();
         }
     }
 }
index 0cbf01d..4128539 100644 (file)
@@ -38,6 +38,7 @@ namespace System.Runtime.InteropServices
 
         protected InvalidOleVariantTypeException(SerializationInfo info, StreamingContext context) : base(info, context)
         {
+            throw new PlatformNotSupportedException();
         }
     }
 }
index 16e260e..75b291a 100644 (file)
@@ -39,6 +39,7 @@ namespace System.Runtime.InteropServices
 
         protected MarshalDirectiveException(SerializationInfo info, StreamingContext context) : base(info, context)
         {
+            throw new PlatformNotSupportedException();
         }
     }
 }
index cbc4fc1..d61e797 100644 (file)
@@ -41,6 +41,7 @@ namespace System.Runtime.InteropServices
 
         protected SEHException(SerializationInfo info, StreamingContext context) : base(info, context)
         {
+            throw new PlatformNotSupportedException();
         }
 
         // Exceptions can be resumable, meaning a filtered exception 
index 4f33595..9df858f 100644 (file)
@@ -38,6 +38,7 @@ namespace System.Runtime.InteropServices
 
         protected SafeArrayRankMismatchException(SerializationInfo info, StreamingContext context) : base(info, context)
         {
+            throw new PlatformNotSupportedException();
         }
     }
 }
index ccd31b5..4b03691 100644 (file)
@@ -39,6 +39,7 @@ namespace System.Runtime.InteropServices
 
         protected SafeArrayTypeMismatchException(SerializationInfo info, StreamingContext context) : base(info, context)
         {
+            throw new PlatformNotSupportedException();
         }
     }
 }
index 129e8db..fca37dd 100644 (file)
@@ -639,30 +639,9 @@ namespace System
             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();
         }
     }
 
@@ -781,33 +760,9 @@ namespace System
         }
 
         // 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
@@ -1244,35 +1199,9 @@ namespace System
         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();
         }
     }
 
index 953e87a..7a8db57 100644 (file)
@@ -123,6 +123,7 @@ namespace System.Text
 
         internal DecoderFallbackException(SerializationInfo info, StreamingContext context) : base(info, context)
         {
+            throw new PlatformNotSupportedException();
         }
 
         public DecoderFallbackException(
index 03a6d74..c2791e9 100644 (file)
@@ -31,21 +31,10 @@ namespace System.Text
 
         #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 
index fb5a423..192ab78 100644 (file)
@@ -123,10 +123,6 @@ namespace System.Text
             HResult = __HResults.COR_E_ARGUMENT;
         }
 
-        internal EncoderFallbackException(SerializationInfo info, StreamingContext context) : base(info, context)
-        {
-        }
-
         internal EncoderFallbackException(
             String message, char charUnknown, int index) : base(message)
         {
index 4e75959..8a8c31e 100644 (file)
@@ -34,22 +34,10 @@ namespace System.Text
 
         #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 
index d6ab91d..5f55fd1 100644 (file)
@@ -1420,25 +1420,6 @@ namespace System.Text
                 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)
             {
@@ -1467,12 +1448,7 @@ namespace System.Text
             // 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
@@ -1540,26 +1516,6 @@ namespace System.Text
                 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)
             {
@@ -1580,15 +1536,10 @@ namespace System.Text
                 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
index b3e284d..3f040b2 100644 (file)
@@ -29,30 +29,10 @@ namespace System.Text
         {
         }
 
-        // 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
index 5e524d2..0ac3b66 100644 (file)
@@ -847,32 +847,10 @@ namespace System.Text
                 // 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()
@@ -910,30 +888,10 @@ namespace System.Text
                 // 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()
index cd7bd1c..fb72110 100644 (file)
@@ -41,6 +41,7 @@ namespace System.Threading
 
         protected ThreadInterruptedException(SerializationInfo info, StreamingContext context) : base(info, context)
         {
+            throw new PlatformNotSupportedException();
         }
     }
 }
index a52e1bc..5e748a6 100644 (file)
@@ -104,33 +104,16 @@ namespace System
 
         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
index 29fb347..00f1db4 100644 (file)
@@ -25,27 +25,12 @@ class Test
            {
 //             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;
 
 
         }