-
Notifications
You must be signed in to change notification settings - Fork 543
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
Add AddParameter overloads that take a constant and a ParameterDefault #5529
Conversation
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.
This LGTM. Thanks for the contribution, @davidebbo!
@DamianEdwards @davidfowl @mitchdenny - any other thoughts?
// An alternate implementation is to use some ConstantParameterDefault implementation that always returns the default value. | ||
// However, doing this causes a "default": {} to be written to the manifest, which is not valid. | ||
// And note that we ignore parameterDefault in the callback, because it can never be non-null, and we want our own default. | ||
return builder.AddParameter(name, parameterDefault => builder.Configuration[$"Parameters:{name}"] ?? defaultValue, secret: secret); |
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.
I'm struggling with this one. Why is defaultValue a fallback instead of an override?
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.
It's the "default value". I.e. "if no one else supplied a value - use this one".
We would call it string value
, if we wanted to always win.
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.
fallback value?
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.
Sounds like a continuation of your earlier conversation: #4429 (comment). And frankly, I'm a bit confused about the comment there that says that "code wins". To me, "config wins", and the code is a fall back, which is what my code is doing.
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.
In C#, when you have "optional arguments", the value that is used if you don't supply a value to the argument is called a "default value":
Each optional parameter has a default value as part of its definition. If no argument is sent for that parameter, the default value is used.
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.
In C#, when you have "optional arguments", the value that is used if you don't supply a value to the argument is called a "default value"
Right, though this is quite different from our situation here, where the value can come from two completely different systems (config vs code). Here, I could see fallbackValue
as a reasonable name, though I don't think defaultValue
is so bad either.
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.
Started Discord thread to make it easier to discuss: https://discord.com/channels/732297728826277939/1281287950491193436
Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
Description
See #5410 for details.
Fixes #5410
Checklist
<remarks />
and<code />
elements on your triple slash comments?Microsoft Reviewers: Open in CodeFlow