Skip to content

Commit 190867b

Browse files
Renamed result files and created CliSymbolResult base
CommandResult -> CliCommandResultInternal OptionResult -> CliOptionResultInternal ArgumentResult -> CliArgumentResultInternal SymbolResult -> CliSymbolResultInternal ValueResult -> CliValueResult CommandValueResult -> CliCommandResult Created CliSymbolResult as abase class for ValueResult and CommandValueResult
1 parent 5166501 commit 190867b

39 files changed

+319
-308
lines changed

src/System.CommandLine.Extended/Help/HelpOptionAction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public override int Invoke(ParseResult parseResult)
2424
var output = parseResult.Configuration.Output;
2525

2626
var helpContext = new HelpContext(Builder,
27-
parseResult.CommandResult.Command,
27+
parseResult.CommandResultInternal.Command,
2828
output,
2929
parseResult);
3030

src/System.CommandLine.Extended/Invocation/ParseErrorAction.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ private static void WriteHelp(ParseResult parseResult)
6666
// Find the most proximate help option (if any) and invoke its action.
6767
var availableHelpOptions =
6868
parseResult
69-
.CommandResult
70-
.RecurseWhileNotNull(r => r.Parent as CommandResult)
69+
.CommandResultInternal
70+
.RecurseWhileNotNull(r => r.Parent as CommandResultInternal)
7171
.Select(r => r.Command.Options.OfType<HelpOption>().FirstOrDefault());
7272
if (availableHelpOptions.FirstOrDefault(o => o is not null) is { Action: not null } helpOption)
7373
{
@@ -92,7 +92,7 @@ private static void WriteTypoCorrectionSuggestions(ParseResult parseResult)
9292
var token = unmatchedTokens[i];
9393

9494
bool first = true;
95-
foreach (string suggestion in GetPossibleTokens(parseResult.CommandResult.Command, token))
95+
foreach (string suggestion in GetPossibleTokens(parseResult.CommandResultInternal.Command, token))
9696
{
9797
if (first)
9898
{

src/System.CommandLine.Extended/VersionOption.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ private void AddValidators()
4747
{
4848
Validators.Add(static result =>
4949
{
50-
if (result.Parent is CommandResult parent &&
50+
if (result.Parent is CliCommandResultInternal parent &&
5151
parent.Children.Any(r => r is not OptionResult { Option: VersionOption }))
5252
{
5353
result.AddError(LocalizationResources.VersionOptionCannotBeCombinedWithOtherArguments(result.IdentifierToken?.Value ?? result.Option.Name));

src/System.CommandLine.NamingConventionBinder/BindingContextExtensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ private sealed class DummyStateHoldingHandler : BindingHandler
2020
public static BindingContext GetBindingContext(this ParseResult parseResult)
2121
{
2222
// parsing resulted with no handler or it was not created yet, we fake it to just store the BindingContext between the calls
23-
if (parseResult.CommandResult.Command.Action is null)
23+
if (parseResult.CommandResultInternal.Command.Action is null)
2424
{
25-
parseResult.CommandResult.Command.Action = new DummyStateHoldingHandler();
25+
parseResult.CommandResultInternal.Command.Action = new DummyStateHoldingHandler();
2626
}
2727

28-
return ((BindingHandler)parseResult.CommandResult.Command.Action).GetBindingContext(parseResult);
28+
return ((BindingHandler)parseResult.CommandResultInternal.Command.Action).GetBindingContext(parseResult);
2929
}
3030

3131
/// <summary>

src/System.CommandLine.NamingConventionBinder/CommandResultExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace System.CommandLine.NamingConventionBinder;
88
internal static class CommandResultExtensions
99
{
1010
internal static bool TryGetValueForArgument(
11-
this CommandResult commandResult,
11+
this CliCommandResultInternal commandResult,
1212
IValueDescriptor valueDescriptor,
1313
out object? value)
1414
{
@@ -38,7 +38,7 @@ internal static bool TryGetValueForArgument(
3838
}
3939

4040
internal static bool TryGetValueForOption(
41-
this CommandResult commandResult,
41+
this CliCommandResultInternal commandResult,
4242
IValueDescriptor valueDescriptor,
4343
out object? value)
4444
{

src/System.CommandLine.NamingConventionBinder/ParseResultMatchingValueSource.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public bool TryGetValue(
1515
{
1616
if (!string.IsNullOrEmpty(valueDescriptor.ValueName))
1717
{
18-
CommandResult? commandResult = bindingContext?.ParseResult.CommandResult;
18+
CliCommandResultInternal? commandResult = bindingContext?.ParseResult.CommandResultInternal;
1919

2020
while (commandResult is { })
2121
{
@@ -34,7 +34,7 @@ public bool TryGetValue(
3434
return true;
3535
}
3636

37-
commandResult = commandResult.Parent as CommandResult;
37+
commandResult = commandResult.Parent as CliCommandResultInternal;
3838
}
3939
}
4040

src/System.CommandLine.Subsystems/Directives/DiagramSubsystem.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ internal static StringBuilder Diagram(ParseResult parseResult)
6060
/*
6161
private static void Diagram(
6262
StringBuilder builder,
63-
SymbolResult symbolResult,
63+
CliSymbolResultInternal symbolResult,
6464
ParseResult parseResult)
6565
{
66-
if (parseResult.Errors.Any(e => e.SymbolResult == symbolResult))
66+
if (parseResult.Errors.Any(e => e.SymbolResultInternal == symbolResult))
6767
{
6868
builder.Append('!');
6969
}
@@ -155,10 +155,10 @@ private static void Diagram(
155155
}
156156
else
157157
{
158-
builder.Append(((CommandResult)symbolResult).IdentifierToken.Value);
158+
builder.Append(((CliCommandResultInternal)symbolResult).IdentifierToken.Value);
159159
}
160160
161-
foreach (SymbolResult child in symbolResult.SymbolResultTree.GetChildren(symbolResult))
161+
foreach (CliSymbolResultInternal child in symbolResult.SymbolResultTree.GetChildren(symbolResult))
162162
{
163163
if (child is ArgumentResult arg &&
164164
(arg.Argument.ValueType == typeof(bool) ||

src/System.CommandLine.Tests/CommandTests.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ public void Outer_command_is_identified_correctly_by_Parent_property()
4242
var result = _outerCommand.Parse("outer inner --option argument1");
4343

4444
result
45-
.CommandResult
45+
.CommandResultInternal
4646
.Parent
4747
.Should()
48-
.BeOfType<CommandResult>()
48+
.BeOfType<CommandResultInternal>()
4949
.Which
5050
.Command
5151
.Name
@@ -58,9 +58,9 @@ public void Inner_command_is_identified_correctly()
5858
{
5959
var result = _outerCommand.Parse("outer inner --option argument1");
6060

61-
result.CommandResult
61+
result.CommandResultInternal
6262
.Should()
63-
.BeOfType<CommandResult>()
63+
.BeOfType<CommandResultInternal>()
6464
.Which
6565
.Command
6666
.Name
@@ -73,7 +73,7 @@ public void Inner_command_option_is_identified_correctly()
7373
{
7474
var result = _outerCommand.Parse("outer inner --option argument1");
7575

76-
result.CommandResult
76+
result.CommandResultInternal
7777
.Children
7878
.ElementAt(0)
7979
.Should()
@@ -90,7 +90,7 @@ public void Inner_command_option_argument_is_identified_correctly()
9090
{
9191
var result = _outerCommand.Parse("outer inner --option argument1");
9292

93-
result.CommandResult
93+
result.CommandResultInternal
9494
.Children
9595
.ElementAt(0)
9696
.Tokens
@@ -114,14 +114,14 @@ public void Commands_at_multiple_levels_can_have_their_own_arguments()
114114

115115
var result = outer.Parse("outer arg1 inner arg2 arg3");
116116

117-
result.CommandResult
117+
result.CommandResultInternal
118118
.Parent
119119
.Tokens
120120
.Select(t => t.Value)
121121
.Should()
122122
.BeEquivalentTo("arg1");
123123

124-
result.CommandResult
124+
result.CommandResultInternal
125125
.Tokens
126126
.Select(t => t.Value)
127127
.Should()
@@ -200,7 +200,7 @@ public void ParseResult_Command_identifies_innermost_command(string input, strin
200200

201201
var result = outer.Parse(input);
202202

203-
result.CommandResult.Command.Name.Should().Be(expectedCommand);
203+
result.CommandResultInternal.Command.Name.Should().Be(expectedCommand);
204204
}
205205

206206
[Fact]
@@ -214,7 +214,7 @@ public void Commands_can_have_aliases()
214214

215215
var result = command.Parse("that");
216216

217-
result.CommandResult.Command.Should().BeSameAs(command);
217+
result.CommandResultInternal.Command.Should().BeSameAs(command);
218218
result.Errors.Should().BeEmpty();
219219
}
220220

@@ -228,7 +228,7 @@ public void RootCommand_can_have_aliases()
228228

229229
var result = command.Parse("that");
230230

231-
result.CommandResult.Command.Should().BeSameAs(command);
231+
result.CommandResultInternal.Command.Should().BeSameAs(command);
232232
result.Errors.Should().BeEmpty();
233233
}
234234

@@ -245,7 +245,7 @@ public void Subcommands_can_have_aliases()
245245

246246
var result = rootCommand.Parse("that");
247247

248-
result.CommandResult.Command.Should().BeSameAs(subcommand);
248+
result.CommandResultInternal.Command.Should().BeSameAs(subcommand);
249249
result.Errors.Should().BeEmpty();
250250
}
251251

src/System.CommandLine.Tests/CustomParsingTests.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public void Validation_failure_message_can_be_specified_when_parsing_tokens()
9595
new CliRootCommand { argument }.Parse("x")
9696
.Errors
9797
.Should()
98-
.ContainSingle(e => ((ArgumentResult)e.SymbolResult).Argument == argument)
98+
.ContainSingle(e => ((ArgumentResult)e.SymbolResultInternal).Argument == argument)
9999
.Which
100100
.Message
101101
.Should()
@@ -117,7 +117,7 @@ public void Validation_failure_message_can_be_specified_when_evaluating_default_
117117
new CliRootCommand { argument }.Parse("")
118118
.Errors
119119
.Should()
120-
.ContainSingle(e => ((ArgumentResult)e.SymbolResult).Argument == argument)
120+
.ContainSingle(e => ((ArgumentResult)e.SymbolResultInternal).Argument == argument)
121121
.Which
122122
.Message
123123
.Should()
@@ -256,7 +256,7 @@ public void Option_ArgumentResult_parentage_to_root_symbol_is_set_correctly_when
256256
.Parent
257257
.Parent
258258
.Should()
259-
.BeOfType<CommandResult>()
259+
.BeOfType<CliCommandResultInternal>()
260260
.Which
261261
.Command
262262
.Should()
@@ -268,7 +268,7 @@ public void Option_ArgumentResult_parentage_to_root_symbol_is_set_correctly_when
268268
[InlineData("-y value-y -x value-x")]
269269
public void Symbol_can_be_found_without_explicitly_traversing_result_tree(string commandLine)
270270
{
271-
SymbolResult resultForOptionX = null;
271+
CliSymbolResultInternal resultForOptionX = null;
272272
var optionX = new CliOption<string>("-x")
273273
{
274274
CustomParser = _ => string.Empty
@@ -322,7 +322,7 @@ public void Command_ArgumentResult_Parent_is_set_correctly_when_token_is_implici
322322
argumentResult
323323
.Parent
324324
.Should()
325-
.BeOfType<CommandResult>()
325+
.BeOfType<CliCommandResultInternal>()
326326
.Which
327327
.Command
328328
.Should()
@@ -447,7 +447,7 @@ public void Custom_parser_can_check_another_option_result_for_custom_errors(stri
447447
var parseResult = command.Parse(commandLine);
448448

449449
parseResult.Errors
450-
.Single(e => e.SymbolResult is OptionResult optResult &&
450+
.Single(e => e.SymbolResultInternal is OptionResult optResult &&
451451
optResult.Option == optionThatDependsOnOptionWithError)
452452
.Message
453453
.Should()
@@ -482,8 +482,8 @@ public void Validation_reports_all_parse_errors()
482482
OptionResult secondOptionResult = parseResult.GetResult(secondOptionWithError);
483483
secondOptionResult.Errors.Single().Message.Should().Be("second error");
484484

485-
parseResult.Errors.Should().Contain(error => error.SymbolResult == firstOptionResult);
486-
parseResult.Errors.Should().Contain(error => error.SymbolResult == secondOptionResult);
485+
parseResult.Errors.Should().Contain(error => error.SymbolResultInternal == firstOptionResult);
486+
parseResult.Errors.Should().Contain(error => error.SymbolResultInternal == secondOptionResult);
487487
}
488488

489489
[Fact]
@@ -504,7 +504,7 @@ public void When_custom_conversion_fails_then_an_option_does_not_accept_further_
504504

505505
var result = command.Parse("the-command -x nope yep");
506506

507-
result.CommandResult.Tokens.Count.Should().Be(1);
507+
result.CommandResultInternal.Tokens.Count.Should().Be(1);
508508
}
509509

510510
[Fact]

src/System.CommandLine.Tests/ParseResultTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,12 @@ public void Command_will_not_accept_a_command_if_a_sibling_command_has_already_b
9494

9595
var result = CliParser.Parse(command, "outer inner-one inner-two");
9696

97-
result.CommandResult.Command.Name.Should().Be("inner-one");
97+
result.CommandResultInternal.Command.Name.Should().Be("inner-one");
9898
result.Errors.Count.Should().Be(1);
9999

100100
var result2 = CliParser.Parse(command, "outer inner-two inner-one");
101101

102-
result2.CommandResult.Command.Name.Should().Be("inner-two");
102+
result2.CommandResultInternal.Command.Name.Should().Be("inner-two");
103103
result2.Errors.Count.Should().Be(1);
104104
}
105105

0 commit comments

Comments
 (0)