-
Notifications
You must be signed in to change notification settings - Fork 401
SetHandler improvements #1729
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SetHandler improvements #1729
Changes from all commits
1932b9d
5647304
7459400
69d0d30
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -287,7 +287,7 @@ internal static (BoundValue? boundValue, bool usedNonDefault) GetBoundValue( | |
{ | ||
if (valueDescriptor.HasDefaultValue) | ||
{ | ||
return (BoundValue.DefaultForValueDescriptor(valueDescriptor), false); | ||
return (DefaultForValueDescriptor(valueDescriptor, bindingContext), false); | ||
} | ||
|
||
if (valueDescriptor.ValueType != parentType) // Recursive models aren't allowed | ||
|
@@ -312,12 +312,26 @@ internal static (BoundValue? boundValue, bool usedNonDefault) GetBoundValue( | |
return (new BoundValue(parameterDescriptor.GetDefaultValue(), valueDescriptor, valueSource), false); | ||
} | ||
|
||
return (BoundValue.DefaultForValueDescriptor(valueDescriptor), false); | ||
return (DefaultForValueDescriptor(valueDescriptor, bindingContext), false); | ||
} | ||
|
||
return (null, false); | ||
} | ||
|
||
private static BoundValue DefaultForValueDescriptor( | ||
IValueDescriptor valueDescriptor, | ||
BindingContext context) | ||
{ | ||
var valueSource = ValueDescriptorDefaultValueSource.Instance; | ||
|
||
valueSource.TryGetValue(valueDescriptor, context, out var value); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we care about the case where |
||
|
||
return new BoundValue( | ||
value, | ||
valueDescriptor, | ||
valueSource); | ||
} | ||
|
||
private protected IValueDescriptor FindModelPropertyDescriptor(Type propertyType, string propertyName) | ||
{ | ||
return ModelDescriptor.PropertyDescriptors | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,7 +44,7 @@ public async Task Sets_output_mode_to_Ansi_when_specified_by_output_directive(Ou | |
OutputMode detectedOutputMode = OutputMode.Auto; | ||
|
||
var command = new Command("hello"); | ||
command.SetHandler((InvocationContext ctx) => | ||
command.SetHandler(ctx => | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's really nice for the simple handlers to be naturally-typed here (and in the other 1000 callsites in this PR) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed. Settling on |
||
{ | ||
detectedOutputMode = ctx.Console.DetectOutputMode(); | ||
return Task.FromResult(0); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I dislike
var
here as it is not clear what the type ofvalue
is.