starting to add IExtension for built-ins

This commit is contained in:
Mike Griese
2025-03-19 08:44:09 -05:00
parent 7f4d85a7f5
commit d791f3527f
2 changed files with 4 additions and 16 deletions

View File

@@ -13,9 +13,6 @@ public class ProviderSettings
[JsonIgnore]
public string ExtensionUniqueId { get; set; } = string.Empty;
[JsonIgnore]
public string Id { get; set; } = string.Empty;
[JsonIgnore]
public string ProviderDisplayName { get; set; } = string.Empty;
@@ -23,7 +20,7 @@ public class ProviderSettings
// public string ProviderId => $"{PackageFamilyName}/{ProviderDisplayName}";
// but I think that's actually a bad idea, because the Display Name can be localized.
[JsonIgnore]
public string ProviderId => $"{ExtensionUniqueId}/{Id}";
public string ProviderId => $"{ExtensionUniqueId}";
[JsonIgnore]
public bool IsBuiltin => string.IsNullOrEmpty(ExtensionUniqueId);
@@ -43,9 +40,9 @@ public class ProviderSettings
{
ExtensionUniqueId = wrapper.Extension?.ExtensionUniqueId ?? string.Empty;
Id = wrapper.Id;
ProviderDisplayName = wrapper.DisplayName;
if (ProviderId == "/")
if (string.IsNullOrEmpty(ProviderId))
{
throw new InvalidDataException("Did you add a built-in command and forget to set the Id? Make sure you do that!");
}

View File

@@ -2,7 +2,6 @@
// 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.Collections.ObjectModel;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.Messaging;
@@ -12,6 +11,7 @@ using Microsoft.CmdPal.UI.ViewModels.Messages;
using Microsoft.CommandPalette.Extensions;
using Microsoft.CommandPalette.Extensions.Toolkit;
using Microsoft.Extensions.DependencyInjection;
using System.Collections.ObjectModel;
namespace Microsoft.CmdPal.UI.ViewModels;
@@ -82,15 +82,6 @@ public partial class TopLevelCommandManager : ObservableObject,
await Task.Factory.StartNew(
() =>
{
// foreach (ICommandItem i in commandProvider.TopLevelItems)
// {
// makeAndAdd(i, false);
// }
// foreach (IFallbackCommandItem i in commandProvider.FallbackItems)
// {
// makeAndAdd(i, true);
// }
lock (TopLevelCommands)
{
foreach (TopLevelViewModel item in commandProvider.TopLevelItems)