Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Make Token.Symbol property public#1815

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
kahlkevin wants to merge1 commit intodotnet:main
base:main
Choose a base branch
Loading
fromkahlkevin:patch-1

Conversation

@kahlkevin
Copy link

Motivation:

  • Inside custom middleware, it may be desirable to understand relative order of symbols in the parsed command line (for e.g. in the case of several option types that influence a shared setting and that have a "last option specified wins" semantic).
  • Best way to do understand sequence order is by inspecting theParseResult.Tokens list. This givesTokens, which contain embedded symbol references.
  • From there, we'd like to compare the token'sSymbol directly against predefinedArgument andOption objects to ease identification.
  • Doing this from non-internal code today requires something likeif (tokenOfInterest == new Token(tokenOfInterest.Value, TokenType.Option, optionOfInterest)) { /* match */ ... }, which works because of the overriddenToken.Equals method.
  • It'd be much easier to sayif (tokenOfInterest.Symbol == optionOfInterest) { /* match */ ... }
  • No clear reason whyToken.Symbol needs to beinternal

Motivation: - Inside custom middleware, it may be desirable to understand relative order of symbols in the parsed command line (for e.g. in the case of several option types that influence a shared setting and that have a "last option specified wins" semantic). - Best way to do understand sequence order is by inspecting the `ParseResult.Tokens` list. This gives `Token`s, which contain embedded symbol references. - From there, we'd like to compare the token's `Symbol` directly against predefined `Argument` and `Option` objects to ease identification. - Doing this from non-`internal` code today requires something like `if (tokenOfInterest == new Token(tokenOfInterest.Value, TokenType.Option, optionOfInterest)) { /* match */ ... }`, which works because of the overridden `Token.Equals` method. - It'd be much easier to say `if (tokenOfInterest.Symbol == optionOfInterest) { /* match */ ... }` - No clear reason why `Token.Symbol` needs to be `internal`
@KalleOlaviNiemitalo

This might simplify the redaction that I do in#1795.

@jonsequiturjonsequitur added the enhancementNew feature or request labelAug 31, 2022
@jonsequitur
Copy link
Contributor

While this might be a useful API addition, it was added primarily for internal bookkeeping and it would need to be tested more thoroughly for a number of scenarios including cases where the token is shifted during parsing, i.e.ArgumentResult.OnlyTake.

@adamsitnikadamsitnik mentioned this pull requestMar 7, 2023
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

enhancementNew feature or request

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@kahlkevin@KalleOlaviNiemitalo@jonsequitur

[8]ページ先頭

©2009-2025 Movatter.jp