GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||
GeezerVison is showing github.com — Fix SuppressMessage CustomRule by HeyItsGilbert · Pull Request #2142 · PowerShell/PSScriptAnalyzer Conversation
Contributor
PR SummaryProblem: SuppressMessageAttribute failed when using named arguments for RuleSuppressionID. Users could not use syntax like: [SuppressMessage("RuleName", RuleSuppressionId="MyId")] Root Cause: In RuleSuppression.cs, the named argument parser had two bugs:
This broke selective rule suppression for custom rules. Solution:
Now both syntaxes work correctly: Fixes #1686 PR Checklist
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsProblem: SuppressMessageAttribute failed when using named arguments for
RuleSuppressionID. Users could not use syntax like:
[SuppressMessage("RuleName", RuleSuppressionId="MyId")]
Root Cause: In RuleSuppression.cs, the named argument parser had two bugs:
1. Checked if RuleName was set instead of RuleSuppressionID
2. Assigned the value to RuleName instead of RuleSuppressionID
This broke selective rule suppression for custom rules.
Solution:
- Fixed conflict check to validate RuleSuppressionID instead of RuleName
- Fixed assignment to set RuleSuppressionID instead of RuleName
- Added comprehensive tests for named argument syntax
- Minor formatting improvements
Now both syntaxes work correctly:
[SuppressMessage("Rule", RuleSuppressionId="Id", Scope="Function")]
[SuppressMessage("Rule", "Id", Scope="Function")]
* Implemented a test case to validate the functionality of custom rules with targeted suppression. * The test recreates the scenario from GitHub issue PowerShell#1686, ensuring that `RuleSuppressionID` works correctly with named arguments. * Verified that violations are suppressed as expected based on the defined rules.
Gilbert Sanchez (HeyItsGilbert)
requested review from
Andy Jordan (andyleejordan) and
Christoph Bergmeister (bergmeister)
as code owners
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pull request overviewThis PR fixes a critical bug in the RuleSuppression attribute parser that prevented the use of named argument syntax for Key Changes:
Reviewed changesCopilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Christoph Bergmeister (bergmeister)
approved these changes
|
|
👍 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
RuleSuppressionId is not being honored for custom rule suppression
There was an error while loading. Please reload this page.