From 5a366b523b931aa1bbbfe3b8785f1e09fbc2923a Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Tue, 10 Dec 2024 17:43:50 -0600 Subject: [PATCH] okay, so yes, if an extension implements this by crashing, we'll throw an exception, that makes sense --- .../Exts/MastodonExtension/MastodonExtensionPage.cs | 10 ++++------ .../Microsoft.CmdPal.Extensions.Helpers/Form.cs | 10 +++++----- .../Microsoft.CmdPal.Extensions.Helpers/FormPage.cs | 4 ++-- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/modules/cmdpal/Exts/MastodonExtension/MastodonExtensionPage.cs b/src/modules/cmdpal/Exts/MastodonExtension/MastodonExtensionPage.cs index 030cc8c67a..9770d82100 100644 --- a/src/modules/cmdpal/Exts/MastodonExtension/MastodonExtensionPage.cs +++ b/src/modules/cmdpal/Exts/MastodonExtension/MastodonExtensionPage.cs @@ -148,7 +148,7 @@ public partial class MastodonExtensionActionsProvider : CommandProvider } [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:File may only contain a single type", Justification = "This is sample code")] -public partial class MastodonPostForm : IForm +public partial class MastodonPostForm : Form { private readonly MastodonStatus post; @@ -157,7 +157,7 @@ public partial class MastodonPostForm : IForm this.post = post; } - public string DataJson() + public override string DataJson() { return $$""" { @@ -171,11 +171,9 @@ public partial class MastodonPostForm : IForm """; } - public string StateJson() => throw new NotImplementedException(); + public override ICommandResult SubmitForm(string payload) => CommandResult.Dismiss(); - public ICommandResult SubmitForm(string payload) => CommandResult.Dismiss(); - - public string TemplateJson() + public override string TemplateJson() { var img_block = string.Empty; if (post.MediaAttachments.Count > 0) diff --git a/src/modules/cmdpal/extensionsdk/Microsoft.CmdPal.Extensions.Helpers/Form.cs b/src/modules/cmdpal/extensionsdk/Microsoft.CmdPal.Extensions.Helpers/Form.cs index f2f5eeb739..986e3d2ee7 100644 --- a/src/modules/cmdpal/extensionsdk/Microsoft.CmdPal.Extensions.Helpers/Form.cs +++ b/src/modules/cmdpal/extensionsdk/Microsoft.CmdPal.Extensions.Helpers/Form.cs @@ -4,13 +4,13 @@ namespace Microsoft.CmdPal.Extensions.Helpers; -public class Form : IForm +public abstract class Form : IForm { - public string Data { get; set; } = string.Empty; + public virtual string Data { get; set; } = string.Empty; - public string State { get; set; } = string.Empty; + public virtual string State { get; set; } = string.Empty; - public string Template { get; set; } = string.Empty; + public virtual string Template { get; set; } = string.Empty; public virtual string DataJson() => Data; @@ -18,5 +18,5 @@ public class Form : IForm public virtual string TemplateJson() => Template; - public virtual ICommandResult SubmitForm(string payload) => throw new NotImplementedException(); + public abstract ICommandResult SubmitForm(string payload); } diff --git a/src/modules/cmdpal/extensionsdk/Microsoft.CmdPal.Extensions.Helpers/FormPage.cs b/src/modules/cmdpal/extensionsdk/Microsoft.CmdPal.Extensions.Helpers/FormPage.cs index f0e556e209..6ddf62aaf6 100644 --- a/src/modules/cmdpal/extensionsdk/Microsoft.CmdPal.Extensions.Helpers/FormPage.cs +++ b/src/modules/cmdpal/extensionsdk/Microsoft.CmdPal.Extensions.Helpers/FormPage.cs @@ -4,7 +4,7 @@ namespace Microsoft.CmdPal.Extensions.Helpers; -public partial class FormPage : Page, IFormPage +public abstract partial class FormPage : Page, IFormPage { - public virtual IForm[] Forms() => throw new NotImplementedException(); + public abstract IForm[] Forms(); }