diff --git a/src/Files.App/Shell/ContextMenu.cs b/src/Files.App/Shell/ContextMenu.cs index e23e6c005cb6..49b0b4f5ca99 100644 --- a/src/Files.App/Shell/ContextMenu.cs +++ b/src/Files.App/Shell/ContextMenu.cs @@ -62,7 +62,7 @@ public async Task InvokeVerb(string? verb) return true; } - catch (Exception ex) when (ex is COMException || ex is UnauthorizedAccessException) + catch (Exception ex) when (ex is COMException or UnauthorizedAccessException) { Debug.WriteLine(ex); } @@ -90,7 +90,7 @@ public async Task InvokeItem(int itemID) Win32API.BringToForeground(currentWindows); } - catch (Exception ex) when (ex is COMException || ex is UnauthorizedAccessException) + catch (Exception ex) when (ex is COMException or UnauthorizedAccessException) { Debug.WriteLine(ex); } @@ -110,7 +110,7 @@ public async Task InvokeItem(int itemID) shellItems.Add(ShellFolderExtensions.GetShellItemFromPathOrPidl(fp)); return GetContextMenuForFiles(shellItems.ToArray(), flags, owningThread, itemFilter); } - catch (Exception ex) when (ex is ArgumentException || ex is FileNotFoundException) + catch (Exception ex) when (ex is ArgumentException or FileNotFoundException) { // Return empty context menu return null; @@ -168,7 +168,7 @@ public async Task InvokeItem(int itemID) return contextMenu; } - catch (Exception ex) when (ex is ArgumentException || ex is FileNotFoundException) + catch (Exception ex) when (ex is ArgumentException or FileNotFoundException) { // Return empty context menu return null; @@ -259,7 +259,7 @@ private static void EnumMenuItems( { cMenu2?.HandleMenuMsg((uint)User32.WindowMessage.WM_INITMENUPOPUP, (IntPtr)mii.hSubMenu, new IntPtr(ii)); } - catch (NotImplementedException) + catch (Exception ex) when (ex is COMException or NotImplementedException) { // Only for dynamic/owner drawn? (open with, etc) } @@ -297,7 +297,7 @@ private static void EnumMenuItems( return commandString.ToString(); } - catch (Exception ex) when (ex is InvalidCastException || ex is ArgumentException) + catch (Exception ex) when (ex is InvalidCastException or ArgumentException) { // TODO: Investigate this... Debug.WriteLine(ex); @@ -305,7 +305,7 @@ private static void EnumMenuItems( return null; } - catch (Exception ex) when (ex is COMException || ex is NotImplementedException) + catch (Exception ex) when (ex is COMException or NotImplementedException) { // Not every item has an associated verb return null;