From 1de870a8a8164f1f657490d1be0ba6cb9e5015a4 Mon Sep 17 00:00:00 2001 From: Jordi Adoumie Date: Fri, 13 Sep 2024 09:40:31 -0700 Subject: [PATCH 1/2] tweaking template --- .../Pages/TemplateExtensionPage.cs | 30 +++++++++++ .../TemplateExtensionCommandsProvider.cs | 33 ++++++++++++ .../TemplateExtensionPage.cs | 52 ------------------- 3 files changed, 63 insertions(+), 52 deletions(-) create mode 100644 src/modules/cmdpal/Exts/TemplateExtension/Pages/TemplateExtensionPage.cs create mode 100644 src/modules/cmdpal/Exts/TemplateExtension/TemplateExtensionCommandsProvider.cs delete mode 100644 src/modules/cmdpal/Exts/TemplateExtension/TemplateExtensionPage.cs diff --git a/src/modules/cmdpal/Exts/TemplateExtension/Pages/TemplateExtensionPage.cs b/src/modules/cmdpal/Exts/TemplateExtension/Pages/TemplateExtensionPage.cs new file mode 100644 index 0000000000..acbd925780 --- /dev/null +++ b/src/modules/cmdpal/Exts/TemplateExtension/Pages/TemplateExtensionPage.cs @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation +// 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; +using Microsoft.CmdPal.Extensions; +using Microsoft.CmdPal.Extensions.Helpers; + +namespace TemplateExtension; + +internal sealed partial class TemplateExtensionPage : ListPage +{ + public TemplateExtensionPage() + { + Icon = new(string.Empty); + Name = "TemplateDisplayName"; + } + + public override ISection[] GetItems() + { + return [ + new ListSection() + { + Items = [ + new ListItem(new NoOpCommand()) { Title = "TODO: Implement your extension here" } + ], + } + ]; + } +} diff --git a/src/modules/cmdpal/Exts/TemplateExtension/TemplateExtensionCommandsProvider.cs b/src/modules/cmdpal/Exts/TemplateExtension/TemplateExtensionCommandsProvider.cs new file mode 100644 index 0000000000..2944ae882d --- /dev/null +++ b/src/modules/cmdpal/Exts/TemplateExtension/TemplateExtensionCommandsProvider.cs @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation +// 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; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.CmdPal.Extensions; +using Microsoft.CmdPal.Extensions.Helpers; + +namespace TemplateExtension; + +public partial class TemplateExtensionActionsProvider : ICommandProvider +{ + public string DisplayName => $"TemplateDisplayName Commands"; + + public IconDataType Icon => new(string.Empty); + + private readonly IListItem[] _commands = [ + new ListItem(new TemplateExtensionPage()), + ]; + +#pragma warning disable CA1816 // Dispose methods should call SuppressFinalize + public void Dispose() => throw new NotImplementedException(); +#pragma warning restore CA1816 // Dispose methods should call SuppressFinalize + + public IListItem[] TopLevelCommands() + { + return _commands; + } +} diff --git a/src/modules/cmdpal/Exts/TemplateExtension/TemplateExtensionPage.cs b/src/modules/cmdpal/Exts/TemplateExtension/TemplateExtensionPage.cs deleted file mode 100644 index f743546c04..0000000000 --- a/src/modules/cmdpal/Exts/TemplateExtension/TemplateExtensionPage.cs +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) Microsoft Corporation -// 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; -using Microsoft.CmdPal.Extensions; -using Microsoft.CmdPal.Extensions.Helpers; - -namespace TemplateExtension; - -[System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:File may only contain a single type", Justification = "This is sample code")] -internal sealed partial class TemplateExtensionPage : ListPage -{ - public TemplateExtensionPage() - { - Icon = new(string.Empty); - Name = "TemplateDisplayName"; - } - - public override ISection[] GetItems() - { - return [ - new ListSection() - { - Items = [ - new ListItem(new NoOpCommand()) { Title = "TODO: Implement your extension here" } - ], - } - ]; - } -} - -[System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:File may only contain a single type", Justification = "This is sample code")] -public partial class TemplateExtensionActionsProvider : ICommandProvider -{ - public string DisplayName => $"TemplateDisplayName Commands"; - - public IconDataType Icon => new(string.Empty); - - private readonly IListItem[] _actions = [ - new ListItem(new TemplateExtensionPage()), - ]; - -#pragma warning disable CA1816 // Dispose methods should call SuppressFinalize - public void Dispose() => throw new NotImplementedException(); -#pragma warning restore CA1816 // Dispose methods should call SuppressFinalize - - public IListItem[] TopLevelCommands() - { - return _actions; - } -} From 77e0449b5611464ac6af576c559ae49c7e063cc8 Mon Sep 17 00:00:00 2001 From: Jordi Adoumie Date: Fri, 13 Sep 2024 09:44:59 -0700 Subject: [PATCH 2/2] Adding folder structure to match docs --- .../cmdpal/Exts/TemplateExtension/TemplateExtension.csproj | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/modules/cmdpal/Exts/TemplateExtension/TemplateExtension.csproj b/src/modules/cmdpal/Exts/TemplateExtension/TemplateExtension.csproj index a101b90964..fd6552d2ff 100644 --- a/src/modules/cmdpal/Exts/TemplateExtension/TemplateExtension.csproj +++ b/src/modules/cmdpal/Exts/TemplateExtension/TemplateExtension.csproj @@ -1,4 +1,4 @@ - + WinExe @@ -36,6 +36,11 @@ + + + + +