Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Copy link
Copy link
@hairyken

Description

@hairyken
Issue body actions

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()

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.