Repository navigation
Recognize static integral ValidateRange bounds - #2278
Conversation
Co-authored-by: bergmeister <9250262+bergmeister@users.noreply.github.com>
There was a problem hiding this comment.
🟡 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
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]::MaxValueand 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
Co-authored-by: bergmeister <9250262+bergmeister@users.noreply.github.com>
Co-authored-by: bergmeister <9250262+bergmeister@users.noreply.github.com>
There was a problem hiding this comment.
🟡 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
Review effort: Balanced
Co-authored-by: bergmeister <9250262+bergmeister@users.noreply.github.com>
Copilot fix the 2 open issues |
... Both open items are already addressed on this branch: the resolved |
919cef7
into
copilot/validate-range-boundary-check


AvoidValidateRangeTypeMismatchmissed integral bounds expressed as static constants and could warn for unrelated custom attributes with similar names.System.Management.Automation.ValidateRangeAttributetype.