@@ -20,8 +20,7 @@ public static class ValueConditionAnnotationExtensions
20
20
/// <param name="symbol">The option or argument the range applies to.</param>
21
21
/// <param name="lowerBound">The lower bound of the range.</param>
22
22
/// <param name="upperBound">The upper bound of the range.</param>
23
- // TODO: Add RangeBounds
24
- // TODO: You should not have to set both...why not nullable?
23
+ // TODO: can we eliminate this overload and just reply on the implicit cast to ValueSource<TValue>?
25
24
public static void SetRange < TValueSymbol , TValue > ( this TValueSymbol symbol , TValue lowerBound , TValue upperBound )
26
25
where TValueSymbol : CliValueSymbol , ICliValueSymbol < TValue >
27
26
where TValue : IComparable < TValue >
@@ -40,12 +39,9 @@ public static void SetRange<TValueSymbol, TValue>(this TValueSymbol symbol, TVal
40
39
/// <param name="symbol">The option or argument the range applies to.</param>
41
40
/// <param name="lowerBound">The <see cref="ValueSource"> that is the lower bound of the range.</param>
42
41
/// <param name="upperBound">The <see cref="ValueSource"> that is the upper bound of the range.</param>
43
- // TODO: Add RangeBounds
44
- // TODO: You should not have to set both...why not nullable?
45
- public static void SetRange < TValueSymbol , TValue > ( this TValueSymbol symbol , ValueSource < TValue > lowerBound , ValueSource < TValue > upperBound )
42
+ public static void SetRange < TValueSymbol , TValue > ( this TValueSymbol symbol , ValueSource < TValue > ? lowerBound , ValueSource < TValue > ? upperBound )
46
43
where TValueSymbol : CliValueSymbol , ICliValueSymbol < TValue >
47
44
where TValue : IComparable < TValue >
48
- // TODO: You should not have to set both...why not nullable?
49
45
{
50
46
var range = new Range < TValue > ( lowerBound , upperBound ) ;
51
47
@@ -68,13 +64,11 @@ public static void SetRange<TValueSymbol, TValue>(this TValueSymbol symbol, Valu
68
64
public static void SetInclusiveGroup ( this CliCommand command , IEnumerable < CliValueSymbol > group )
69
65
=> command . SetValueCondition ( new InclusiveGroup ( group ) ) ;
70
66
71
- // TODO: This should not be public if ValueConditions are not public
72
67
public static void SetValueCondition < TValueSymbol , TValueCondition > ( this TValueSymbol symbol , TValueCondition valueCondition )
73
68
where TValueSymbol : CliValueSymbol
74
69
where TValueCondition : ValueCondition
75
70
=> symbol . AddAnnotation ( ValueConditionAnnotations . ValueConditions , valueCondition ) ;
76
71
77
- // TODO: This should not be public if ValueConditions are not public
78
72
public static void SetValueCondition < TCommandCondition > ( this CliCommand symbol , TCommandCondition commandCondition )
79
73
where TCommandCondition : CommandCondition
80
74
=> symbol . AddAnnotation ( ValueConditionAnnotations . ValueConditions , commandCondition ) ;
@@ -84,8 +78,6 @@ public static void SetValueCondition<TCommandCondition>(this CliCommand symbol,
84
78
/// </summary>
85
79
/// <param name="command">The option or argument to get the conditions for.</param>
86
80
/// <returns>The conditions that have been applied to the option or argument.</returns>
87
- ///
88
- // TODO: This is public because it will be used by other subsystems we might not own. It could be an extension method the subsystem namespace
89
81
public static IEnumerable < ValueCondition > EnumerateValueConditions ( this CliValueSymbol symbol )
90
82
=> symbol . EnumerateAnnotations < ValueCondition > ( ValueConditionAnnotations . ValueConditions ) ;
91
83
@@ -94,8 +86,6 @@ public static IEnumerable<ValueCondition> EnumerateValueConditions(this CliValue
94
86
/// </summary>
95
87
/// <param name="command">The option or argument to get the conditions for.</param>
96
88
/// <returns>The conditions that have been applied to the option or argument.</returns>
97
- ///
98
- // TODO: This is public because it will be used by other subsystems we might not own. It could be an extension method the subsystem namespace
99
89
public static IEnumerable < ValueCondition > EnumerateValueConditions ( this AnnotationResolver resolver , CliValueSymbol symbol )
100
90
=> resolver . Enumerate < ValueCondition > ( symbol , ValueConditionAnnotations . ValueConditions ) ;
101
91
@@ -104,8 +94,6 @@ public static IEnumerable<ValueCondition> EnumerateValueConditions(this Annotati
104
94
/// </summary>
105
95
/// <param name="command">The command to get the conditions for.</param>
106
96
/// <returns>The conditions that have been applied to the command.</returns>
107
- ///
108
- // TODO: This is public because it will be used by other subsystems we might not own. It could be an extension method the subsystem namespace
109
97
public static IEnumerable < CommandCondition > EnumerateCommandConditions ( this CliCommand command )
110
98
=> command . EnumerateAnnotations < CommandCondition > ( ValueConditionAnnotations . ValueConditions ) ;
111
99
@@ -125,19 +113,16 @@ public static IEnumerable<CommandCondition> EnumerateCommandConditions(this Anno
125
113
/// <typeparam name="TCondition">The type of condition to return.</typeparam>
126
114
/// <param name="symbol">The option or argument that may contain the condition.</param>
127
115
/// <returns>The condition if it exists on the option or argument, otherwise null.</returns>
128
- // This method feels useful because it clarifies that last should win and returns one, when only one should be applied
129
- // TODO: Consider removing user facing naming, other than the base type, that is Value or CommandCondition and just use Condition
130
116
public static TCondition ? GetValueCondition < TCondition > ( this CliValueSymbol symbol )
131
117
where TCondition : ValueCondition
132
- => symbol . EnumerateValueConditions ( ) . OfType < TCondition > ( ) . LastOrDefault ( ) ;
118
+ => symbol . EnumerateValueConditions ( ) . OfType < TCondition > ( ) . FirstOrDefault ( ) ;
133
119
134
120
/// <summary>
135
121
/// Gets the condition that matches the type, if it exists on this command.
136
122
/// </summary>
137
123
/// <typeparam name="TCondition">The type of condition to return.</typeparam>
138
124
/// <param name="symbol">The command that may contain the condition.</param>
139
125
/// <returns>The condition if it exists on the command, otherwise null.</returns>
140
- // This method feels useful because it clarifies that last should win and returns one, when only one should be applied
141
126
public static TCondition ? GetCommandCondition < TCondition > ( this CliCommand symbol )
142
127
where TCondition : CommandCondition
143
128
=> symbol . EnumerateCommandConditions ( ) . OfType < TCondition > ( ) . FirstOrDefault ( ) ;
0 commit comments