Ignore length of [SuppressMessage] lines?

Feb 19, 2012 at 7:11 AM

Would it be possible to disable the length check on lines containing the SuppressMessage attribute?

When you add the category and the checkId (some of which can be quite long) parameters, it leaves very little space for the Justification, and it makes for ugly code to have a 2-line SuppressMessage for a 3-line method.

I came across an ironic case where rule SP2100 was triggering on a [SuppressMessage] that was suppressing the length check on the next line.

What do you think?

Coordinator
Feb 23, 2012 at 3:23 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Coordinator
Feb 23, 2012 at 3:25 PM

Hi Philip,

I would agree.

I am sorry although, that I don't have much spare time at the moment.
Anyway, it will definitely be implemented someday!

Best regards,
Oleg Shuruev

Feb 23, 2012 at 3:35 PM

I'd be happy to provide a patch, if you wouldn't mind a bit of guidance.

Am I correct in thinking the right fix would be to change MoreCustomRules.CheckLineLength and inspect currentLine for the pressence of SuppressMessage?

Coordinator
Mar 4, 2012 at 5:41 PM
Edited Mar 4, 2012 at 5:41 PM

Philip,

I'm afraid that it could be not quite correct just to check whether code line contains some specified text.

I think that this new check should rely on parsed result and make exceptions exactly for SuppressMessage attribute, not for any text whithin source code which could look like attribute declaration.

Best regards,
Oleg Shuruev