From 30669e8c257ce02f08cf763dcd1efaf99950ed81 Mon Sep 17 00:00:00 2001 From: Oren Nachman Date: Tue, 9 Aug 2022 20:18:37 -0700 Subject: [PATCH] Further cleanups --- Flow.Launcher.Core/Plugin/PluginManager.cs | 2 +- Flow.Launcher.Test/Plugins/ExplorerTest.cs | 8 +++++--- Flow.Launcher/App.xaml.cs | 2 +- Flow.Launcher/CustomQueryHotkeySetting.xaml.cs | 2 +- Flow.Launcher/HotkeyControl.xaml.cs | 8 ++++---- Flow.Launcher/Resources/Pages/WelcomePage2.xaml.cs | 2 +- Flow.Launcher/SettingWindow.xaml.cs | 2 +- Plugins/Flow.Launcher.Plugin.PluginsManager/Main.cs | 2 +- .../PluginsManager.cs | 12 ++++++------ Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs | 2 +- 10 files changed, 22 insertions(+), 20 deletions(-) diff --git a/Flow.Launcher.Core/Plugin/PluginManager.cs b/Flow.Launcher.Core/Plugin/PluginManager.cs index d6b130f7b..7f8eb024a 100644 --- a/Flow.Launcher.Core/Plugin/PluginManager.cs +++ b/Flow.Launcher.Core/Plugin/PluginManager.cs @@ -109,7 +109,7 @@ namespace Flow.Launcher.Core.Plugin /// Call initialize for all plugins /// /// return the list of failed to init plugins or null for none - public static async Task InitializePlugins(IPublicAPI api) + public static async Task InitializePluginsAsync(IPublicAPI api) { API = api; var failedPlugins = new ConcurrentQueue(); diff --git a/Flow.Launcher.Test/Plugins/ExplorerTest.cs b/Flow.Launcher.Test/Plugins/ExplorerTest.cs index 9d7fccad9..78be463e4 100644 --- a/Flow.Launcher.Test/Plugins/ExplorerTest.cs +++ b/Flow.Launcher.Test/Plugins/ExplorerTest.cs @@ -1,4 +1,4 @@ -using Flow.Launcher.Plugin; +using Flow.Launcher.Plugin; using Flow.Launcher.Plugin.Explorer; using Flow.Launcher.Plugin.Explorer.Search; using Flow.Launcher.Plugin.Explorer.Search.DirectoryInfo; @@ -19,10 +19,12 @@ namespace Flow.Launcher.Test.Plugins [TestFixture] public class ExplorerTest { +#pragma warning disable CS1998 // async method with no await (more readable to leave it async to match the tested signature) private async Task> MethodWindowsIndexSearchReturnsZeroResultsAsync(Query dummyQuery, string dummyString, CancellationToken dummyToken) { return new List(); } +#pragma warning restore CS1998 private List MethodDirectoryInfoClassSearchReturnsTwoResults(Query dummyQuery, string dummyString, CancellationToken token) { @@ -151,7 +153,7 @@ namespace Flow.Launcher.Test.Plugins } [TestCase] - public async Task GivenTopLevelDirectorySearch_WhenIndexSearchNotRequired_ThenSearchMethodShouldContinueDirectoryInfoClassSearch() + public async Task GivenTopLevelDirectorySearch_WhenIndexSearchNotRequired_ThenSearchMethodShouldContinueDirectoryInfoClassSearchAsync() { // Given var searchManager = new SearchManager(new Settings(), new PluginInitContext()); @@ -172,7 +174,7 @@ namespace Flow.Launcher.Test.Plugins } [TestCase] - public async Task GivenTopLevelDirectorySearch_WhenIndexSearchNotRequired_ThenSearchMethodShouldNotContinueDirectoryInfoClassSearch() + public async Task GivenTopLevelDirectorySearch_WhenIndexSearchNotRequired_ThenSearchMethodShouldNotContinueDirectoryInfoClassSearchAsync() { // Given var searchManager = new SearchManager(new Settings(), new PluginInitContext()); diff --git a/Flow.Launcher/App.xaml.cs b/Flow.Launcher/App.xaml.cs index 8c970eddd..cb8e79d63 100644 --- a/Flow.Launcher/App.xaml.cs +++ b/Flow.Launcher/App.xaml.cs @@ -74,7 +74,7 @@ namespace Flow.Launcher Http.API = API; Http.Proxy = _settings.Proxy; - await PluginManager.InitializePlugins(API); + await PluginManager.InitializePluginsAsync(API); var window = new MainWindow(_settings, _mainVM); Log.Info($"|App.OnStartup|Dependencies Info:{ErrorReporting.DependenciesInfo()}"); diff --git a/Flow.Launcher/CustomQueryHotkeySetting.xaml.cs b/Flow.Launcher/CustomQueryHotkeySetting.xaml.cs index b98df9a94..110beeded 100644 --- a/Flow.Launcher/CustomQueryHotkeySetting.xaml.cs +++ b/Flow.Launcher/CustomQueryHotkeySetting.xaml.cs @@ -81,7 +81,7 @@ namespace Flow.Launcher } tbAction.Text = updateCustomHotkey.ActionKeyword; - _ = ctlHotkey.SetHotkey(updateCustomHotkey.Hotkey, false); + _ = ctlHotkey.SetHotkeyAsync(updateCustomHotkey.Hotkey, false); update = true; lblAdd.Text = InternationalizationManager.Instance.GetTranslation("update"); } diff --git a/Flow.Launcher/HotkeyControl.xaml.cs b/Flow.Launcher/HotkeyControl.xaml.cs index 6bd21453f..9a4e946d0 100644 --- a/Flow.Launcher/HotkeyControl.xaml.cs +++ b/Flow.Launcher/HotkeyControl.xaml.cs @@ -65,11 +65,11 @@ namespace Flow.Launcher { await Task.Delay(500, token); if (!token.IsCancellationRequested) - await SetHotkey(hotkeyModel); + await SetHotkeyAsync(hotkeyModel); }); } - public async Task SetHotkey(HotkeyModel keyModel, bool triggerValidate = true) + public async Task SetHotkeyAsync(HotkeyModel keyModel, bool triggerValidate = true) { CurrentHotkey = keyModel; @@ -101,9 +101,9 @@ namespace Flow.Launcher } } - public async Task SetHotkey(string keyStr, bool triggerValidate = true) + public async Task SetHotkeyAsync(string keyStr, bool triggerValidate = true) { - _ = SetHotkey(new HotkeyModel(keyStr), triggerValidate); + await SetHotkeyAsync(new HotkeyModel(keyStr), triggerValidate); } private bool CheckHotkeyAvailability() => HotKeyMapper.CheckAvailability(CurrentHotkey); diff --git a/Flow.Launcher/Resources/Pages/WelcomePage2.xaml.cs b/Flow.Launcher/Resources/Pages/WelcomePage2.xaml.cs index a433611f6..4f8d65378 100644 --- a/Flow.Launcher/Resources/Pages/WelcomePage2.xaml.cs +++ b/Flow.Launcher/Resources/Pages/WelcomePage2.xaml.cs @@ -27,7 +27,7 @@ namespace Flow.Launcher.Resources.Pages tbMsgTextOriginal = HotkeyControl.tbMsg.Text; tbMsgForegroundColorOriginal = HotkeyControl.tbMsg.Foreground; - HotkeyControl.SetHotkey(new Infrastructure.Hotkey.HotkeyModel(Settings.Hotkey), false); + HotkeyControl.SetHotkeyAsync(new Infrastructure.Hotkey.HotkeyModel(Settings.Hotkey), false); } private void HotkeyControl_OnGotFocus(object sender, RoutedEventArgs args) { diff --git a/Flow.Launcher/SettingWindow.xaml.cs b/Flow.Launcher/SettingWindow.xaml.cs index 38b5e0a5a..10c9aeffe 100644 --- a/Flow.Launcher/SettingWindow.xaml.cs +++ b/Flow.Launcher/SettingWindow.xaml.cs @@ -101,7 +101,7 @@ namespace Flow.Launcher private void OnHotkeyControlLoaded(object sender, RoutedEventArgs e) { - _ = HotkeyControl.SetHotkey(viewModel.Settings.Hotkey, false); + _ = HotkeyControl.SetHotkeyAsync(viewModel.Settings.Hotkey, false); } private void OnHotkeyControlFocused(object sender, RoutedEventArgs e) diff --git a/Plugins/Flow.Launcher.Plugin.PluginsManager/Main.cs b/Plugins/Flow.Launcher.Plugin.PluginsManager/Main.cs index 57c857403..dddb7cf68 100644 --- a/Plugins/Flow.Launcher.Plugin.PluginsManager/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.PluginsManager/Main.cs @@ -55,7 +55,7 @@ namespace Flow.Launcher.Plugin.PluginsManager //search could be url, no need ToLower() when passed in Settings.InstallCommand => await pluginManager.RequestInstallOrUpdate(query.SecondToEndSearch, token), Settings.UninstallCommand => pluginManager.RequestUninstall(query.SecondToEndSearch), - Settings.UpdateCommand => await pluginManager.RequestUpdate(query.SecondToEndSearch, token), + Settings.UpdateCommand => await pluginManager.RequestUpdateAsync(query.SecondToEndSearch, token), _ => pluginManager.GetDefaultHotKeys().Where(hotkey => { hotkey.Score = StringMatcher.FuzzySearch(query.Search, hotkey.Title).Score; diff --git a/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs b/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs index bbf155e23..4ca98aeae 100644 --- a/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs +++ b/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs @@ -1,4 +1,4 @@ -using Flow.Launcher.Core.ExternalPlugins; +using Flow.Launcher.Core.ExternalPlugins; using Flow.Launcher.Core.Plugin; using Flow.Launcher.Infrastructure; using Flow.Launcher.Infrastructure.Http; @@ -109,7 +109,7 @@ namespace Flow.Launcher.Plugin.PluginsManager }; } - internal async Task InstallOrUpdate(UserPlugin plugin) + internal async Task InstallOrUpdateAsync(UserPlugin plugin) { if (PluginExists(plugin.ID)) { @@ -182,7 +182,7 @@ namespace Flow.Launcher.Plugin.PluginsManager Context.API.RestartApp(); } - internal async ValueTask> RequestUpdate(string search, CancellationToken token) + internal async ValueTask> RequestUpdateAsync(string search, CancellationToken token) { await UpdateManifestAsync(token); @@ -336,7 +336,7 @@ namespace Flow.Launcher.Plugin.PluginsManager } Application.Current.MainWindow.Hide(); - _ = InstallOrUpdate(plugin); + _ = InstallOrUpdateAsync(plugin); return ShouldHideWindow; } @@ -383,7 +383,7 @@ namespace Flow.Launcher.Plugin.PluginsManager } Application.Current.MainWindow.Hide(); - _ = InstallOrUpdate(x); // No need to wait + _ = InstallOrUpdateAsync(x); // No need to wait return ShouldHideWindow; }, ContextData = x @@ -502,4 +502,4 @@ namespace Flow.Launcher.Plugin.PluginsManager && newMetadata.Version.CompareTo(x.Metadata.Version) <= 0); } } -} \ No newline at end of file +} diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs index 9e2a9a0f3..81dc8b88c 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs @@ -407,7 +407,7 @@ namespace Flow.Launcher.Plugin.Program.Programs }); } - private async void LaunchElevated() + private void LaunchElevated() { string command = "shell:AppsFolder\\" + UniqueIdentifier; command = Environment.ExpandEnvironmentVariables(command.Trim());