Make more exceptions serializable, fix typeforwards and add one missing serialization...
authorViktor Hofer <viktor.hofer@outlook.com>
Thu, 5 Oct 2017 14:55:25 +0000 (16:55 +0200)
committerViktor Hofer <viktor.hofer@outlook.com>
Thu, 5 Oct 2017 14:55:25 +0000 (16:55 +0200)
src/mscorlib/shared/System/Reflection/ReflectionTypeLoadException.cs
src/mscorlib/shared/System/Security/SecurityException.cs
src/mscorlib/shared/System/Threading/LockRecursionException.cs
src/mscorlib/shared/System/Threading/SemaphoreFullException.cs
src/mscorlib/shared/System/TimeZoneNotFoundException.cs
src/mscorlib/src/System/MissingMemberException.cs

index 0e86d34..a411387 100644 (file)
@@ -6,6 +6,8 @@ using System.Runtime.Serialization;
 
 namespace System.Reflection
 {
+    [Serializable]
+    [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
     public sealed class ReflectionTypeLoadException : SystemException, ISerializable
     {
         public ReflectionTypeLoadException(Type[] classes, Exception[] exceptions)
@@ -24,9 +26,17 @@ namespace System.Reflection
             HResult = HResults.COR_E_REFLECTIONTYPELOAD;
         }
 
+        private ReflectionTypeLoadException(SerializationInfo info, StreamingContext context) 
+            : base(info, context)
+        {
+            LoaderExceptions = (Exception[])(info.GetValue("Exceptions", typeof(Exception[])));
+        }
+
         public override void GetObjectData(SerializationInfo info, StreamingContext context)
         {
             base.GetObjectData(info, context);
+            info.AddValue("Types", null, typeof(Type[]));
+            info.AddValue("Exceptions", LoaderExceptions, typeof(Exception[]));
         }
 
         public Type[] Types { get; }
index 51a23b1..61504c3 100644 (file)
@@ -11,6 +11,13 @@ namespace System.Security
     [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
     public class SecurityException : SystemException
     {
+        private const string DemandedName = "Demanded";
+        private const string GrantedSetName = "GrantedSet";
+        private const string RefusedSetName = "RefusedSet";
+        private const string DeniedName = "Denied";
+        private const string PermitOnlyName = "PermitOnly";
+        private const string UrlName = "Url";
+
         public SecurityException()
             : base(SR.Arg_SecurityException)
         {
@@ -47,11 +54,26 @@ namespace System.Security
         protected SecurityException(SerializationInfo info, StreamingContext context)
             : base(info, context)
         {
+            Demanded = (string)info.GetValueNoThrow(DemandedName, typeof(string));
+            GrantedSet = (string)info.GetValueNoThrow(GrantedSetName, typeof(string));
+            RefusedSet = (string)info.GetValueNoThrow(RefusedSetName, typeof(string));
+            DenySetInstance = (string)info.GetValueNoThrow(DeniedName, typeof(string));
+            PermitOnlySetInstance = (string)info.GetValueNoThrow(PermitOnlyName, typeof(string));
+            Url = (string)info.GetValueNoThrow(UrlName, typeof(string));
         }
 
         public override string ToString() => base.ToString();
 
-        public override void GetObjectData(SerializationInfo info, StreamingContext context) => base.GetObjectData(info, context);
+        public override void GetObjectData(SerializationInfo info, StreamingContext context)
+        {
+            base.GetObjectData(info, context); 
+            info.AddValue(DemandedName, Demanded, typeof(string));
+            info.AddValue(GrantedSetName, GrantedSet, typeof(string));
+            info.AddValue(RefusedSetName, RefusedSet, typeof(string));
+            info.AddValue(DeniedName, DenySetInstance, typeof(string));
+            info.AddValue(PermitOnlyName, PermitOnlySetInstance, typeof(string));
+            info.AddValue(UrlName, Url, typeof(string));
+        }
 
         public object Demanded { get; set; }
         public object DenySetInstance { get; set; }
index ac7c1b6..c76c7a5 100644 (file)
@@ -8,7 +8,7 @@ using System.Runtime.Serialization;
 namespace System.Threading
 {
     [Serializable]
-    [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
+    [System.Runtime.CompilerServices.TypeForwardedFrom("System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
     public class LockRecursionException : System.Exception
     {
         public LockRecursionException()
index 883e167..18558b1 100644 (file)
@@ -8,7 +8,7 @@ using System.Runtime.Serialization;
 namespace System.Threading
 {
     [Serializable]
-    [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
+    [System.Runtime.CompilerServices.TypeForwardedFrom("System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
     public class SemaphoreFullException : SystemException
     {
         public SemaphoreFullException() : base(SR.Threading_SemaphoreFullException)
index 5eccfd5..f83c644 100644 (file)
@@ -7,7 +7,7 @@ using System.Runtime.Serialization;
 namespace System
 {
     [Serializable]
-    [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
+    [System.Runtime.CompilerServices.TypeForwardedFrom("System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
     public class TimeZoneNotFoundException : Exception
     {
         public TimeZoneNotFoundException()
index 95ad711..ba16b27 100644 (file)
 =============================================================================*/
 
 
-using System;
 using System.Runtime.Serialization;
 using System.Runtime.CompilerServices;
-using System.Globalization;
-using System.Runtime.Versioning;
-using System.Diagnostics.Contracts;
 
 namespace System
 {
@@ -45,8 +41,8 @@ namespace System
 
         protected MissingMemberException(SerializationInfo info, StreamingContext context) : base(info, context)
         {
-            ClassName = (string)info.GetString("MMClassName");
-            MemberName = (string)info.GetString("MMMemberName");
+            ClassName = info.GetString("MMClassName");
+            MemberName = info.GetString("MMMemberName");
             Signature = (byte[])info.GetValue("MMSignature", typeof(byte[]));
         }
 
@@ -80,6 +76,7 @@ namespace System
         {
             base.GetObjectData(info, context);
             info.AddValue("MMClassName", ClassName, typeof(string));
+            info.AddValue("MMMemberName", MemberName, typeof(string));
             info.AddValue("MMSignature", Signature, typeof(byte[]));
         }