-
Notifications
You must be signed in to change notification settings - Fork 399
Value handling cleanup #2486
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
base: main-powderhouse
Are you sure you want to change the base?
Value handling cleanup #2486
Conversation
src/System.CommandLine.Subsystems/ValueSources/CollectionValueSource.cs
Outdated
Show resolved
Hide resolved
src/System.CommandLine.Subsystems/ValueSources/SymbolValueSource.cs
Outdated
Show resolved
Hide resolved
using System.CommandLine.ValueSources; | ||
using static System.Net.Mime.MediaTypeNames; |
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.
MediaTypeNames doesn't seem relevant here.
They may apply to commands. | ||
They may apply to comm | ||
|
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.
That's just harder to understand.
@@ -3,9 +3,11 @@ | |||
|
|||
namespace System.CommandLine.ValueSources; | |||
|
|||
// TODO: Consider creating a set of classes with different arity: T1 and T1, T2 and T1, T2, T3, etc. |
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 would be easier to parse if written with angle brackets
// TODO: Consider creating a set of classes with different arity: <T1> and <T1, T2> and <T1, T2, T3>, etc.
This PR has several fixes to value handling.
CliCommand.Add
method (philosophically opposed to needing to step through code to understand a call stack, and this caused me a longer than necessary debugging session)ValueSource
s to more palatable namesValueSource
s. This may require discussion.TryGetValue
to PipelineResultGetValue
. Do we want to mimic dictionaries and use an indexer for throw semanticsFallbackValueSource
for default values, unifying these similar conceptsValueProvider
cachingAlso, on calculated values, Chet found a couple more that I plan to discuss on Friday but can move forward if needed.
Both because it was easier, and because I wanted to ensure we retained our experience with the currently rejected approach to custom type handling (calculated values here, but we are planning to instead use custom type conversions in core) I backed calculated values out in a commit in this PR.