Skip to content
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

Filter completion for enum parameter against ValidateRange-attributes #17750

Merged

Conversation

fflaten
Copy link
Contributor

@fflaten fflaten commented Jul 23, 2022

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
Copy link
Contributor Author

fflaten commented Jul 23, 2022

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

@iSazonov
Copy link
Collaborator

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

@fflaten
Copy link
Contributor Author

fflaten commented Jul 24, 2022

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
Collaborator

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

@fflaten
Copy link
Contributor Author

fflaten commented Jul 24, 2022

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
@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
@iSazonov iSazonov requested a review from daxian-dbw July 31, 2022 13:43
@pull-request-quantifier-deprecated

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
Copy link

ghost commented Aug 11, 2022

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
Copy link
Contributor Author

fflaten commented May 21, 2023

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
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 merged commit c57ada2 into PowerShell:master May 22, 2023
1 check passed
@adityapatwardhan
Copy link
Member

@fflaten thank you for your contribution!

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

ghost commented Jun 29, 2023

🎉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