Roslyn: Support SuppressMessageAttribute suppression for compiler diagnostics

Created on 30 Oct 2015  路  6Comments  路  Source: dotnet/roslyn

Compiler diagnostics only respect in source pragma suppressions. This causes lot of nuances for bulk suppression/baselining feature. Additionally, the user experience for suppressing individual or bulk diagnostics from error list is also affected:

  1. If user selects one compiler and one analyzer warning - the suppress in suppressions file command can only work for the latter. User has to repeat the exercise again, with suppress in source command to get compiler warning suppressed.
  2. Bulk suppressing multiple compiler diagnostics adds lot of clutter to source code if done via pragma suppressions.

We should work with the compiler team to enable this functionality post 1.1

Area-Compilers Bug

Most helpful comment

馃挱 Considering a non-empty set analyzers are eventually going to ship by default in the SDK and those analyzers respect SuppressMessageAttribute, one could argue that the performance overhead of respecting SuppressMessageAttribute in compilation scenarios is no longer opt-in. At some point, this may provide sufficient justification for respecting the attribute for compiler diagnostics.

All 6 comments

We've talked about this before and decided against it but given the arguments above for baselining, moving to the compiler team for reconsideration.

Bumping this, because I got fooled.

It appears that the SupressMessageAttribute works if you're in VisualStudio and have the file open, as it helpfully does not display them in the warnings error list, but they still appear in MSBuild output.

Bumping this up again as it seems that the IDE behavior will be fixed as per #39094.
Still, the difference in behavior for analyzer and compiler diagnostics is weird for users. Also I couldn't find docs explaining it. This causes confusion and makes the language harder to use.

馃挱 Considering a non-empty set analyzers are eventually going to ship by default in the SDK and those analyzers respect SuppressMessageAttribute, one could argue that the performance overhead of respecting SuppressMessageAttribute in compilation scenarios is no longer opt-in. At some point, this may provide sufficient justification for respecting the attribute for compiler diagnostics.

I encounter this over and over.
I don't like the pragma style which makes me feel like a C++ developer when I'm supposed to write C#.
Attributes are scope based, so I can suppress once per method or class, without having to restore - hence doubling my code uglification.

Related

Was this page helpful?
0 / 5 - 0 ratings