Use ThrowHelper in ManualResetValueTaskSourceCore (dotnet/coreclr#22714)
authorStephen Toub <stoub@microsoft.com>
Wed, 20 Feb 2019 19:36:56 +0000 (14:36 -0500)
committerGitHub <noreply@github.com>
Wed, 20 Feb 2019 19:36:56 +0000 (14:36 -0500)
Just move the helper being used to ThrowHelper.

Commit migrated from https://github.com/dotnet/coreclr/commit/57b0be625346712fd3bafb71a9568edb579971f1

src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Sources/ManualResetValueTaskSourceCore.cs
src/libraries/System.Private.CoreLib/src/System/ThrowHelper.cs

index 264fe92..3244e0a 100644 (file)
@@ -94,7 +94,7 @@ namespace System.Threading.Tasks.Sources
             ValidateToken(token);
             if (!_completed)
             {
-                ManualResetValueTaskSourceCoreShared.ThrowInvalidOperationException();
+                ThrowHelper.ThrowInvalidOperationException();
             }
 
             _error?.Throw();
@@ -156,7 +156,7 @@ namespace System.Threading.Tasks.Sources
                 // Operation already completed, so we need to queue the supplied callback.
                 if (!ReferenceEquals(oldContinuation, ManualResetValueTaskSourceCoreShared.s_sentinel))
                 {
-                    ManualResetValueTaskSourceCoreShared.ThrowInvalidOperationException();
+                    ThrowHelper.ThrowInvalidOperationException();
                 }
 
                 switch (_capturedContext)
@@ -193,7 +193,7 @@ namespace System.Threading.Tasks.Sources
         {
             if (token != _version)
             {
-                ManualResetValueTaskSourceCoreShared.ThrowInvalidOperationException();
+                ThrowHelper.ThrowInvalidOperationException();
             }
         }
 
@@ -202,7 +202,7 @@ namespace System.Threading.Tasks.Sources
         {
             if (_completed)
             {
-                ManualResetValueTaskSourceCoreShared.ThrowInvalidOperationException();
+                ThrowHelper.ThrowInvalidOperationException();
             }
             _completed = true;
 
@@ -266,14 +266,11 @@ namespace System.Threading.Tasks.Sources
 
     internal static class ManualResetValueTaskSourceCoreShared // separated out of generic to avoid unnecessary duplication
     {
-        [StackTraceHidden]
-        internal static void ThrowInvalidOperationException() => throw new InvalidOperationException();
-
         internal static readonly Action<object> s_sentinel = CompletionSentinel;
         private static void CompletionSentinel(object _) // named method to aid debugging
         {
             Debug.Fail("The sentinel delegate should never be invoked.");
-            ThrowInvalidOperationException();
+            ThrowHelper.ThrowInvalidOperationException();
         }
     }
 }
index df66f3f..cc39069 100644 (file)
@@ -191,6 +191,11 @@ namespace System
             throw GetArgumentOutOfRangeException(argument, paramNumber, resource);
         }
 
+        internal static void ThrowInvalidOperationException()
+        {
+            throw new InvalidOperationException();
+        }
+
         internal static void ThrowInvalidOperationException(ExceptionResource resource)
         {
             throw GetInvalidOperationException(resource);