Skip to content

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

Closed
@hairyken

Description

@hairyken

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