GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Recognize static integral ValidateRange bounds by Copilot · Pull Request #2278 · PowerShell/PSScriptAnalyzer

Conversation

Copilot AI commented Oct 28, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

AvoidValidateRangeTypeMismatch missed integral bounds expressed as static constants and could warn for unrelated custom attributes with similar names.

  • Boundary detection: Recognize public static literal integral fields without invoking property getters.
  • Attribute matching: Require the resolved System.Management.Automation.ValidateRangeAttribute type.
param([double][ValidateRange(0, [int]::MaxValue)]$Value)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Initial plan
3cea006
Copilot AI assigned Copilot and Christoph Bergmeister (bergmeister) Oct 28, 2026
@bergmeister
Christoph Bergmeister (bergmeister) added this pull request to stack #2279 October 28, 2026 13:20
Copilot started work on behalf of Christoph Bergmeister (bergmeister) October 28, 2026 13:20
View session
@bergmeister
Handle ValidateRange static integral bounds
beb066a
Co-authored-by: bergmeister <[email protected]>
@bergmeister
Christoph Bergmeister (bergmeister) requested a balanced review from Copilot October 28, 2026 13:25
Copilot started reviewing on behalf of Christoph Bergmeister (bergmeister) October 28, 2026 13:26
View session
Copilot AI changed the title [WIP] Fix code based on review comments Recognize static integral ValidateRange bounds Oct 28, 2026
Copilot AI requested a review from Christoph Bergmeister (bergmeister) October 28, 2026 13:27
Copilot finished work on behalf of Christoph Bergmeister (bergmeister) October 28, 2026 13:27
Copilot AI reviewed Oct 28, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

🟡 Changes recommended

The rule misses warnings for inherited public static bounds and fully qualified ValidateRange declarations without the Attribute suffix because its reflection lookups do not support either case.

2 open issues
  • Medium severity Include inherited public static fields in bounds lookup · New
  • Medium severity Resolve ValidateRange attributes with optional Attribute suffix · New
What changed in this PR

This PR refines AvoidValidateRangeTypeMismatch to recognize static integral constants without invoking property getters and to identify the actual PowerShell validation attribute.

Changes:

  • Detect public static integral constant fields used as range bounds.
  • Replace attribute-name matching with a resolved-type comparison.
  • Add regression cases for [int]::MaxValue and an unrelated attribute name.
File Description
Tests/​Rules/​AvoidValidateRangeTypeMismatch.tests.ps1 Adds constant-bound and unrelated-attribute regression cases.
Rules/​AvoidValidateRangeTypeMismatch.cs Adds constant-field detection and exact attribute-type matching.

Review effort: Balanced

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Rules/AvoidValidateRangeTypeMismatch.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Rules/AvoidValidateRangeTypeMismatch.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Copilot started work on behalf of Christoph Bergmeister (bergmeister) October 28, 2026 13:30
View session
@bergmeister
Fix ValidateRange review edge cases
391e777
Co-authored-by: bergmeister <[email protected]>
Copilot finished work on behalf of Christoph Bergmeister (bergmeister) October 28, 2026 13:37
@bergmeister
Christoph Bergmeister (bergmeister) requested a balanced review from Copilot October 28, 2026 13:42
Copilot started reviewing on behalf of Christoph Bergmeister (bergmeister) October 28, 2026 13:42
View session
Copilot AI reviewed Oct 28, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

🟡 Changes recommended

The negative test never loads Contoso.ValidateRangeAttribute, leaving rejection of a successfully resolved custom attribute untested.

1 open issue
  • Low severity Add ValidateRangeAttribute fixture to test resolved custom attributes · New
2 resolved since last review
  • Medium severity Resolve ValidateRange attributes with optional Attribute suffix
  • Medium severity Include inherited public static fields in bounds lookup

Review effort: Balanced

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Tests/Rules/AvoidValidateRangeTypeMismatch.tests.ps1 Resolved

Uh oh!

There was an error while loading. Please reload this page.

Copilot started work on behalf of Christoph Bergmeister (bergmeister) October 28, 2026 14:04
View session
@bergmeister
Add real Contoso.ValidateRangeAttribute to test fixture
0fd8633
Co-authored-by: bergmeister <[email protected]>
Copilot finished work on behalf of Christoph Bergmeister (bergmeister) October 28, 2026 14:06
@bergmeister
Christoph Bergmeister (bergmeister) requested a balanced review from Copilot October 28, 2026 14:11
Copilot started reviewing on behalf of Christoph Bergmeister (bergmeister) October 28, 2026 14:11
View session
Copilot AI reviewed Oct 28, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

