Skip to content

Commit 71f2464

Browse files
committed
Don't call GetLastWin32Error in interpolated string. Addresses CA1404
1 parent 9a77667 commit 71f2464

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Rubberduck.Core/Common/Hotkeys/Hotkey.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ public void Detach()
7171

7272
if (!User32.UnregisterHotKey(_hWndVbe, HotkeyInfo.HookId))
7373
{
74-
Logger.Warn($"Error calling UnregisterHotKey on hokey with id {HotkeyInfo.HookId} for command of type {Command.GetType()}; the error was {Marshal.GetLastWin32Error()}; going to delete the atom anyway... The memory may leak.");
74+
var error = Marshal.GetLastWin32Error();
75+
Logger.Warn($"Error calling UnregisterHotKey on hokey with id {HotkeyInfo.HookId} for command of type {Command.GetType()}; the error was {error}; going to delete the atom anyway... The memory may leak.");
7576
}
7677
Kernel32.SetLastError(Kernel32.ERROR_SUCCESS);
7778
Kernel32.GlobalDeleteAtom(HotkeyInfo.HookId);
@@ -93,9 +94,10 @@ private void HookKey(Keys key, uint shift)
9394
}
9495

9596
var hookId = (IntPtr)Kernel32.GlobalAddAtom(Guid.NewGuid().ToString());
97+
var error = Marshal.GetLastWin32Error();
9698
if (hookId == IntPtr.Zero)
97-
{
98-
Logger.Warn($"Error calling GlobalAddAtom; the error was {Marshal.GetLastWin32Error()}; aborting the HookKey operation...");
99+
{
100+
Logger.Warn($"Error calling GlobalAddAtom; the error was {error}; aborting the HookKey operation...");
99101
return;
100102
}
101103

0 commit comments

Comments
 (0)