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(
202202 var valueSource = GetValueSource ( bindingSources , bindingContext , valueDescriptor ) ;
203203
204204 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 (
211206 valueDescriptor ,
212207 valueSource ,
213208 out boundValue ) && valueDescriptor . HasDefaultValue )
@@ -240,7 +235,7 @@ private IReadOnlyList<BoundValue> GetValues(
240235 return values ;
241236 }
242237
243- private IValueSource ? GetValueSource (
238+ private IValueSource GetValueSource (
244239 IDictionary < IValueDescriptor , IValueSource > ? bindingSources ,
245240 BindingContext bindingContext ,
246241 IValueDescriptor valueDescriptor )
@@ -263,7 +258,7 @@ private IReadOnlyList<BoundValue> GetValues(
263258 return new ParseResultMatchingValueSource ( ) ;
264259 }
265260
266- return null ;
261+ return new MissingValueSource ( ) ;
267262 }
268263
269264 public override string ToString ( ) =>
You can’t perform that action at this time.
0 commit comments