From 96f10d27997f13e24866a415c346ba947e515f98 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Thu, 3 Apr 2025 22:13:12 +0800 Subject: [PATCH] Code quality --- Flow.Launcher.Infrastructure/Win32Helper.cs | 11 +++++++++++ Flow.Launcher/Notification.cs | 5 ++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Flow.Launcher.Infrastructure/Win32Helper.cs b/Flow.Launcher.Infrastructure/Win32Helper.cs index 7a3a0c36e..42461dc18 100644 --- a/Flow.Launcher.Infrastructure/Win32Helper.cs +++ b/Flow.Launcher.Infrastructure/Win32Helper.cs @@ -488,5 +488,16 @@ namespace Flow.Launcher.Infrastructure } #endregion + + #region Noticification + + public static bool IsNotificationSupport() + { + // Noticification only supported Windows 10 19041+ + return RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && + Environment.OSVersion.Version.Build >= 19041; + } + + #endregion } } diff --git a/Flow.Launcher/Notification.cs b/Flow.Launcher/Notification.cs index cb1cbb729..23125de15 100644 --- a/Flow.Launcher/Notification.cs +++ b/Flow.Launcher/Notification.cs @@ -9,8 +9,8 @@ namespace Flow.Launcher { internal static class Notification { - internal static bool legacy = Environment.OSVersion.Version.Build < 19041; - [System.Diagnostics.CodeAnalysis.SuppressMessage("Interoperability", "CA1416:Validate platform compatibility", Justification = "")] + internal static bool legacy = !Win32Helper.IsNotificationSupport(); + internal static void Uninstall() { if (!legacy) @@ -25,7 +25,6 @@ namespace Flow.Launcher }); } - [System.Diagnostics.CodeAnalysis.SuppressMessage("Interoperability", "CA1416:Validate platform compatibility", Justification = "")] private static void ShowInternal(string title, string subTitle, string iconPath = null) { // Handle notification for win7/8/early win10