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

Error in last two SuppressMessageAttribute examples in readme.MD #1592

Closed
hairyken opened this issue Oct 6, 2020 · 1 comment · Fixed by #1593
Closed

Error in last two SuppressMessageAttribute examples in readme.MD #1592

hairyken opened this issue Oct 6, 2020 · 1 comment · Fixed by #1593

Comments

@hairyken
Copy link

hairyken commented Oct 6, 2020

In Suppressing rules in README.md, the last two examples omit the CheckID parameter. When used like this, the constructor for SuppressMessageAttribute throws an exception

Eg. when using the example provided under 'Suppress violations in all the functions' in a script:

[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', Scope='Function', Target='*')]
Param()

Write-Output 'Hello world'

When executing this script, PowerShell throws this error:

Cannot find an overload for ".ctor" and the argument count: "1".

The example starting on line 302 should read:

[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '', Scope='Function', Target='*')]
Param()

and on line 307

[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '', Scope='Function', Target='start-b*')]
Param()
@ghost ghost added the Needs: Triage 🔍 label Oct 6, 2020
@SydneyhSmith
Copy link
Collaborator

SydneyhSmith commented Oct 6, 2020

Thanks @hairyken you are correct, we will make this fix-- in the future feel free to open a PR for issues like this as well 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants