Make one more exception serializable some code styling
authorViktor Hofer <viktor.hofer@outlook.com>
Sat, 7 Oct 2017 10:12:03 +0000 (12:12 +0200)
committerViktor Hofer <viktor.hofer@outlook.com>
Sat, 7 Oct 2017 10:12:03 +0000 (12:12 +0200)
src/mscorlib/shared/System/NotFiniteNumberException.cs
src/mscorlib/shared/System/Runtime/CompilerServices/RuntimeWrappedException.cs
src/mscorlib/shared/System/Text/DecoderExceptionFallback.cs
src/mscorlib/shared/System/Threading/ThreadStartException.cs

index 259248f..b9c9af0 100644 (file)
@@ -26,27 +26,27 @@ namespace System
             HResult = HResults.COR_E_NOTFINITENUMBER;
         }
 
-        public NotFiniteNumberException(String message)
+        public NotFiniteNumberException(string message)
             : base(message)
         {
             _offendingNumber = 0;
             HResult = HResults.COR_E_NOTFINITENUMBER;
         }
 
-        public NotFiniteNumberException(String message, double offendingNumber)
+        public NotFiniteNumberException(string message, double offendingNumber)
             : base(message)
         {
             _offendingNumber = offendingNumber;
             HResult = HResults.COR_E_NOTFINITENUMBER;
         }
 
-        public NotFiniteNumberException(String message, Exception innerException)
+        public NotFiniteNumberException(string message, Exception innerException)
             : base(message, innerException)
         {
             HResult = HResults.COR_E_NOTFINITENUMBER;
         }
 
-        public NotFiniteNumberException(String message, double offendingNumber, Exception innerException)
+        public NotFiniteNumberException(string message, double offendingNumber, Exception innerException)
             : base(message, innerException)
         {
             _offendingNumber = offendingNumber;
@@ -61,7 +61,7 @@ namespace System
         public override void GetObjectData(SerializationInfo info, StreamingContext context)
         {
             base.GetObjectData(info, context);
-            info.AddValue("OffendingNumber", _offendingNumber, typeof(Int32));
+            info.AddValue("OffendingNumber", _offendingNumber, typeof(int));
         }
 
         public double OffendingNumber
index af3b0c9..72996c6 100644 (file)
@@ -2,8 +2,6 @@
 // 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.Diagnostics.Contracts;
 using System.Runtime.Serialization;
 
 namespace System.Runtime.CompilerServices
@@ -15,29 +13,29 @@ namespace System.Runtime.CompilerServices
     [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
     public sealed class RuntimeWrappedException : Exception
     {
-        private Object _wrappedException; // EE expects this name
+        private object _wrappedException; // EE expects this name
 
         // Not an api but has to be public as System.Linq.Expression invokes this through Reflection when an expression
         // throws an object that doesn't derive from Exception.
-        public RuntimeWrappedException(Object thrownObject)
+        public RuntimeWrappedException(object thrownObject)
             : base(SR.RuntimeWrappedException)
         {
             HResult = HResults.COR_E_RUNTIMEWRAPPED;
             _wrappedException = thrownObject;
         }
 
-        public override void GetObjectData(SerializationInfo info, StreamingContext context)
+        private RuntimeWrappedException(SerializationInfo info, StreamingContext context)
+            : base(info, context)
         {
-            base.GetObjectData(info, context);
-            info.AddValue("WrappedException", _wrappedException, typeof(object));
+            _wrappedException = info.GetValue("WrappedException", typeof(object));
         }
 
-        internal RuntimeWrappedException(SerializationInfo info, StreamingContext context)
-            : base(info, context)
+        public override void GetObjectData(SerializationInfo info, StreamingContext context)
         {
-            _wrappedException = info.GetValue("WrappedException", typeof(object));
+            base.GetObjectData(info, context);
+            info.AddValue("WrappedException", _wrappedException, typeof(object));
         }
 
-        public Object WrappedException => _wrappedException;
+        public object WrappedException => _wrappedException;
     }
 }
index 26d604a..9fd6ef8 100644 (file)
@@ -4,6 +4,7 @@
 
 using System;
 using System.Globalization;
+using System.Runtime.Serialization;
 
 namespace System.Text
 {
@@ -98,6 +99,8 @@ namespace System.Text
     }
 
     // Exception for decoding unknown byte sequences.
+    [Serializable]
+    [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
     public sealed class DecoderFallbackException : ArgumentException
     {
         private byte[] _bytesUnknown = null;
@@ -128,6 +131,10 @@ namespace System.Text
             _index = index;
         }
 
+        private DecoderFallbackException(SerializationInfo serializationInfo, StreamingContext streamingContext)
+        {
+        }
+
         public byte[] BytesUnknown
         {
             get
index c6b180a..5172555 100644 (file)
@@ -22,7 +22,7 @@ namespace System.Threading
             HResult = HResults.COR_E_THREADSTART;
         }
 
-        internal ThreadStartException(SerializationInfo info, StreamingContext context)
+        private ThreadStartException(SerializationInfo info, StreamingContext context)
             : base(info, context)
         {
         }