Skip to content

Commit f14d7d0

Browse files
Respond to review
1 parent b2c13b7 commit f14d7d0

21 files changed

+210
-56
lines changed

src/System.CommandLine.Subsystems/Subsystems/Annotations/ValueAnnotations.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
namespace System.CommandLine.Subsystems.Annotations;
55

66
/// <summary>
7-
/// IDs for well-known Version annotations.
7+
/// IDs for well-known Default Value annotations.
88
/// </summary>
99
public static class ValueAnnotations
1010
{
@@ -16,7 +16,7 @@ public static class ValueAnnotations
1616
public static AnnotationId DefaultValueSource { get; } = new(Prefix, nameof(DefaultValueSource));
1717

1818
/// <summary>
19-
/// Default value for an option or argument
19+
/// Default default value for an option or argument
2020
/// </summary>
2121
/// <remarks>
2222
/// Should be the same type as the type parameter of
@@ -26,7 +26,7 @@ public static class ValueAnnotations
2626

2727

2828
/// <summary>
29-
/// Default value calculation for an option or argument
29+
/// Default default value calculation for an option or argument
3030
/// </summary>
3131
/// <remarks>
3232
/// Please use the extension methods and do not call this directly.

src/System.CommandLine.Subsystems/Subsystems/Annotations/ValueConditionAnnotations.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
namespace System.CommandLine.Subsystems.Annotations;
55

66
/// <summary>
7-
/// IDs for well-known Version annotations.
7+
/// IDs for well-known Value Condition annotations.
88
/// </summary>
99
public static class ValueConditionAnnotations
1010
{

src/System.CommandLine.Subsystems/Subsystems/CliSubsystem.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ protected internal bool TryGetAnnotation(CliSymbol symbol, AnnotationId annotati
108108
/// </summary>
109109
/// <param name="pipelineResult">The context contains data like the ParseResult, and allows setting of values like whether execution was handled and the CLI should terminate </param>
110110
/// <returns>A PipelineResult object with information such as whether the CLI should terminate</returns>
111+
// These methods are public to support use of subsystems without the pipeline
111112
public virtual void Execute(PipelineResult pipelineResult)
112113
=> pipelineResult.NotRun(pipelineResult.ParseResult);
113114

src/System.CommandLine.Subsystems/Validation/CommandValidator.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,20 @@
55

66
namespace System.CommandLine.Validation;
77

8+
/// <summary>
9+
/// Base class for validators that affect the entire command
10+
/// </summary>
811
public abstract class CommandValidator : Validator
912
{
1013
protected CommandValidator(string name, Type valueConditionType, params Type[] moreValueConditionTypes)
1114
: base(name, valueConditionType, moreValueConditionTypes)
1215
{ }
1316

17+
/// <summary>
18+
/// Validation method specific to command results.
19+
/// </summary>
20+
/// <param name="commandResult">The <see cref="CliCommandResult" that will be validated./></param>
21+
/// <param name="commandCondition">The <see cref="CommandCondition" that defines the condition that may be validatable./></param>
22+
/// <param name="validationContext">The <see cref="ValidationContext" containing information about the current context./></param>
1423
public abstract void Validate(CliCommandResult commandResult, CommandCondition commandCondition, ValidationContext validationContext);
1524
}

src/System.CommandLine.Subsystems/Validation/ICommandValidator.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,18 @@
55

66
namespace System.CommandLine.Validation;
77

8+
/// <summary>
9+
/// Interface that allows non-Validator derived methods to perform validation. Specifically, this supports
10+
/// <see cref="CommandCondition"/> instances that can validate.
11+
/// </summary>
812
public interface ICommandValidator
913
{
10-
14+
/// <summary>
15+
/// Validation method specific to command results
16+
/// </summary>
17+
/// <param name="commandResult">The <see cref="CliCommandResult" that will be validated./></param>
18+
/// <param name="commandCondition">The <see cref="CommandCondition" that defines the condition that may be validatable./></param>
19+
/// <param name="validationContext">The <see cref="ValidationContext" containing information about the current context./></param>
1120
void Validate(CliCommandResult commandResult, CommandCondition commandCondition, ValidationContext validationContext);
1221
}
1322

src/System.CommandLine.Subsystems/Validation/IValueValidator.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,21 @@
55

66
namespace System.CommandLine.Validation;
77

8+
/// <summary>
9+
/// Interface that allows non-Validator derived methods to perform validation. Specifically, this supports
10+
/// <see cref="CommandCondition"/> instances that can validate.
11+
/// </summary>
812
public interface IValueValidator
913
{
14+
// Note: We pass both valueSymbol and valueResult, because we may validate symbols where valueResult is null.
15+
/// <summary>
16+
/// Validation method specific to value results.
17+
/// </summary>
18+
/// <param name="value">The value to validate.</param>
19+
/// <param name="valueSymbol">The <see cref="CliValueSymbol"/> of the value to validate.</param>
20+
/// <param name="valueResult">The <see cref="CliValueResult"/> of the value to validate.</param>
21+
/// <param name="valueCondition">The <see cref="ValueCondition" that defines the condition that may be validatable.</param>
22+
/// <param name="validationContext">The <see cref="ValidationContext" containing information about the current context./></param>
1023
void Validate(object? value, CliValueSymbol valueSymbol,
1124
CliValueResult? valueResult, ValueCondition valueCondition, ValidationContext validationContext);
1225
}

src/System.CommandLine.Subsystems/Validation/InclusiveGroupValidator.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@
66

77
namespace System.CommandLine.Validation;
88

9+
/// <summary>
10+
/// Validator that requires that if one member of the group is present, they are all present.
11+
/// </summary>
912
public class InclusiveGroupValidator : CommandValidator
1013
{
1114
public InclusiveGroupValidator() : base(nameof(InclusiveGroup), typeof(InclusiveGroup))
1215
{ }
1316

17+
/// <inheritdoc/>
1418
public override void Validate(CliCommandResult commandResult,
1519
CommandCondition valueCondition, ValidationContext validationContext)
1620
{

src/System.CommandLine.Subsystems/Validation/RangeValidator.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@
55

66
namespace System.CommandLine.Validation;
77

8+
/// <summary>
9+
/// Validates that a value is within the specified bounds.
10+
/// </summary>
811
public class RangeValidator : ValueValidator, IValueValidator
912
{
1013
public RangeValidator() : base(nameof(ValueConditions.Range), typeof(ValueConditions.Range))
1114
{ }
1215

16+
/// <inheritdoc/>
1317
public override void Validate(object? value, CliValueSymbol valueSymbol,
1418
CliValueResult? valueResult, ValueCondition valueCondition, ValidationContext validationContext)
1519
{

src/System.CommandLine.Subsystems/Validation/ValidationContext.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
namespace System.CommandLine.Validation;
55

6+
// TODO: Remove this class. All of the things it contains are in the PipelineResult, except the ValidationSubsystem currently
7+
// running, if there are multiple. The scenario where that is needed seems unlikely.
68
public class ValidationContext
79
{
810
public ValidationContext(PipelineResult pipelineResult, ValidationSubsystem validationSubsystem)

src/System.CommandLine.Subsystems/Validation/Validator.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
namespace System.CommandLine.Validation;
66

7+
// TODO: This may be removed if we settle on ValueCondition validation only.
8+
/// <summary>
9+
/// Base class for CommandValidator and ValueValidator.
10+
/// </summary>
711
public abstract class Validator
812
{
913
public Validator(string name, Type valueConditionType, params Type[] moreValueConditionTypes)

0 commit comments

Comments
 (0)