Diagnostics.CodeAnalysis.SuppressMessageAttribute should take an array of category names
The attribute needs to take an array of categories. I shouldn't have to add a new instance of the attribute for each category I want to suppress.
Having to write a separate line for every rule I need to suppress is extremely frustrating and verbose. Take for example this 2 line internal function:
function New-PSCredential {
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingPlainTextForPassword")] # It's encoded, leave me alone
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingUserNameAndPasswordParams")] # That's the whole point of this function
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSProvideCommentHelp")] # No point for a constructor function with parameters this simple
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSProvideDefaultParameterValue")] # No point for internal functions
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseOutputTypeCorrectly")] # No point for internal functions
param([string]$UserName, [string]$EncodedPassword)
New-Object PSCredential $UserName, (ConvertTo-SecureString $EncodedPassword)
}
Seriously?
Thanks for the feedback.
Originally, we modeled this after System.Diagnostics.CodeAnalysis.SuppressMessage in .net.
But, since we control the implementation we can definitely optimize the experience.
Marking this as a new feature
It would be really cool if the parameter name could also be an array to suppress the same category for multiple parameters in one go. Maybe not at the same time as defining an array for the category, as that might have unintentional consequences.