From 2a893ea8537cc180f37db8075ea4f8e38f183d82 Mon Sep 17 00:00:00 2001 From: Velvet Toroyashi <42438262+VelvetToroyashi@users.noreply.github.com> Date: Mon, 11 Aug 2025 15:59:02 -0400 Subject: [PATCH 1/2] fix: Don't ammend self to parent's collection. The parameter list remains internal (visible) for purposes of allowing CommandShape to access its list. This should *probably* be publicly exposed as `IReadOnlyList` as per proper API standards. --- Remora.Commands/Builders/CommandParameterBuilder.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Remora.Commands/Builders/CommandParameterBuilder.cs b/Remora.Commands/Builders/CommandParameterBuilder.cs index 601e481..c0093cf 100644 --- a/Remora.Commands/Builders/CommandParameterBuilder.cs +++ b/Remora.Commands/Builders/CommandParameterBuilder.cs @@ -60,10 +60,8 @@ public CommandParameterBuilder(CommandBuilder builder, Type type) { _name = string.Empty; _builder = builder; - _attributes = new(); - _conditions = new(); - builder.Parameters.Add(this); - + _attributes = []; + _conditions = []; _parameterType = type; } From 3727310f118024ad91ad2834c0cd4bfea00c8f87 Mon Sep 17 00:00:00 2001 From: Velvet Toroyashi <42438262+VelvetToroyashi@users.noreply.github.com> Date: Mon, 11 Aug 2025 16:08:56 -0400 Subject: [PATCH 2/2] fix(tests): Update tests according to new API behavior --- .../Builders/CommandBuilderTests.cs | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Tests/Remora.Commands.Tests/Builders/CommandBuilderTests.cs b/Tests/Remora.Commands.Tests/Builders/CommandBuilderTests.cs index 3495045..c724f82 100644 --- a/Tests/Remora.Commands.Tests/Builders/CommandBuilderTests.cs +++ b/Tests/Remora.Commands.Tests/Builders/CommandBuilderTests.cs @@ -65,11 +65,11 @@ public void CanBuildParameterizedCommand() var commandBuilder = new CommandBuilder() .WithName("test") .WithInvocation((_, _, _) => default) - .WithDescription("A test command."); - - _ = new CommandParameterBuilder(commandBuilder, typeof(string)) - .WithName("test") - .WithDescription("A test parameter."); + .WithDescription("A test command.") + .AddParameter(typeof(string)) + .WithName("test") + .WithDescription("A test parameter.") + .Finish(); var command = commandBuilder.Build(rootNode); @@ -90,15 +90,15 @@ public void CanBuildParameterizedCommandWithMultipleParameters() var commandBuilder = new CommandBuilder() .WithName("test") .WithInvocation((_, _, _) => default) - .WithDescription("A test command."); - - _ = new CommandParameterBuilder(commandBuilder, typeof(string)) - .WithName("test") - .WithDescription("A test parameter."); - - _ = new CommandParameterBuilder(commandBuilder, typeof(int)) - .WithName("test2") - .WithDescription("A second test parameter."); + .WithDescription("A test command.") + .AddParameter(typeof(string)) + .WithName("test") + .WithDescription("A test parameter.") + .Finish() + .AddParameter(typeof(int)) + .WithName("test2") + .WithDescription("A second test parameter.") + .Finish(); var command = commandBuilder.Build(rootNode);