@@ -26,6 +26,15 @@ public class RuleSuppression
2626 {
2727 private string _ruleName ;
2828
29+ /// <summary>
30+ /// The start offset of the rule suppression attribute (not where it starts to apply)
31+ /// </summary>
32+ public int StartAttributeLine
33+ {
34+ get ;
35+ set ;
36+ }
37+
2938 /// <summary>
3039 /// The start offset of the rule suppression
3140 /// </summary>
@@ -133,6 +142,7 @@ public RuleSuppression(AttributeAst attrAst, int start, int end)
133142
134143 if ( attrAst != null )
135144 {
145+ StartAttributeLine = attrAst . Extent . StartLineNumber ;
136146 var positionalArguments = attrAst . PositionalArguments ;
137147 var namedArguments = attrAst . NamedArguments ;
138148
@@ -262,24 +272,26 @@ public RuleSuppression(AttributeAst attrAst, int start, int end)
262272
263273 if ( ! String . IsNullOrWhiteSpace ( Error ) )
264274 {
265- Error = String . Format ( CultureInfo . CurrentCulture , Strings . RuleSuppressionErrorFormat , attrAst . Extent . StartLineNumber ,
275+ Error = String . Format ( CultureInfo . CurrentCulture , Strings . RuleSuppressionErrorFormat , StartAttributeLine ,
266276 System . IO . Path . GetFileName ( attrAst . Extent . File ) , Error ) ;
267277 }
268278 }
269279
270280 /// <summary>
271- /// Constructs rule expression from rule name, id, start and end
281+ /// Constructs rule expression from rule name, id, start, end and startAttributeLine
272282 /// </summary>
273283 /// <param name="ruleName"></param>
274284 /// <param name="ruleSuppressionID"></param>
275285 /// <param name="start"></param>
276286 /// <param name="end"></param>
277- public RuleSuppression ( string ruleName , string ruleSuppressionID , int start , int end )
287+ /// <param name="startAttributeLine"></param>
288+ public RuleSuppression ( string ruleName , string ruleSuppressionID , int start , int end , int startAttributeLine )
278289 {
279290 RuleName = ruleName ;
280291 RuleSuppressionID = ruleSuppressionID ;
281292 StartOffset = start ;
282293 EndOffset = end ;
294+ StartAttributeLine = startAttributeLine ;
283295 }
284296
285297 /// <summary>
@@ -336,15 +348,15 @@ public static List<RuleSuppression> GetSuppressions(IEnumerable<AttributeAst> at
336348 {
337349 if ( targetAsts . Count ( ) == 0 )
338350 {
339- ruleSupp . Error = String . Format ( CultureInfo . CurrentCulture , Strings . RuleSuppressionErrorFormat , ruleSupp . StartOffset ,
351+ ruleSupp . Error = String . Format ( CultureInfo . CurrentCulture , Strings . RuleSuppressionErrorFormat , ruleSupp . StartAttributeLine ,
340352 System . IO . Path . GetFileName ( scopeAst . Extent . File ) , String . Format ( Strings . TargetCannotBeFoundError , ruleSupp . Target , ruleSupp . Scope ) ) ;
341353 result . Add ( ruleSupp ) ;
342354 continue ;
343355 }
344356
345357 foreach ( Ast targetAst in targetAsts )
346358 {
347- result . Add ( new RuleSuppression ( ruleSupp . RuleName , ruleSupp . RuleSuppressionID , targetAst . Extent . StartOffset , targetAst . Extent . EndOffset ) ) ;
359+ result . Add ( new RuleSuppression ( ruleSupp . RuleName , ruleSupp . RuleSuppressionID , targetAst . Extent . StartOffset , targetAst . Extent . EndOffset , attributeAst . Extent . StartLineNumber ) ) ;
348360 }
349361 }
350362
0 commit comments