@@ -99,6 +99,18 @@ public SwitchParameter Recurse
99
99
}
100
100
private bool recurse ;
101
101
102
+ /// <summary>
103
+ /// ShowSuppressed: Show the suppressed message
104
+ /// </summary>
105
+ [ Parameter ( Mandatory = false ) ]
106
+ [ SuppressMessage ( "Microsoft.Performance" , "CA1819:PropertiesShouldNotReturnArrays" ) ]
107
+ public SwitchParameter ShowSuppressed
108
+ {
109
+ get { return showSuppressed ; }
110
+ set { showSuppressed = value ; }
111
+ }
112
+ private bool showSuppressed ;
113
+
102
114
#endregion Parameters
103
115
104
116
#region Private Members
@@ -256,6 +268,7 @@ private void AnalyzeFile(string filePath)
256
268
Token [ ] tokens = null ;
257
269
ParseError [ ] errors = null ;
258
270
List < DiagnosticRecord > diagnostics = new List < DiagnosticRecord > ( ) ;
271
+ List < DiagnosticRecord > suppressed = new List < DiagnosticRecord > ( ) ;
259
272
260
273
// Use a List of KVP rather than dictionary, since for a script containing inline functions with same signature, keys clash
261
274
List < KeyValuePair < CommandInfo , IScriptExtent > > cmdInfoTable = new List < KeyValuePair < CommandInfo , IScriptExtent > > ( ) ;
@@ -331,6 +344,7 @@ private void AnalyzeFile(string filePath)
331
344
var records = scriptRule . AnalyzeScript ( ast , filePath ) . ToList ( ) ;
332
345
Helper . Instance . SuppressRule ( scriptRule . GetName ( ) , ruleSuppressions , records ) ;
333
346
diagnostics . AddRange ( records . Where ( record => record . Suppression == null ) ) ;
347
+ suppressed . AddRange ( records . Where ( record => record . Suppression != null ) ) ;
334
348
}
335
349
catch ( Exception scriptRuleException )
336
350
{
@@ -361,6 +375,7 @@ private void AnalyzeFile(string filePath)
361
375
var records = tokenRule . AnalyzeTokens ( tokens , fileName ) . ToList ( ) ;
362
376
Helper . Instance . SuppressRule ( tokenRule . GetName ( ) , ruleSuppressions , records ) ;
363
377
diagnostics . AddRange ( records . Where ( record => record . Suppression == null ) ) ;
378
+ suppressed . AddRange ( records . Where ( record => record . Suppression != null ) ) ;
364
379
}
365
380
catch ( Exception tokenRuleException )
366
381
{
@@ -391,6 +406,7 @@ private void AnalyzeFile(string filePath)
391
406
var records = dscResourceRule . AnalyzeDSCClass ( ast , filePath ) . ToList ( ) ;
392
407
Helper . Instance . SuppressRule ( dscResourceRule . GetName ( ) , ruleSuppressions , records ) ;
393
408
diagnostics . AddRange ( records . Where ( record => record . Suppression == null ) ) ;
409
+ suppressed . AddRange ( records . Where ( record => record . Suppression != null ) ) ;
394
410
}
395
411
catch ( Exception dscResourceRuleException )
396
412
{
@@ -435,6 +451,7 @@ private void AnalyzeFile(string filePath)
435
451
var records = dscResourceRule . AnalyzeDSCResource ( ast , filePath ) . ToList ( ) ;
436
452
Helper . Instance . SuppressRule ( dscResourceRule . GetName ( ) , ruleSuppressions , records ) ;
437
453
diagnostics . AddRange ( records . Where ( record => record . Suppression == null ) ) ;
454
+ suppressed . AddRange ( records . Where ( record => record . Suppression != null ) ) ;
438
455
}
439
456
catch ( Exception dscResourceRuleException )
440
457
{
@@ -492,9 +509,19 @@ private void AnalyzeFile(string filePath)
492
509
//Output through loggers
493
510
foreach ( ILogger logger in ScriptAnalyzer . Instance . Loggers )
494
511
{
495
- foreach ( DiagnosticRecord diagnostic in diagnostics )
512
+ if ( ShowSuppressed )
496
513
{
497
- logger . LogMessage ( diagnostic , this ) ;
514
+ foreach ( DiagnosticRecord suppressRecord in suppressed )
515
+ {
516
+ logger . LogObject ( suppressRecord , this ) ;
517
+ }
518
+ }
519
+ else
520
+ {
521
+ foreach ( DiagnosticRecord diagnostic in diagnostics )
522
+ {
523
+ logger . LogObject ( diagnostic , this ) ;
524
+ }
498
525
}
499
526
}
500
527
}
0 commit comments