@@ -99,6 +99,18 @@ public SwitchParameter Recurse
9999 }
100100 private bool recurse ;
101101
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+
102114 #endregion Parameters
103115
104116 #region Private Members
@@ -256,6 +268,7 @@ private void AnalyzeFile(string filePath)
256268 Token [ ] tokens = null ;
257269 ParseError [ ] errors = null ;
258270 List < DiagnosticRecord > diagnostics = new List < DiagnosticRecord > ( ) ;
271+ List < DiagnosticRecord > suppressed = new List < DiagnosticRecord > ( ) ;
259272
260273 // Use a List of KVP rather than dictionary, since for a script containing inline functions with same signature, keys clash
261274 List < KeyValuePair < CommandInfo , IScriptExtent > > cmdInfoTable = new List < KeyValuePair < CommandInfo , IScriptExtent > > ( ) ;
@@ -331,6 +344,7 @@ private void AnalyzeFile(string filePath)
331344 var records = scriptRule . AnalyzeScript ( ast , filePath ) . ToList ( ) ;
332345 Helper . Instance . SuppressRule ( scriptRule . GetName ( ) , ruleSuppressions , records ) ;
333346 diagnostics . AddRange ( records . Where ( record => record . Suppression == null ) ) ;
347+ suppressed . AddRange ( records . Where ( record => record . Suppression != null ) ) ;
334348 }
335349 catch ( Exception scriptRuleException )
336350 {
@@ -361,6 +375,7 @@ private void AnalyzeFile(string filePath)
361375 var records = tokenRule . AnalyzeTokens ( tokens , fileName ) . ToList ( ) ;
362376 Helper . Instance . SuppressRule ( tokenRule . GetName ( ) , ruleSuppressions , records ) ;
363377 diagnostics . AddRange ( records . Where ( record => record . Suppression == null ) ) ;
378+ suppressed . AddRange ( records . Where ( record => record . Suppression != null ) ) ;
364379 }
365380 catch ( Exception tokenRuleException )
366381 {
@@ -391,6 +406,7 @@ private void AnalyzeFile(string filePath)
391406 var records = dscResourceRule . AnalyzeDSCClass ( ast , filePath ) . ToList ( ) ;
392407 Helper . Instance . SuppressRule ( dscResourceRule . GetName ( ) , ruleSuppressions , records ) ;
393408 diagnostics . AddRange ( records . Where ( record => record . Suppression == null ) ) ;
409+ suppressed . AddRange ( records . Where ( record => record . Suppression != null ) ) ;
394410 }
395411 catch ( Exception dscResourceRuleException )
396412 {
@@ -435,6 +451,7 @@ private void AnalyzeFile(string filePath)
435451 var records = dscResourceRule . AnalyzeDSCResource ( ast , filePath ) . ToList ( ) ;
436452 Helper . Instance . SuppressRule ( dscResourceRule . GetName ( ) , ruleSuppressions , records ) ;
437453 diagnostics . AddRange ( records . Where ( record => record . Suppression == null ) ) ;
454+ suppressed . AddRange ( records . Where ( record => record . Suppression != null ) ) ;
438455 }
439456 catch ( Exception dscResourceRuleException )
440457 {
@@ -492,9 +509,19 @@ private void AnalyzeFile(string filePath)
492509 //Output through loggers
493510 foreach ( ILogger logger in ScriptAnalyzer . Instance . Loggers )
494511 {
495- foreach ( DiagnosticRecord diagnostic in diagnostics )
512+ if ( ShowSuppressed )
496513 {
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+ }
498525 }
499526 }
500527 }
0 commit comments