Skip to content

Commit a86fbfe

Browse files
authoredJan 6, 2020
Update SuppressMessageAttribute docs link and use single quotes for examples (#1389)
1 parent 8408066 commit a86fbfe

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed
 

Diff for: ‎README.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -227,13 +227,13 @@ PSUseApprovedVerbs Warning 1 The cmdlet 'eliminate-file' uses an
227227
Suppressing Rules
228228
=================
229229

230-
You can suppress a rule by decorating a script/function or script/function parameter with .NET's [SuppressMessageAttribute](https://msdn.microsoft.com/en-us/library/system.diagnostics.codeanalysis.suppressmessageattribute.aspx).
230+
You can suppress a rule by decorating a script/function or script/function parameter with .NET's [SuppressMessageAttribute](https://docs.microsoft.com/dotnet/api/system.diagnostics.codeanalysis.suppressmessageattribute).
231231
`SuppressMessageAttribute`'s constructor takes two parameters: a category and a check ID. Set the `categoryID` parameter to the name of the rule you want to suppress and set the `checkID` parameter to a null or empty string. You can optionally add a third named parameter with a justification for suppressing the message:
232232

233233
``` PowerShell
234234
function SuppressMe()
235235
{
236-
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSProvideCommentHelp", "", Justification="Just an example")]
236+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSProvideCommentHelp', '', Justification='Just an example')]
237237
param()
238238
239239
Write-Verbose -Message "I'm making a difference!"
@@ -247,8 +247,8 @@ To suppress a message on a specific parameter, set the `SuppressMessageAttribute
247247
``` PowerShell
248248
function SuppressTwoVariables()
249249
{
250-
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSProvideDefaultParameterValue", "b")]
251-
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSProvideDefaultParameterValue", "a")]
250+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSProvideDefaultParameterValue', 'b')]
251+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSProvideDefaultParameterValue', 'a')]
252252
param([string]$a, [int]$b)
253253
{
254254
}
@@ -260,7 +260,7 @@ Use the `SuppressMessageAttribute`'s `Scope` property to limit rule suppression
260260
Use the value `Function` to suppress violations on all functions within the attribute's scope. Use the value `Class` to suppress violations on all classes within the attribute's scope:
261261

262262
``` PowerShell
263-
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSProvideCommentHelp", "", Scope="Function")]
263+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSProvideCommentHelp', '', Scope='Function')]
264264
param(
265265
)
266266
@@ -297,13 +297,13 @@ function start-bam {
297297

298298
Suppress violations in all the functions:
299299
``` PowerShell
300-
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingWriteHost", Scope="Function", Target="*")]
300+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', Scope='Function', Target='*')]
301301
Param()
302302
```
303303

304304
Suppress violation in `start-bar`, `start-baz` and `start-bam` but not in `start-foo`:
305305
``` PowerShell
306-
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingWriteHost", Scope="Function", Target="start-b*")]
306+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', Scope='Function', Target='start-b*')]
307307
Param()
308308
```
309309

0 commit comments

Comments
 (0)