🟡 Changes recommended

The member-expression tests lack negative coverage for throwing static getters, static readonly integral fields, and floating-point constants, leaving getter non-execution and literal-integral-only behavior unguarded against regressions.

2 open issues
  • Low severity The new member-expression path is tested only with integral constants. Please also add negative… · New
  • Low severity Add ValidateRangeAttribute fixture to test resolved custom attributes

Review effort: Balanced

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Rules/AvoidValidateRangeTypeMismatch.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Copilot started work on behalf of Christoph Bergmeister (bergmeister) October 28, 2026 14:37
View session
@bergmeister
Test non-constant ValidateRange bounds
bd60450
Co-authored-by: bergmeister <[email protected]>
Copilot finished work on behalf of Christoph Bergmeister (bergmeister) October 28, 2026 14:44
@bergmeister
Christoph Bergmeister (bergmeister) requested a balanced review from Copilot October 28, 2026 14:47
Copilot started reviewing on behalf of Christoph Bergmeister (bergmeister) October 28, 2026 14:48
View session
Copilot AI reviewed Oct 28, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

🟢 Approval recommended

No active review issues are reported for the added static integral constant support and stricter attribute matching.

2 open issues
  • Low severity The new member-expression path is tested only with integral constants. Please also add negative…
  • Low severity Add ValidateRangeAttribute fixture to test resolved custom attributes

Review effort: Balanced

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bergmeister

Christoph Bergmeister (bergmeister) commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator

🟢 Approval recommended

No active review issues are reported for the added static integral constant support and stricter attribute matching.

2 open issues

  • Low severity The new member-expression path is tested only with integral constants. Please also add negative…
  • Low severity Add ValidateRangeAttribute fixture to test resolved custom attributes

Review effort: Balanced

Copilot fix the 2 open issues

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Copilot started work on behalf of Christoph Bergmeister (bergmeister) October 28, 2026 14:56
View session

Copilot AI commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

🟢 Approval recommended

No active review issues are reported for the added static integral constant support and stricter attribute matching.

...

Both open items are already addressed on this branch: the resolved Contoso.ValidateRangeAttribute fixture is in 0fd8633, and the throwing-getter, readonly-integral, and floating-point negative cases are in bd60450. CI passed on the current commit.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Copilot finished work on behalf of Christoph Bergmeister (bergmeister) October 28, 2026 14:58
@bergmeister
Christoph Bergmeister (bergmeister) requested a balanced review from Copilot October 28, 2026 15:08
Copilot started reviewing on behalf of Christoph Bergmeister (bergmeister) October 28, 2026 15:08
View session
Copilot AI reviewed Oct 28, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

🟢 Approval recommended

No active review issues were identified for the changes supporting static integral bounds and excluding unrelated custom attributes.

No open issues 🎉

2 resolved since last review
  • Low severity The new member-expression path is tested only with integral constants. Please also add negative…
  • Low severity Add ValidateRangeAttribute fixture to test resolved custom attributes

Review effort: Balanced

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bergmeister
Christoph Bergmeister (bergmeister) marked this pull request as ready for review October 28, 2026 15:14
@bergmeister
Christoph Bergmeister (bergmeister) requested a review from a team as a code owner October 28, 2026 15:14
@bergmeister
Christoph Bergmeister (bergmeister) removed this pull request from stack #2279 October 28, 2026 15:14
@bergmeister
Christoph Bergmeister (bergmeister) merged commit 919cef7 into copilot/validate-range-boundary-check Oct 28, 2026
10 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@bergmeister
Christoph Bergmeister (bergmeister) deleted the copilot/fix-code-for-review-comments branch October 28, 2026 15:14
@bergmeister Christoph Bergmeister (bergmeister) mentioned this pull request Oct 28, 2026
Warn on integer ValidateRange bounds for floating-point parameters #2267
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments
@bergmeister Christoph Bergmeister (bergmeister) Awaiting requested review from bergmeister bergmeister is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@bergmeister Christoph Bergmeister (bergmeister)

Copilot code review Copilot

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@bergmeister
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.