From fbce93088e410c56c612344fe3dfebede66fb057 Mon Sep 17 00:00:00 2001 From: Simon Curtis <43214378+simon-curtis@users.noreply.github.com> Date: Thu, 30 Oct 2025 20:39:12 +0000 Subject: [PATCH] Added DynamicallyAccessedMembers metadata --- src/Spectre.Console.Cli/AsyncCommandOfT.cs | 2 +- src/Spectre.Console.Cli/CommandOfT.cs | 2 +- src/Spectre.Console.Cli/IConfigurator.cs | 2 +- src/Spectre.Console.Cli/IConfiguratorOfT.cs | 4 ++-- .../Internal/Configuration/Configurator.cs | 2 +- .../Internal/Configuration/ConfiguratorOfT.cs | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Spectre.Console.Cli/AsyncCommandOfT.cs b/src/Spectre.Console.Cli/AsyncCommandOfT.cs index ee5feb5..79a20eb 100644 --- a/src/Spectre.Console.Cli/AsyncCommandOfT.cs +++ b/src/Spectre.Console.Cli/AsyncCommandOfT.cs @@ -4,7 +4,7 @@ namespace Spectre.Console.Cli; /// Base class for an asynchronous command. /// /// The settings type. -public abstract class AsyncCommand : ICommand +public abstract class AsyncCommand<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] TSettings> : ICommand where TSettings : CommandSettings { /// diff --git a/src/Spectre.Console.Cli/CommandOfT.cs b/src/Spectre.Console.Cli/CommandOfT.cs index 45a58ed..7dec179 100644 --- a/src/Spectre.Console.Cli/CommandOfT.cs +++ b/src/Spectre.Console.Cli/CommandOfT.cs @@ -5,7 +5,7 @@ namespace Spectre.Console.Cli; /// /// The settings type. /// -public abstract class Command : ICommand +public abstract class Command<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] TSettings> : ICommand where TSettings : CommandSettings { /// diff --git a/src/Spectre.Console.Cli/IConfigurator.cs b/src/Spectre.Console.Cli/IConfigurator.cs index ec4051c..94cb4ae 100644 --- a/src/Spectre.Console.Cli/IConfigurator.cs +++ b/src/Spectre.Console.Cli/IConfigurator.cs @@ -38,7 +38,7 @@ public IConfigurator SetHelpProvider() /// The command type. /// The name of the command. /// A command configurator that can be used to configure the command further. - ICommandConfigurator AddCommand(string name) + ICommandConfigurator AddCommand<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TCommand>(string name) where TCommand : class, ICommand; /// diff --git a/src/Spectre.Console.Cli/IConfiguratorOfT.cs b/src/Spectre.Console.Cli/IConfiguratorOfT.cs index 7922230..a935d00 100644 --- a/src/Spectre.Console.Cli/IConfiguratorOfT.cs +++ b/src/Spectre.Console.Cli/IConfiguratorOfT.cs @@ -4,7 +4,7 @@ namespace Spectre.Console.Cli; /// Represents a configurator for specific settings. /// /// The command setting type. -public interface IConfigurator +public interface IConfigurator<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] in TSettings> where TSettings : CommandSettings { /// @@ -44,7 +44,7 @@ void SetDefaultCommand() /// The command type. /// The name of the command. /// A command configurator that can be used to configure the command further. - ICommandConfigurator AddCommand(string name) + ICommandConfigurator AddCommand<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TCommand>(string name) where TCommand : class, ICommandLimiter; /// diff --git a/src/Spectre.Console.Cli/Internal/Configuration/Configurator.cs b/src/Spectre.Console.Cli/Internal/Configuration/Configurator.cs index de1de70..7eac255 100644 --- a/src/Spectre.Console.Cli/Internal/Configuration/Configurator.cs +++ b/src/Spectre.Console.Cli/Internal/Configuration/Configurator.cs @@ -49,7 +49,7 @@ public ConfiguredCommand SetDefaultCommand() return DefaultCommand; } - public ICommandConfigurator AddCommand(string name) + public ICommandConfigurator AddCommand<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TCommand>(string name) where TCommand : class, ICommand { var command = Commands.AddAndReturn(ConfiguredCommand.FromType(name, isDefaultCommand: false)); diff --git a/src/Spectre.Console.Cli/Internal/Configuration/ConfiguratorOfT.cs b/src/Spectre.Console.Cli/Internal/Configuration/ConfiguratorOfT.cs index 0b837c3..f13b6e0 100644 --- a/src/Spectre.Console.Cli/Internal/Configuration/ConfiguratorOfT.cs +++ b/src/Spectre.Console.Cli/Internal/Configuration/ConfiguratorOfT.cs @@ -1,6 +1,6 @@ namespace Spectre.Console.Cli; -internal sealed class Configurator : IUnsafeBranchConfigurator, IConfigurator +internal sealed class Configurator<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] TSettings> : IUnsafeBranchConfigurator, IConfigurator where TSettings : CommandSettings { private readonly ConfiguredCommand _command; @@ -36,7 +36,7 @@ public void HideBranch() _command.IsHidden = true; } - public ICommandConfigurator AddCommand(string name) + public ICommandConfigurator AddCommand<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TCommand>(string name) where TCommand : class, ICommandLimiter { var command = ConfiguredCommand.FromType(name, isDefaultCommand: false);