@@ -20,8 +20,7 @@ public static class ValueConditionAnnotationExtensions
2020 /// <param name="symbol">The option or argument the range applies to.</param>
2121 /// <param name="lowerBound">The lower bound of the range.</param>
2222 /// <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>?
2524 public static void SetRange < TValueSymbol , TValue > ( this TValueSymbol symbol , TValue lowerBound , TValue upperBound )
2625 where TValueSymbol : CliValueSymbol , ICliValueSymbol < TValue >
2726 where TValue : IComparable < TValue >
@@ -40,12 +39,9 @@ public static void SetRange<TValueSymbol, TValue>(this TValueSymbol symbol, TVal
4039 /// <param name="symbol">The option or argument the range applies to.</param>
4140 /// <param name="lowerBound">The <see cref="ValueSource"> that is the lower bound of the range.</param>
4241 /// <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 )
4643 where TValueSymbol : CliValueSymbol , ICliValueSymbol < TValue >
4744 where TValue : IComparable < TValue >
48- // TODO: You should not have to set both...why not nullable?
4945 {
5046 var range = new Range < TValue > ( lowerBound , upperBound ) ;
5147
@@ -68,13 +64,11 @@ public static void SetRange<TValueSymbol, TValue>(this TValueSymbol symbol, Valu
6864 public static void SetInclusiveGroup ( this CliCommand command , IEnumerable < CliValueSymbol > group )
6965 => command . SetValueCondition ( new InclusiveGroup ( group ) ) ;
7066
71- // TODO: This should not be public if ValueConditions are not public
7267 public static void SetValueCondition < TValueSymbol , TValueCondition > ( this TValueSymbol symbol , TValueCondition valueCondition )
7368 where TValueSymbol : CliValueSymbol
7469 where TValueCondition : ValueCondition
7570 => symbol . AddAnnotation ( ValueConditionAnnotations . ValueConditions , valueCondition ) ;
7671
77- // TODO: This should not be public if ValueConditions are not public
7872 public static void SetValueCondition < TCommandCondition > ( this CliCommand symbol , TCommandCondition commandCondition )
7973 where TCommandCondition : CommandCondition
8074 => symbol . AddAnnotation ( ValueConditionAnnotations . ValueConditions , commandCondition ) ;
@@ -84,8 +78,6 @@ public static void SetValueCondition<TCommandCondition>(this CliCommand symbol,
8478 /// </summary>
8579 /// <param name="command">The option or argument to get the conditions for.</param>
8680 /// <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
8981 public static IEnumerable < ValueCondition > EnumerateValueConditions ( this CliValueSymbol symbol )
9082 => symbol . EnumerateAnnotations < ValueCondition > ( ValueConditionAnnotations . ValueConditions ) ;
9183
@@ -94,8 +86,6 @@ public static IEnumerable<ValueCondition> EnumerateValueConditions(this CliValue
9486 /// </summary>
9587 /// <param name="command">The option or argument to get the conditions for.</param>
9688 /// <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
9989 public static IEnumerable < ValueCondition > EnumerateValueConditions ( this AnnotationResolver resolver , CliValueSymbol symbol )
10090 => resolver . Enumerate < ValueCondition > ( symbol , ValueConditionAnnotations . ValueConditions ) ;
10191
@@ -104,8 +94,6 @@ public static IEnumerable<ValueCondition> EnumerateValueConditions(this Annotati
10494 /// </summary>
10595 /// <param name="command">The command to get the conditions for.</param>
10696 /// <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
10997 public static IEnumerable < CommandCondition > EnumerateCommandConditions ( this CliCommand command )
11098 => command . EnumerateAnnotations < CommandCondition > ( ValueConditionAnnotations . ValueConditions ) ;
11199
@@ -125,19 +113,16 @@ public static IEnumerable<CommandCondition> EnumerateCommandConditions(this Anno
125113 /// <typeparam name="TCondition">The type of condition to return.</typeparam>
126114 /// <param name="symbol">The option or argument that may contain the condition.</param>
127115 /// <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
130116 public static TCondition ? GetValueCondition < TCondition > ( this CliValueSymbol symbol )
131117 where TCondition : ValueCondition
132- => symbol . EnumerateValueConditions ( ) . OfType < TCondition > ( ) . LastOrDefault ( ) ;
118+ => symbol . EnumerateValueConditions ( ) . OfType < TCondition > ( ) . FirstOrDefault ( ) ;
133119
134120 /// <summary>
135121 /// Gets the condition that matches the type, if it exists on this command.
136122 /// </summary>
137123 /// <typeparam name="TCondition">The type of condition to return.</typeparam>
138124 /// <param name="symbol">The command that may contain the condition.</param>
139125 /// <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
141126 public static TCondition ? GetCommandCondition < TCondition > ( this CliCommand symbol )
142127 where TCondition : CommandCondition
143128 => symbol . EnumerateCommandConditions ( ) . OfType < TCondition > ( ) . FirstOrDefault ( ) ;
0 commit comments