@@ -1160,8 +1160,7 @@ public Dictionary<string, List<RuleSuppression>> GetRuleSuppression(Ast ast)
1160
1160
ruleSuppressionList . AddRange ( GetSuppressionsFunction ( funcAst ) ) ;
1161
1161
}
1162
1162
1163
- #if ! PSV3
1164
-
1163
+ #if ! PSV3
1165
1164
// Get rule suppression from classes
1166
1165
IEnumerable < TypeDefinitionAst > typeAsts = ast . FindAll ( item => item is TypeDefinitionAst , true ) . Cast < TypeDefinitionAst > ( ) ;
1167
1166
@@ -1170,7 +1169,14 @@ public Dictionary<string, List<RuleSuppression>> GetRuleSuppression(Ast ast)
1170
1169
ruleSuppressionList . AddRange ( GetSuppressionsClass ( typeAst ) ) ;
1171
1170
}
1172
1171
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
1174
1180
1175
1181
ruleSuppressionList . Sort ( ( item , item2 ) => item . StartOffset . CompareTo ( item2 . StartOffset ) ) ;
1176
1182
@@ -1188,6 +1194,27 @@ public Dictionary<string, List<RuleSuppression>> GetRuleSuppression(Ast ast)
1188
1194
return results ;
1189
1195
}
1190
1196
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
+
1191
1218
/// <summary>
1192
1219
/// Returns a list of rule suppressions from the function
1193
1220
/// </summary>
0 commit comments