Skip to content

Commit 7facb86

Browse files
Merge pull request #2386 from KathleenDollard/parseresult-remove-tokens
Removed tokens from ParseResult
2 parents 4da16b7 + 85b4dbe commit 7facb86

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

src/System.CommandLine.Tests/ParserTests.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,8 @@ public void Relative_order_of_arguments_and_options_within_a_command_does_not_ma
497497
.Excluding(y => y.WhichGetterHas(CSharpAccessModifier.PrivateProtected)));
498498
}
499499

500+
// TODO: Tests tokens which is no longer exposed, and should be replaced by tests of location or removed
501+
/*
500502
[Theory]
501503
[InlineData("--one 1 --many 1 --many 2")]
502504
[InlineData("--one 1 --many 1 --many 2 arg1 arg2")]
@@ -520,6 +522,7 @@ public void Original_order_of_tokens_is_preserved_in_ParseResult_Tokens(string c
520522
521523
result.Tokens.Select(t => t.Value).Should().Equal(rawSplit);
522524
}
525+
*/
523526

524527
/*
525528
[Fact]
@@ -1114,6 +1117,8 @@ public void When_an_option_argument_is_enclosed_in_double_quotes_its_value_retai
11141117
.BeEquivalentTo(new[] { arg2 });
11151118
}
11161119

1120+
// TODO: Tests tokens which is no longer exposed, and should be replaced by tests of location or removed
1121+
/*
11171122
[Fact] // https://github.com/dotnet/command-line-api/issues/1445
11181123
public void Trailing_option_delimiters_are_ignored()
11191124
{
@@ -1136,6 +1141,7 @@ public void Trailing_option_delimiters_are_ignored()
11361141
.Should()
11371142
.BeEquivalentSequenceTo(new[] { "subcommand", "--directory", @"c:\" });
11381143
}
1144+
*/
11391145

11401146
[Theory]
11411147
[InlineData("-x -y")]
@@ -1620,6 +1626,8 @@ public void When_option_arguments_are_greater_than_maximum_arity_then_an_error_i
16201626
.Contain(LocalizationResources.UnrecognizedCommandOrArgument("4"));
16211627
}
16221628

1629+
// TODO: Tests tokens which is no longer exposed, and should be replaced with equivalent test using ParseResult
1630+
/*
16231631
[Fact]
16241632
public void Tokens_are_not_split_if_the_part_before_the_delimiter_is_not_an_option()
16251633
{
@@ -1633,6 +1641,7 @@ public void Tokens_are_not_split_if_the_part_before_the_delimiter_is_not_an_opti
16331641
.BeEquivalentTo("url",
16341642
"jdbc:sqlserver://10.0.0.2;databaseName=main");
16351643
}
1644+
*/
16361645
/*
16371646
[Fact]
16381647
public void A_subcommand_wont_overflow_when_checking_maximum_argument_capacity()

src/System.CommandLine/ParseResult.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ internal ParseResult(
3131
CommandResult rootCommandResult,
3232
CommandResult commandResult,
3333
Dictionary<CliSymbol, ValueResult> valueResults,
34+
/*
3435
List<CliToken> tokens,
36+
*/
3537
// TODO: unmatched tokens
3638
// List<CliToken>? unmatchedTokens,
3739
List<ParseError>? errors,
@@ -53,7 +55,7 @@ internal ParseResult(
5355
_action = action;
5456
_preActions = preActions;
5557
*/
56-
58+
/*
5759
// skip the root command when populating Tokens property
5860
if (tokens.Count > 1)
5961
{
@@ -67,6 +69,7 @@ internal ParseResult(
6769
{
6870
Tokens = Array.Empty<CliToken>();
6971
}
72+
*/
7073

7174
CommandLineText = commandLineText;
7275

@@ -101,12 +104,14 @@ internal ParseResult(
101104
/// </summary>
102105
public IReadOnlyList<ParseError> Errors { get; }
103106

107+
/*
104108
// TODO: don't expose tokens
105109
// TODO: This appears to be set, but only read during testing. Consider removing.
106110
/// <summary>
107111
/// Gets the tokens identified while parsing command line input.
108112
/// </summary>
109113
internal IReadOnlyList<CliToken> Tokens { get; }
114+
*/
110115

111116
// TODO: This appears to be set, but never used. Consider removing.
112117
/// <summary>

src/System.CommandLine/Parsing/ParseOperation.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ internal ParseResult Parse()
8686
_rootCommandResult,
8787
_innermostCommandResult,
8888
_rootCommandResult.SymbolResultTree.GetValueResultDictionary(),
89+
/*
8990
_tokens,
91+
*/
9092
// TODO: unmatched tokens
9193
// _symbolResultTree.UnmatchedTokens,
9294
_symbolResultTree.Errors,

0 commit comments

Comments
 (0)