Open mavasani opened 9 years ago
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.
There are scenarios where a source generator may add partial declarations which result in warnings on partial declarations in user code, which the source generator wants to suppress. SharpLab
If the compiler respected the SuppressMessageAttribute when issuing compiler diagnostics, the generator author could apply the attribute to the partial declaration they control and suppress the warning in the user's code.
This seems to be a really popular suggestion, but no love? Please resolve this because, as someone else has quite rightly pointed out - pragma's look like cancer in code :(
Tagging @jaredpar @jcouv - seems like a popular customer request, but last time @gafter looked at this feature, he was worried about performance implications around this. I am not sure those still hold given Sam's point: https://github.com/dotnet/roslyn/issues/6471#issuecomment-581162825
I would love to suppress compiler warnings using SuppressMessageAttribute
. It looks much nicer.
Would be great to have this feature #pragma
is a very jarring experience for devs when it shows up in code and the attribute would be much cleaner. 👍
Are there any news regarding this feature? I spent half an hour trying to suppress irrelevant CS8625 warnings in test classes using the SuppressMessage
attribute. And now I've found this 8.5 years old issue.
I guess I'll put exclamation marks everywhere, using #pragma
feels like using goto
, no way.
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:
We should work with the compiler team to enable this functionality post 1.1