Skip to content

Commit 5398b09

Browse files
Made SymbolResult internal
1 parent 0933deb commit 5398b09

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ internal static StringBuilder Diagram(ParseResult parseResult)
5757
return builder;
5858
}
5959

60+
/*
6061
private static void Diagram(
6162
StringBuilder builder,
6263
SymbolResult symbolResult,
@@ -66,7 +67,7 @@ private static void Diagram(
6667
{
6768
builder.Append('!');
6869
}
69-
70+
*/
7071
// TODO: Directives
7172
/*
7273
switch (symbolResult)
@@ -176,6 +177,6 @@ private static void Diagram(
176177
}
177178
}
178179
}
179-
*/
180180
}
181+
*/
181182
}

src/System.CommandLine/Parsing/ParseError.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public sealed class ParseError
1010
{
1111
// TODO: add position
1212
// TODO: reevaluate whether we should be exposing a SymbolResult here
13-
public ParseError(
13+
internal ParseError(
1414
string message,
1515
SymbolResult? symbolResult = null)
1616
{
@@ -20,18 +20,33 @@ public ParseError(
2020
}
2121

2222
Message = message;
23+
/*
2324
SymbolResult = symbolResult;
25+
*/
26+
}
27+
28+
public ParseError(
29+
string message)
30+
{
31+
if (string.IsNullOrWhiteSpace(message))
32+
{
33+
throw new ArgumentException("Value cannot be null or whitespace.", nameof(message));
34+
}
35+
36+
Message = message;
2437
}
2538

2639
/// <summary>
2740
/// A message to explain the error to a user.
2841
/// </summary>
2942
public string Message { get; }
3043

44+
/* Consider how results are attached to errors now that we have ValueResult and CommandValueResult. Should there be a common base?
3145
/// <summary>
3246
/// The symbol result detailing the symbol that failed to parse and the tokens involved.
3347
/// </summary>
3448
public SymbolResult? SymbolResult { get; }
49+
*/
3550

3651
/// <inheritdoc />
3752
public override string ToString() => Message;

src/System.CommandLine/Parsing/SymbolResult.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace System.CommandLine.Parsing
88
/// <summary>
99
/// A result produced during parsing for a specific symbol.
1010
/// </summary>
11-
public abstract class SymbolResult
11+
internal abstract class SymbolResult
1212
{
1313
// TODO: make this a property and protected if possible
1414
internal readonly SymbolResultTree SymbolResultTree;
@@ -72,12 +72,14 @@ public IEnumerable<ParseError> Errors
7272
/// <returns>An argument result if the argument was matched by the parser or has a default value; otherwise, <c>null</c>.</returns>
7373
internal ArgumentResult? GetResult(CliArgument argument) => SymbolResultTree.GetResult(argument);
7474

75+
/* Not used
7576
/// <summary>
7677
/// Finds a result for the specific command anywhere in the parse tree, including parent and child symbol results.
7778
/// </summary>
7879
/// <param name="command">The command for which to find a result.</param>
7980
/// <returns>An command result if the command was matched by the parser; otherwise, <c>null</c>.</returns>
8081
internal CommandResult? GetResult(CliCommand command) => SymbolResultTree.GetResult(command);
82+
*/
8183

8284
/// <summary>
8385
/// Finds a result for the specific option anywhere in the parse tree, including parent and child symbol results.
@@ -103,6 +105,7 @@ public IEnumerable<ParseError> Errors
103105
public SymbolResult? GetResult(string name) =>
104106
SymbolResultTree.GetResult(name);
105107

108+
/* Not used
106109
/// <inheritdoc cref="ParseResult.GetValue{T}(CliArgument{T})"/>
107110
public T? GetValue<T>(CliArgument<T> argument)
108111
{
@@ -126,6 +129,7 @@ public IEnumerable<ParseError> Errors
126129
127130
return CliArgument<T>.CreateDefaultValue();
128131
}
132+
*/
129133

130134
/// <summary>
131135
/// Gets the value for a symbol having the specified name anywhere in the parse tree.

0 commit comments

Comments
 (0)