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

Appearance settings

Filter completion for enum parameter against ValidateRange-attributes#17750

Merged
adityapatwardhan merged 11 commits into
PowerShell:masterPowerShell/PowerShell:masterfrom
fflaten:enum-completion-validaterangefflaten/PowerShell:enum-completion-validaterangeCopy head branch name to clipboard
May 22, 2023
Merged

Filter completion for enum parameter against ValidateRange-attributes#17750
adityapatwardhan merged 11 commits into
PowerShell:masterPowerShell/PowerShell:masterfrom
fflaten:enum-completion-validaterangefflaten/PowerShell:enum-completion-validaterangeCopy head branch name to clipboard

Conversation

@fflaten

@fflaten fflaten commented Jul 23, 2022

Copy link
Copy Markdown
Contributor

PR Summary

Updates parameter completion for enums to exclude values not allowed by ValidateRange-attributes.

PR Context

See this comment

Fix #2849

PR Checklist

@fflaten

fflaten commented Jul 23, 2022

Copy link
Copy Markdown
Contributor Author

Tested devbuild with vscode-powershell (stable). It also shows filtered values as expected.

@iSazonov

Copy link
Copy Markdown
Collaborator

I suggest to put enum value list and code to check range in ValidateRangeAttribute class.

@fflaten

fflaten commented Jul 24, 2022

Copy link
Copy Markdown
Contributor Author

I suggest to put enum value list and code to check range in ValidateRangeAttribute class.

I agree on the validation. Just realized that I forgot about rangekind also
Initially intended to reuse ValidateElement() with a try/catch, but it's currently protected. Any rules blocking me from making it internal?

The value-list is unique to this completer though as the range could be int-values or rangekind (weird but supported).

@fflaten fflaten changed the title Filter completion for enum parameter against ValidateRange-attributes WIP: Filter completion for enum parameter against ValidateRange-attributes Jul 24, 2022
@iSazonov

Copy link
Copy Markdown
Collaborator

I thinks really we need internal helper method in ValidateRangeAttribute to return a list of filtered strings for enum base type.

@fflaten

fflaten commented Jul 24, 2022

Copy link
Copy Markdown
Contributor Author

I thinks really we need internal helper method in ValidateRangeAttribute to return a list of filtered strings for enum base type.

Thanks. Better now?

@fflaten fflaten changed the title WIP: Filter completion for enum parameter against ValidateRange-attributes Filter completion for enum parameter against ValidateRange-attributes Jul 24, 2022
Comment thread src/System.Management.Automation/engine/Attributes.cs Outdated
Comment thread src/System.Management.Automation/engine/Attributes.cs Outdated
Comment thread src/System.Management.Automation/engine/Attributes.cs Outdated
Comment thread src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs Outdated
@iSazonov iSazonov added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label Jul 25, 2022
@fflaten fflaten changed the title Filter completion for enum parameter against ValidateRange-attributes WIP: Filter completion for enum parameter against ValidateRange-attributes Jul 25, 2022
@fflaten fflaten changed the title WIP: Filter completion for enum parameter against ValidateRange-attributes Filter completion for enum parameter against ValidateRange-attributes Jul 28, 2022
Comment thread src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs Outdated
Comment thread src/System.Management.Automation/engine/Attributes.cs Outdated
Comment thread src/System.Management.Automation/engine/Attributes.cs
@iSazonov iSazonov requested a review from daxian-dbw July 31, 2022 13:43
@pull-request-quantifier-deprecated

Copy link
Copy Markdown

This PR has 50 quantified lines of changes. In general, a change size of upto 200 lines is ideal for the best PR experience!


Quantification details

Label      : Extra Small
Size       : +41 -9
Percentile : 20%

Total files changed: 4

Change summary by file extension:
.cs : +20 -9
.ps1 : +21 -0

Change counts above are quantified counts, based on the PullRequestQuantifier customizations.

Why proper sizing of changes matters

Optimal pull request sizes drive a better predictable PR flow as they strike a
balance between between PR complexity and PR review overhead. PRs within the
optimal size (typical small, or medium sized PRs) mean:

  • Fast and predictable releases to production:
    • Optimal size changes are more likely to be reviewed faster with fewer
      iterations.
    • Similarity in low PR complexity drives similar review times.
  • Review quality is likely higher as complexity is lower:
    • Bugs are more likely to be detected.
    • Code inconsistencies are more likely to be detected.
  • Knowledge sharing is improved within the participants:
    • Small portions can be assimilated better.
  • Better engineering practices are exercised:
    • Solving big problems by dividing them in well contained, smaller problems.
    • Exercising separation of concerns within the code changes.

What can I do to optimize my changes

  • Use the PullRequestQuantifier to quantify your PR accurately
    • Create a context profile for your repo using the context generator
    • Exclude files that are not necessary to be reviewed or do not increase the review complexity. Example: Autogenerated code, docs, project IDE setting files, binaries, etc. Check out the Excluded section from your prquantifier.yaml context profile.
    • Understand your typical change complexity, drive towards the desired complexity by adjusting the label mapping in your prquantifier.yaml context profile.
    • Only use the labels that matter to you, see context specification to customize your prquantifier.yaml context profile.
  • Change your engineering behaviors
    • For PRs that fall outside of the desired spectrum, review the details and check if:
      • Your PR could be split in smaller, self-contained PRs instead
      • Your PR only solves one particular issue. (For example, don't refactor and code new features in the same PR).

How to interpret the change counts in git diff output

  • One line was added: +1 -0
  • One line was deleted: +0 -1
  • One line was modified: +1 -1 (git diff doesn't know about modified, it will
    interpret that line like one addition plus one deletion)
  • Change percentiles: Change characteristics (addition, deletion, modification)
    of this PR in relation to all other PRs within the repository.


Was this comment helpful? 👍  :ok_hand:  :thumbsdown: (Email)
Customize PullRequestQuantifier for this repository.

@ghost ghost added the Review - Needed The PR is being reviewed label Aug 11, 2022
@ghost

ghost commented Aug 11, 2022

Copy link
Copy Markdown

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Maintainer, please provide feedback and/or mark it as Waiting on Author

@fflaten

fflaten commented May 21, 2023

Copy link
Copy Markdown
Contributor Author

Hi @adityapatwardhan . Any ETA on review?
Would be great it this would make 7.4 as LTS releases are deployed in enterprises.

@adityapatwardhan

Copy link
Copy Markdown
Member

I will prioritize this for community day tomorrow.

@ghost ghost removed the Review - Needed The PR is being reviewed label May 22, 2023
@adityapatwardhan adityapatwardhan enabled auto-merge (squash) May 22, 2023 21:24
@adityapatwardhan adityapatwardhan disabled auto-merge May 22, 2023 21:24
@adityapatwardhan adityapatwardhan merged commit c57ada2 into PowerShell:master May 22, 2023
@adityapatwardhan

Copy link
Copy Markdown
Member

@fflaten thank you for your contribution!

@fflaten fflaten deleted the enum-completion-validaterange branch May 22, 2023 22:12
@ghost

ghost commented Jun 29, 2023

Copy link
Copy Markdown

🎉v7.4.0-preview.4 has been released which incorporates this pull request.:tada:

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log Extra Small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ValidateRange should not allow iteration over invalid range values

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.