Make internal API ThrowIfDeserializationInProgress internal (#44147)
authorMarek Safar <marek.safar@gmail.com>
Tue, 10 Nov 2020 08:16:04 +0000 (09:16 +0100)
committerGitHub <noreply@github.com>
Tue, 10 Nov 2020 08:16:04 +0000 (09:16 +0100)
* Make internal API ThrowIfDeserializationInProgress internal

also avoid doing costly argument checks

* Make methods public again

* Update src/libraries/System.Private.CoreLib/src/System/Runtime/Serialization/SerializationInfo.SerializationGuard.cs

Co-authored-by: Levi Broderick <GrabYourPitchforks@users.noreply.github.com>
Co-authored-by: Levi Broderick <GrabYourPitchforks@users.noreply.github.com>
src/libraries/System.Private.CoreLib/src/System/Runtime/Serialization/SerializationInfo.SerializationGuard.cs

index cc66407..5ea0f2f 100644 (file)
@@ -3,6 +3,7 @@
 
 using System.Security;
 using System.Threading;
+using System.Diagnostics;
 
 namespace System.Runtime.Serialization
 {
@@ -64,14 +65,7 @@ namespace System.Runtime.Serialization
         public static void ThrowIfDeserializationInProgress(string switchSuffix, ref int cachedValue)
         {
             const string SwitchPrefix = "Switch.System.Runtime.Serialization.SerializationGuard.";
-            if (switchSuffix == null)
-            {
-                throw new ArgumentNullException(nameof(switchSuffix));
-            }
-            if (string.IsNullOrWhiteSpace(switchSuffix))
-            {
-                throw new ArgumentException(SR.Argument_EmptyName, nameof(switchSuffix));
-            }
+            Debug.Assert(!string.IsNullOrWhiteSpace(switchSuffix));
 
             if (cachedValue == 0)
             {