Skip to content

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

Open
wants to merge 10 commits into
base: main-powderhouse
Choose a base branch
from

Conversation

KathleenDollard
Copy link
Contributor

This PR has several fixes to value handling.

  • General cleanup
  • Removed attributes on the 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)
  • Renamed individual ValueSources to more palatable names
  • Separated fallback and collection ValueSources. This may require discussion.
  • Added TryGetValue to PipelineResult
    • Check naming on GetValue. Do we want to mimic dictionaries and use an indexer for throw semantics
  • Now using FallbackValueSource for default values, unifying these similar concepts
  • Added guard to ValueProvider caching
  • Left the calculated value tests in place as comments as a reminder that we need these tests

Also, 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.

@KathleenDollard KathleenDollard added the Powderhouse Work to isolate parser and features label Sep 16, 2024
@KathleenDollard KathleenDollard changed the base branch from main to main-powderhouse September 16, 2024 20:19
using System.CommandLine.ValueSources;
using static System.Net.Mime.MediaTypeNames;

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.

Comment on lines 59 to 60
They may apply to commands.
They may apply to comm

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.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Powderhouse Work to isolate parser and features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants