File tree Expand file tree Collapse file tree 2 files changed +17
-8
lines changed
src/System.CommandLine/Binding Expand file tree Collapse file tree 2 files changed +17
-8
lines changed Original file line number Diff line number Diff line change
1
+ // Copyright (c) .NET Foundation and contributors. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ namespace System . CommandLine . Binding
5
+ {
6
+ internal class MissingValueSource : IValueSource
7
+ {
8
+ public bool TryGetValue ( IValueDescriptor valueDescriptor , BindingContext ? bindingContext , out object ? boundValue )
9
+ {
10
+ boundValue = null ;
11
+ return false ;
12
+ }
13
+ }
14
+ }
Original file line number Diff line number Diff line change @@ -202,12 +202,7 @@ private IReadOnlyList<BoundValue> GetValues(
202
202
var valueSource = GetValueSource ( bindingSources , bindingContext , valueDescriptor ) ;
203
203
204
204
BoundValue ? boundValue ;
205
- if ( valueSource is null )
206
- {
207
- // If there is no source to bind from, no value can be bound.
208
- boundValue = null ;
209
- }
210
- else if ( ! bindingContext . TryBindToScalarValue (
205
+ if ( ! bindingContext . TryBindToScalarValue (
211
206
valueDescriptor ,
212
207
valueSource ,
213
208
out boundValue ) && valueDescriptor . HasDefaultValue )
@@ -240,7 +235,7 @@ private IReadOnlyList<BoundValue> GetValues(
240
235
return values ;
241
236
}
242
237
243
- private IValueSource ? GetValueSource (
238
+ private IValueSource GetValueSource (
244
239
IDictionary < IValueDescriptor , IValueSource > ? bindingSources ,
245
240
BindingContext bindingContext ,
246
241
IValueDescriptor valueDescriptor )
@@ -263,7 +258,7 @@ private IReadOnlyList<BoundValue> GetValues(
263
258
return new ParseResultMatchingValueSource ( ) ;
264
259
}
265
260
266
- return null ;
261
+ return new MissingValueSource ( ) ;
267
262
}
268
263
269
264
public override string ToString ( ) =>
You can’t perform that action at this time.
0 commit comments