@@ -1160,8 +1160,7 @@ public Dictionary<string, List<RuleSuppression>> GetRuleSuppression(Ast ast)
11601160 ruleSuppressionList . AddRange ( GetSuppressionsFunction ( funcAst ) ) ;
11611161 }
11621162
1163- #if ! PSV3
1164-
1163+ #if ! PSV3
11651164 // Get rule suppression from classes
11661165 IEnumerable < TypeDefinitionAst > typeAsts = ast . FindAll ( item => item is TypeDefinitionAst , true ) . Cast < TypeDefinitionAst > ( ) ;
11671166
@@ -1170,7 +1169,14 @@ public Dictionary<string, List<RuleSuppression>> GetRuleSuppression(Ast ast)
11701169 ruleSuppressionList . AddRange ( GetSuppressionsClass ( typeAst ) ) ;
11711170 }
11721171
1173- #endif
1172+ // Get rule suppression from configuration definitions
1173+ IEnumerable < ConfigurationDefinitionAst > configDefAsts = ast . FindAll ( item => item is ConfigurationDefinitionAst , true ) . Cast < ConfigurationDefinitionAst > ( ) ;
1174+
1175+ foreach ( var configDefAst in configDefAsts )
1176+ {
1177+ ruleSuppressionList . AddRange ( GetSuppressionsConfiguration ( configDefAst ) ) ;
1178+ }
1179+ #endif // !PSV3
11741180
11751181 ruleSuppressionList . Sort ( ( item , item2 ) => item . StartOffset . CompareTo ( item2 . StartOffset ) ) ;
11761182
@@ -1188,6 +1194,27 @@ public Dictionary<string, List<RuleSuppression>> GetRuleSuppression(Ast ast)
11881194 return results ;
11891195 }
11901196
1197+ /// <summary>
1198+ /// Returns a list of rule suppressions from the configuration
1199+ /// </summary>
1200+ /// <param name="configDefAst"></param>
1201+ /// <returns></returns>
1202+ internal List < RuleSuppression > GetSuppressionsConfiguration ( ConfigurationDefinitionAst configDefAst )
1203+ {
1204+ var result = new List < RuleSuppression > ( ) ;
1205+ if ( configDefAst == null || configDefAst . Body == null )
1206+ {
1207+ return result ;
1208+ }
1209+ var attributeAsts = configDefAst . FindAll ( x => x is AttributeAst , true ) . Cast < AttributeAst > ( ) ;
1210+ result . AddRange ( RuleSuppression . GetSuppressions (
1211+ attributeAsts ,
1212+ configDefAst . Extent . StartOffset ,
1213+ configDefAst . Extent . EndOffset ,
1214+ configDefAst ) ) ;
1215+ return result ;
1216+ }
1217+
11911218 /// <summary>
11921219 /// Returns a list of rule suppressions from the function
11931220 /// </summary>
0 commit comments