Skip to content

Commit 93c7f4b

Browse files
Inline VerifyAccess (#4021)
* Inline VerifyAccess * Use static local function
1 parent 028bc1e commit 93c7f4b

File tree

1 file changed

+9
-1
lines changed
  • src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/Threading

1 file changed

+9
-1
lines changed

src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/Threading/Dispatcher.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
using MS.Internal.WindowsBase; // SecurityHelper
1818
using System.Threading;
1919
using System.ComponentModel; // EditorBrowsableAttribute, BrowsableAttribute
20+
using System.Diagnostics.CodeAnalysis;
21+
using System.Runtime.CompilerServices;
2022

2123
// Disabling 1634 and 1691:
2224
// In order to avoid generating warnings about unknown message numbers and
@@ -222,7 +224,13 @@ public void VerifyAccess()
222224
{
223225
if(!CheckAccess())
224226
{
225-
throw new InvalidOperationException(SR.VerifyAccess);
227+
// Used to inline VerifyAccess.
228+
[DoesNotReturn]
229+
[MethodImpl(MethodImplOptions.NoInlining)]
230+
static void ThrowVerifyAccess()
231+
=> throw new InvalidOperationException(SR.VerifyAccess);
232+
233+
ThrowVerifyAccess();
226234
}
227235
}
228236

0 commit comments

Comments
 (0)