diff --git a/Directory.Build.props b/Directory.Build.props index 6dea3ddd..ad2a1c02 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,5 +1,8 @@ net8.0-windows10.0.22621.0 + x64;arm64 + enable + nullable diff --git a/WinQuickLook.App/Program.cs b/WinQuickLook.App/Program.cs index ad3c7c97..178eaf90 100644 --- a/WinQuickLook.App/Program.cs +++ b/WinQuickLook.App/Program.cs @@ -38,8 +38,8 @@ public static void Main(string[] args) private static void ConfigureService(IServiceCollection services) { - services.TryAddEnumerable(new[] - { + services.TryAddEnumerable( + [ ServiceDescriptor.Singleton(), ServiceDescriptor.Singleton(), ServiceDescriptor.Singleton(), @@ -51,7 +51,7 @@ private static void ConfigureService(IServiceCollection services) ServiceDescriptor.Singleton(), ServiceDescriptor.Singleton(), ServiceDescriptor.Singleton() - }); + ]); services.AddSingleton(); services.AddSingleton(); diff --git a/WinQuickLook.App/WinQuickLook.App.csproj b/WinQuickLook.App/WinQuickLook.App.csproj index fcba5d27..e0e31af7 100644 --- a/WinQuickLook.App/WinQuickLook.App.csproj +++ b/WinQuickLook.App/WinQuickLook.App.csproj @@ -2,12 +2,9 @@ WinExe - enable true Icon.ico app.manifest - x64;arm64 - nullable win-x64;win-arm64 win-$(Platform).pubxml true diff --git a/WinQuickLook.Core.Tests/WinQuickLook.Core.Tests.csproj b/WinQuickLook.Core.Tests/WinQuickLook.Core.Tests.csproj index 3245265f..399039fd 100644 --- a/WinQuickLook.Core.Tests/WinQuickLook.Core.Tests.csproj +++ b/WinQuickLook.Core.Tests/WinQuickLook.Core.Tests.csproj @@ -1,11 +1,8 @@  - enable false WinQuickLook.Tests - x64;arm64 - nullable @@ -26,7 +23,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/WinQuickLook.Core/Controls/ShellFileControl.cs b/WinQuickLook.Core/Controls/ShellFileControl.cs index 3736f4f6..26426a9b 100644 --- a/WinQuickLook.Core/Controls/ShellFileControl.cs +++ b/WinQuickLook.Core/Controls/ShellFileControl.cs @@ -37,7 +37,9 @@ protected override HandleRef BuildWindowCore(HandleRef hwndParent) WINDOW_STYLE.WS_CHILD | WINDOW_STYLE.WS_VISIBLE | WINDOW_STYLE.WS_CLIPCHILDREN, 0, 0, (int)ActualWidth, (int)ActualHeight, - new HWND(hwndParent.Handle)); + new HWND(hwndParent.Handle), + null, + null); return new HandleRef(this, hwndHost); } diff --git a/WinQuickLook.Core/Messaging/LowLevelKeyboardHook.cs b/WinQuickLook.Core/Messaging/LowLevelKeyboardHook.cs index 1f8bc809..828670d4 100644 --- a/WinQuickLook.Core/Messaging/LowLevelKeyboardHook.cs +++ b/WinQuickLook.Core/Messaging/LowLevelKeyboardHook.cs @@ -8,13 +8,8 @@ namespace WinQuickLook.Messaging; -public class LowLevelKeyboardHook : WindowsHook +public class LowLevelKeyboardHook() : WindowsHook(WINDOWS_HOOK_ID.WH_KEYBOARD_LL) { - public LowLevelKeyboardHook() - : base(WINDOWS_HOOK_ID.WH_KEYBOARD_LL) - { - } - public Action? PerformKeyDown { get; set; } protected override LRESULT HookProc(int code, WPARAM wParam, LPARAM lParam) diff --git a/WinQuickLook.Core/Messaging/LowLevelMouseHook.cs b/WinQuickLook.Core/Messaging/LowLevelMouseHook.cs index 1cf16303..40dfbf72 100644 --- a/WinQuickLook.Core/Messaging/LowLevelMouseHook.cs +++ b/WinQuickLook.Core/Messaging/LowLevelMouseHook.cs @@ -4,13 +4,8 @@ namespace WinQuickLook.Messaging; -public class LowLevelMouseHook : WindowsHook +public class LowLevelMouseHook() : WindowsHook(WINDOWS_HOOK_ID.WH_MOUSE_LL) { - public LowLevelMouseHook() - : base(WINDOWS_HOOK_ID.WH_MOUSE_LL) - { - } - protected override LRESULT HookProc(int code, WPARAM wParam, LPARAM lParam) { if (code == PInvoke.HC_ACTION && wParam == PInvoke.WM_LBUTTONDOWN) diff --git a/WinQuickLook.Core/Providers/ShellAssociationProvider.cs b/WinQuickLook.Core/Providers/ShellAssociationProvider.cs index bed78598..a617fc86 100644 --- a/WinQuickLook.Core/Providers/ShellAssociationProvider.cs +++ b/WinQuickLook.Core/Providers/ShellAssociationProvider.cs @@ -49,14 +49,14 @@ public IReadOnlyList GetRecommends(FileInfo fileInfo) { if (PInvoke.SHAssocEnumHandlers(fileInfo.Extension, ASSOC_FILTER.ASSOC_FILTER_RECOMMENDED, out var enumAssocHandlers).Failed) { - return Array.Empty(); + return []; } try { var recommends = new List(); - var assocHandlers = new IAssocHandler?[8]; + var assocHandlers = new IAssocHandler[8]; while (enumAssocHandlers.Next(assocHandlers, out var fetched).Succeeded) { @@ -69,11 +69,6 @@ public IReadOnlyList GetRecommends(FileInfo fileInfo) { var assocHandler = assocHandlers[i]; - if (assocHandler is null) - { - continue; - } - try { assocHandler.GetUIName(out var pUiName); @@ -115,7 +110,7 @@ public void Invoke(string appName, FileInfo fileInfo) try { - var assocHandlers = new IAssocHandler?[8]; + var assocHandlers = new IAssocHandler[8]; while (enumAssocHandlers.Next(assocHandlers, out var fetched).Succeeded) { @@ -128,11 +123,6 @@ public void Invoke(string appName, FileInfo fileInfo) { var assocHandler = assocHandlers[i]; - if (assocHandler is null) - { - continue; - } - try { assocHandler.GetUIName(out var pUiName); diff --git a/WinQuickLook.Core/WinQuickLook.Core.csproj b/WinQuickLook.Core/WinQuickLook.Core.csproj index 251ccc9e..e94eb0c6 100644 --- a/WinQuickLook.Core/WinQuickLook.Core.csproj +++ b/WinQuickLook.Core/WinQuickLook.Core.csproj @@ -1,17 +1,14 @@ - + - enable true WinQuickLook - x64;arm64 - nullable - + diff --git a/WinQuickLook.CsWin32/PInvoke.cs b/WinQuickLook.CsWin32/PInvoke.cs index d87ccb5d..159005bd 100644 --- a/WinQuickLook.CsWin32/PInvoke.cs +++ b/WinQuickLook.CsWin32/PInvoke.cs @@ -20,14 +20,14 @@ public static partial class PInvoke public const uint MF_SOURCE_READER_FIRST_VIDEO_STREAM = 0xFFFFFFFCU; public const uint MF_SOURCE_READER_FIRST_AUDIO_STREAM = 0xFFFFFFFDU; - public static HRESULT SHCreateItemFromParsingName(string pszPath, System.Com.IBindCtx pbc, out T ppv) + public static HRESULT SHCreateItemFromParsingName(string pszPath, System.Com.IBindCtx? pbc, out T ppv) { var hr = SHCreateItemFromParsingName(pszPath, pbc, typeof(T).GUID, out var o); ppv = (T)o; return hr; } - public static HRESULT SHGetPropertyStoreFromParsingName(string pszPath, System.Com.IBindCtx pbc, GETPROPERTYSTOREFLAGS flags, out T ppv) + public static HRESULT SHGetPropertyStoreFromParsingName(string pszPath, System.Com.IBindCtx? pbc, GETPROPERTYSTOREFLAGS flags, out T ppv) { var hr = SHGetPropertyStoreFromParsingName(pszPath, pbc, flags, typeof(T).GUID, out var o); ppv = (T)o; @@ -35,7 +35,7 @@ public static HRESULT SHGetPropertyStoreFromParsingName(string pszPath, Syste } /// - public static unsafe HRESULT AssocQueryString(ASSOCF flags, ASSOCSTR str, string pszAssoc, string pszExtra, Span pszOut, ref uint pcchOut) + public static unsafe HRESULT AssocQueryString(ASSOCF flags, ASSOCSTR str, string pszAssoc, string? pszExtra, Span pszOut, ref uint pcchOut) { fixed (char* pszOutLocal = pszOut) { @@ -43,7 +43,7 @@ public static unsafe HRESULT AssocQueryString(ASSOCF flags, ASSOCSTR str, string } } - public static unsafe HWND CreateWindowEx(WINDOW_EX_STYLE dwExStyle, string lpClassName, string lpWindowName, WINDOW_STYLE dwStyle, int X, int Y, int nWidth, int nHeight, HWND hWndParent, SafeHandle hMenu = default, SafeHandle hInstance = default) + public static unsafe HWND CreateWindowEx(WINDOW_EX_STYLE dwExStyle, string lpClassName, string lpWindowName, WINDOW_STYLE dwStyle, int X, int Y, int nWidth, int nHeight, HWND hWndParent, SafeHandle? hMenu, SafeHandle? hInstance) { return CreateWindowEx(dwExStyle, lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWndParent, hMenu, hInstance, null); } diff --git a/WinQuickLook.CsWin32/WinQuickLook.CsWin32.csproj b/WinQuickLook.CsWin32/WinQuickLook.CsWin32.csproj index 87f32fbc..c062af1b 100644 --- a/WinQuickLook.CsWin32/WinQuickLook.CsWin32.csproj +++ b/WinQuickLook.CsWin32/WinQuickLook.CsWin32.csproj @@ -1,10 +1,8 @@  - x64;arm64 CS0109 Windows.Win32 - nullable