diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/CommandProviderWrapper.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/CommandProviderWrapper.cs index 81d9be2242..70f2b7ff83 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/CommandProviderWrapper.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/CommandProviderWrapper.cs @@ -43,13 +43,7 @@ public sealed class CommandProviderWrapper public bool IsActive { get; private set; } - public string ProviderId - { - get - { - return string.IsNullOrEmpty(Extension?.ExtensionUniqueId) ? Id : Extension.ExtensionUniqueId; - } - } + public string ProviderId => string.IsNullOrEmpty(Extension?.ExtensionUniqueId) ? Id : Extension.ExtensionUniqueId; public CommandProviderWrapper(ICommandProvider provider, TaskScheduler mainThread) { @@ -180,14 +174,14 @@ public sealed class CommandProviderWrapper var settings = serviceProvider.GetService()!; var providerSettings = GetProviderSettings(settings); - Func makeAndAdd = (ICommandItem? i, bool fallback) => + TopLevelViewModel makeAndAdd(ICommandItem? i, bool fallback) { CommandItemViewModel commandItemViewModel = new(new(i), pageContext); TopLevelViewModel topLevelViewModel = new(commandItemViewModel, fallback, ExtensionHost, ProviderId, settings, providerSettings, serviceProvider); topLevelViewModel.InitializeProperties(); return topLevelViewModel; - }; + } if (commands != null) { TopLevelItems = commands diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/CreatedExtensionForm.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/CreatedExtensionForm.cs index 78cca78363..e7a6f9c6f4 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/CreatedExtensionForm.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/CreatedExtensionForm.cs @@ -13,7 +13,7 @@ internal sealed partial class CreatedExtensionForm : NewExtensionFormBase { public CreatedExtensionForm(string name, string displayName, string path) { - var serializeString = (string? s) => JsonSerializer.Serialize(s, JsonSerializationContext.Default.String); + static string serializeString(string? s) => JsonSerializer.Serialize(s, JsonSerializationContext.Default.String); TemplateJson = CardTemplate; DataJson = $$""" { diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/MainListPage.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/MainListPage.cs index 95c8cf5646..2c640d48dc 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/MainListPage.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/MainListPage.cs @@ -271,7 +271,7 @@ public partial class MainListPage : DynamicListPage, // title and extension name up above ones that just match title. // e.g. "git" will up-weight "GitHub searches" from the GitHub extension // above "git" from "whatever" - max = max + extensionTitleMatch; + max += extensionTitleMatch; var matchSomething = max + (isAliasMatch ? 9001 : (isAliasSubstringMatch ? 1 : 0)); diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Models/ExtensionService.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Models/ExtensionService.cs index 6d59aa66b4..e5ec8f1785 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Models/ExtensionService.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Models/ExtensionService.cs @@ -260,8 +260,7 @@ public partial class ExtensionService : IExtensionService, IDisposable { foreach (var supportedInterface in supportedInterfaces) { - ProviderType pt; - if (Enum.TryParse(supportedInterface.Key, out pt)) + if (Enum.TryParse(supportedInterface.Key, out ProviderType pt)) { extensionWrapper.AddProviderType(pt); } diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ProviderSettings.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ProviderSettings.cs index a6ed102015..8132bf7b46 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ProviderSettings.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ProviderSettings.cs @@ -47,7 +47,7 @@ public class ProviderSettings public bool IsFallbackEnabled(TopLevelViewModel command) { - return FallbackCommands.TryGetValue(command.Id, out var enabled) ? enabled : true; + return !FallbackCommands.TryGetValue(command.Id, out var enabled) || enabled; } public void SetFallbackEnabled(TopLevelViewModel command, bool enabled) diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ProviderSettingsViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ProviderSettingsViewModel.cs index 2cde53dd7b..9ee4c5df93 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ProviderSettingsViewModel.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ProviderSettingsViewModel.cs @@ -126,10 +126,7 @@ public partial class ProviderSettingsViewModel( { get { - if (field == null) - { - field = BuildTopLevelViewModels(); - } + field ??= BuildTopLevelViewModels(); return field; } @@ -149,10 +146,7 @@ public partial class ProviderSettingsViewModel( { get { - if (field == null) - { - field = BuildFallbackViewModels(); - } + field ??= BuildFallbackViewModels(); return field; } diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Settings/HotkeySettings.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Settings/HotkeySettings.cs index 7e3d1658eb..d94e29c139 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Settings/HotkeySettings.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Settings/HotkeySettings.cs @@ -146,7 +146,7 @@ public record HotkeySettings// : ICmdLineRepresentable public bool IsValid() { - return IsAccessibleShortcut() ? false : (Alt || Ctrl || Win || Shift) && Code != 0; + return !IsAccessibleShortcut() && (Alt || Ctrl || Win || Shift) && Code != 0; } public bool IsEmpty() diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/SettingsModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/SettingsModel.cs index d238f520ef..51035e3911 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/SettingsModel.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/SettingsModel.cs @@ -60,8 +60,7 @@ public partial class SettingsModel : ObservableObject public ProviderSettings GetProviderSettings(CommandProviderWrapper provider) { - ProviderSettings? settings; - if (!ProviderSettings.TryGetValue(provider.ProviderId, out settings)) + if (!ProviderSettings.TryGetValue(provider.ProviderId, out ProviderSettings? settings)) { settings = new ProviderSettings(provider); settings.Connect(provider);