diff --git a/src/Common.Dotnet.AotCompatibility.props b/src/Common.Dotnet.AotCompatibility.props
index 46a39e9c65..af1eb9f5e8 100644
--- a/src/Common.Dotnet.AotCompatibility.props
+++ b/src/Common.Dotnet.AotCompatibility.props
@@ -7,6 +7,6 @@
2
- IL2081;$(WarningsNotAsErrors)
+ IL2081,CsWinRT1028;$(WarningsNotAsErrors)
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/ShortcutControl/HotkeySettingsControlHook.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/ShortcutControl/HotkeySettingsControlHook.cs
index 66f482f502..6ea1c708a7 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/ShortcutControl/HotkeySettingsControlHook.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/ShortcutControl/HotkeySettingsControlHook.cs
@@ -12,7 +12,7 @@ public delegate bool IsActive();
public delegate bool FilterAccessibleKeyboardEvents(int key, UIntPtr extraInfo);
-public class HotkeySettingsControlHook : IDisposable
+public partial class HotkeySettingsControlHook : IDisposable
{
private const int WmKeyDown = 0x100;
private const int WmKeyUp = 0x101;
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/ShortcutControl/NativeKeyboardHelper.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/ShortcutControl/NativeKeyboardHelper.cs
index 9d3961f907..cbbab871aa 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/ShortcutControl/NativeKeyboardHelper.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/ShortcutControl/NativeKeyboardHelper.cs
@@ -2,85 +2,83 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System;
using System.Runtime.InteropServices;
-namespace Microsoft.PowerToys.Settings.UI.Helpers
+namespace Microsoft.PowerToys.Settings.UI.Helpers;
+
+internal static class NativeKeyboardHelper
{
- internal static class NativeKeyboardHelper
+ [StructLayout(LayoutKind.Sequential)]
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.NamingRules", "SA1307:Accessible fields should begin with upper-case letter", Justification = "Matching Native Structure")]
+ internal struct INPUT
{
- [StructLayout(LayoutKind.Sequential)]
- [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.NamingRules", "SA1307:Accessible fields should begin with upper-case letter", Justification = "Matching Native Structure")]
- internal struct INPUT
- {
- internal INPUTTYPE type;
- internal InputUnion data;
+ internal INPUTTYPE type;
+ internal InputUnion data;
- internal static int Size
- {
- get { return Marshal.SizeOf(typeof(INPUT)); }
- }
- }
-
- [StructLayout(LayoutKind.Explicit)]
- [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.NamingRules", "SA1307:Accessible fields should begin with upper-case letter", Justification = "Matching Native Structure")]
- internal struct InputUnion
+ internal static int Size
{
- [FieldOffset(0)]
- internal MOUSEINPUT mi;
- [FieldOffset(0)]
- internal KEYBDINPUT ki;
- [FieldOffset(0)]
- internal HARDWAREINPUT hi;
- }
-
- [StructLayout(LayoutKind.Sequential)]
- [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.NamingRules", "SA1307:Accessible fields should begin with upper-case letter", Justification = "Matching Native Structure")]
- internal struct MOUSEINPUT
- {
- internal int dx;
- internal int dy;
- internal int mouseData;
- internal uint dwFlags;
- internal uint time;
- internal UIntPtr dwExtraInfo;
- }
-
- [StructLayout(LayoutKind.Sequential)]
- [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.NamingRules", "SA1307:Accessible fields should begin with upper-case letter", Justification = "Matching Native Structure")]
- internal struct KEYBDINPUT
- {
- internal short wVk;
- internal short wScan;
- internal uint dwFlags;
- internal int time;
- internal UIntPtr dwExtraInfo;
- }
-
- [StructLayout(LayoutKind.Sequential)]
- [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.NamingRules", "SA1307:Accessible fields should begin with upper-case letter", Justification = "Matching Native Structure")]
- internal struct HARDWAREINPUT
- {
- internal int uMsg;
- internal short wParamL;
- internal short wParamH;
- }
-
- internal enum INPUTTYPE : uint
- {
- INPUT_MOUSE = 0,
- INPUT_KEYBOARD = 1,
- INPUT_HARDWARE = 2,
- }
-
- [Flags]
- internal enum KeyEventF
- {
- KeyDown = 0x0000,
- ExtendedKey = 0x0001,
- KeyUp = 0x0002,
- Unicode = 0x0004,
- Scancode = 0x0008,
+ get { return Marshal.SizeOf(); }
}
}
+
+ [StructLayout(LayoutKind.Explicit)]
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.NamingRules", "SA1307:Accessible fields should begin with upper-case letter", Justification = "Matching Native Structure")]
+ internal struct InputUnion
+ {
+ [FieldOffset(0)]
+ internal MOUSEINPUT mi;
+ [FieldOffset(0)]
+ internal KEYBDINPUT ki;
+ [FieldOffset(0)]
+ internal HARDWAREINPUT hi;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.NamingRules", "SA1307:Accessible fields should begin with upper-case letter", Justification = "Matching Native Structure")]
+ internal struct MOUSEINPUT
+ {
+ internal int dx;
+ internal int dy;
+ internal int mouseData;
+ internal uint dwFlags;
+ internal uint time;
+ internal UIntPtr dwExtraInfo;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.NamingRules", "SA1307:Accessible fields should begin with upper-case letter", Justification = "Matching Native Structure")]
+ internal struct KEYBDINPUT
+ {
+ internal short wVk;
+ internal short wScan;
+ internal uint dwFlags;
+ internal int time;
+ internal UIntPtr dwExtraInfo;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.NamingRules", "SA1307:Accessible fields should begin with upper-case letter", Justification = "Matching Native Structure")]
+ internal struct HARDWAREINPUT
+ {
+ internal int uMsg;
+ internal short wParamL;
+ internal short wParamH;
+ }
+
+ internal enum INPUTTYPE : uint
+ {
+ INPUT_MOUSE = 0,
+ INPUT_KEYBOARD = 1,
+ INPUT_HARDWARE = 2,
+ }
+
+ [Flags]
+ internal enum KeyEventF
+ {
+ KeyDown = 0x0000,
+ ExtendedKey = 0x0001,
+ KeyUp = 0x0002,
+ Unicode = 0x0004,
+ Scancode = 0x0008,
+ }
}
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/MainWindow.xaml.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI/MainWindow.xaml.cs
index d4d868b581..07b7c85e5f 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI/MainWindow.xaml.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/MainWindow.xaml.cs
@@ -660,7 +660,7 @@ public sealed partial class MainWindow : WindowEx,
_largeIcon = GetAppIconHandle();
_trayIconData = new NOTIFYICONDATAW()
{
- cbSize = (uint)Marshal.SizeOf(typeof(NOTIFYICONDATAW)),
+ cbSize = (uint)Marshal.SizeOf(),
hWnd = _hwnd,
uID = MY_NOTIFY_ID,
uFlags = NOTIFY_ICON_DATA_FLAGS.NIF_MESSAGE | NOTIFY_ICON_DATA_FLAGS.NIF_ICON | NOTIFY_ICON_DATA_FLAGS.NIF_TIP,
@@ -697,7 +697,7 @@ public sealed partial class MainWindow : WindowEx,
private DestroyIconSafeHandle GetAppIconHandle()
{
- var exePath = System.Reflection.Assembly.GetExecutingAssembly().Location;
+ var exePath = AppContext.BaseDirectory;
DestroyIconSafeHandle largeIcon;
PInvoke.ExtractIconEx(exePath, 0, out largeIcon, out _, 1);
return largeIcon;
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Microsoft.CmdPal.UI.csproj b/src/modules/cmdpal/Microsoft.CmdPal.UI/Microsoft.CmdPal.UI.csproj
index 0b653d2d0a..e13dc7f281 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Microsoft.CmdPal.UI.csproj
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Microsoft.CmdPal.UI.csproj
@@ -1,6 +1,7 @@
+
@@ -92,7 +93,6 @@
-
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/NativeMethods.txt b/src/modules/cmdpal/Microsoft.CmdPal.UI/NativeMethods.txt
index c39ed38300..51badbd1a0 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI/NativeMethods.txt
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/NativeMethods.txt
@@ -1,7 +1,6 @@
GetPhysicallyInstalledSystemMemory
GlobalMemoryStatusEx
GetSystemInfo
-CoCreateInstance
GetForegroundWindow
SetForegroundWindow
GetWindowRect
@@ -21,25 +20,18 @@ SetActiveWindow
MonitorFromWindow
GetMonitorInfo
GetDpiForMonitor
-SHCreateStreamOnFileEx
CoAllowSetForegroundWindow
-SHCreateStreamOnFileEx
-SHLoadIndirectString
WM_HOTKEY
WM_NCLBUTTONDBLCLK
-
Shell_NotifyIcon
LoadIcon
WM_USER
WM_WINDOWPOSCHANGING
RegisterWindowMessageW
-GetModuleHandleW
ExtractIconEx
WM_RBUTTONUP
WM_LBUTTONUP
WM_LBUTTONDBLCLK
-
-MessageBox
DwmGetWindowAttribute
DwmSetWindowAttribute
DWM_CLOAKED_APP
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Program.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI/Program.cs
index ffe2f45176..4e4cfd2a82 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Program.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Program.cs
@@ -34,33 +34,6 @@ internal sealed class Program
return 0;
}
- try
- {
- Logger.InitializeLogger("\\CmdPal\\Logs\\");
- }
- catch (COMException e)
- {
- // This is unexpected. For the sake of debugging:
- // pop a message box
- PInvoke.MessageBox(
- (HWND)IntPtr.Zero,
- $"Failed to initialize the logger. COMException: \r{e.Message}",
- "Command Palette",
- MESSAGEBOX_STYLE.MB_OK | MESSAGEBOX_STYLE.MB_ICONERROR);
- return 0;
- }
- catch (Exception e2)
- {
- // This is unexpected. For the sake of debugging:
- // pop a message box
- PInvoke.MessageBox(
- (HWND)IntPtr.Zero,
- $"Failed to initialize the logger. Unknown Exception: \r{e2.Message}",
- "Command Palette",
- MESSAGEBOX_STYLE.MB_OK | MESSAGEBOX_STYLE.MB_ICONERROR);
- return 0;
- }
-
Logger.LogDebug($"Starting at {DateTime.UtcNow}");
PowerToysTelemetry.Log.WriteEvent(new CmdPalProcessStarted());
diff --git a/src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/ListHelpers.cs b/src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/ListHelpers.cs
index 5468449406..8a4547b550 100644
--- a/src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/ListHelpers.cs
+++ b/src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/ListHelpers.cs
@@ -136,6 +136,8 @@ public partial class ListHelpers
}
}
+#pragma warning disable CA1051
+
public struct ScoredListItem
{
public int Score;
@@ -147,3 +149,4 @@ public struct Scored
public int Score;
public T Item;
}
+#pragma warning restore CA1051