From 8adf079e0f6920dbcdb26aabebac279b1ddf3c45 Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Mon, 12 Dec 2022 20:54:36 +0100 Subject: [PATCH 1/7] expose Command.Arguments/Options/Subcommands as a mutable List use a custom type that implements IList to ensure that on every added element the parent is set as well --- ...ommandLine_api_is_not_changed.approved.txt | 6 +- src/System.CommandLine/ChildList.cs | 65 +++++++++++++++++++ src/System.CommandLine/Command.cs | 30 +++------ src/System.CommandLine/Help/HelpBuilder.cs | 4 +- .../Parsing/ParseResultVisitor.cs | 4 +- src/System.CommandLine/SymbolExtensions.cs | 2 +- 6 files changed, 82 insertions(+), 29 deletions(-) create mode 100644 src/System.CommandLine/ChildList.cs diff --git a/src/System.CommandLine.ApiCompatibility.Tests/ApiCompatibilityApprovalTests.System_CommandLine_api_is_not_changed.approved.txt b/src/System.CommandLine.ApiCompatibility.Tests/ApiCompatibilityApprovalTests.System_CommandLine_api_is_not_changed.approved.txt index d42c624ad9..5d71a68dd9 100644 --- a/src/System.CommandLine.ApiCompatibility.Tests/ApiCompatibilityApprovalTests.System_CommandLine_api_is_not_changed.approved.txt +++ b/src/System.CommandLine.ApiCompatibility.Tests/ApiCompatibilityApprovalTests.System_CommandLine_api_is_not_changed.approved.txt @@ -49,11 +49,11 @@ System.CommandLine public static Argument AcceptExistingOnly(this Argument argument) public class Command : IdentifierSymbol, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable .ctor(System.String name, System.String description = null) - public System.Collections.Generic.IReadOnlyList Arguments { get; } + public System.Collections.Generic.IList Arguments { get; } public System.Collections.Generic.IEnumerable Children { get; } public ICommandHandler Handler { get; set; } - public System.Collections.Generic.IReadOnlyList