From e911ef1ed8bed3b74f155a8a000b5419a33cd2b9 Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Wed, 20 Feb 2019 14:36:56 -0500 Subject: [PATCH] Use ThrowHelper in ManualResetValueTaskSourceCore (dotnet/coreclr#22714) Just move the helper being used to ThrowHelper. Commit migrated from https://github.com/dotnet/coreclr/commit/57b0be625346712fd3bafb71a9568edb579971f1 --- .../Tasks/Sources/ManualResetValueTaskSourceCore.cs | 13 +++++-------- .../System.Private.CoreLib/src/System/ThrowHelper.cs | 5 +++++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Sources/ManualResetValueTaskSourceCore.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Sources/ManualResetValueTaskSourceCore.cs index 264fe92..3244e0a 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Sources/ManualResetValueTaskSourceCore.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Sources/ManualResetValueTaskSourceCore.cs @@ -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 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(); } } } diff --git a/src/libraries/System.Private.CoreLib/src/System/ThrowHelper.cs b/src/libraries/System.Private.CoreLib/src/System/ThrowHelper.cs index df66f3f..cc39069 100644 --- a/src/libraries/System.Private.CoreLib/src/System/ThrowHelper.cs +++ b/src/libraries/System.Private.CoreLib/src/System/ThrowHelper.cs @@ -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); -- 2.7.4