Add tag for diagnostics that need to be suppressed with `[UnconditionalSuppressMessage]`.
- Dominant language
- C#
- Stars
- 20.7k
- Forks
- 4.3k
- PR merge metrics
- PR metrics pending
Description
## Background and Motivation
Some analyzers like the trimming and AOT compatibility analyzers, emit diagnostics that would also be emitted by external tools, and therefore would require `[UnconditionalSuppressMessage]` in order for them to be suppressed. However, suppressing them from the IDE generates either a `#pragma warning disable`, a `[SuppressMessage]` or changes to the `.editorconfig`, none of which will be seen by the external tool.
I am proposing a new entry in the `WellKnownDiagnosticTags` class, that will instruct IDEs to suppress diagnostics tagged with it using `[UnconditionalSuppressMessage]`. Additionally:
* IDEs will _not_ suggest suppressing the diagnostic with `#pragma warning disable`, or configuring its severity in the `.editorconfig`.
* If `UnconditionalSuppressMessageAttribute` is not available, we can either ignore the tag, or not suggest suppressing the diagnostic at all.
* Optionally, we can report a warning if the user attempts to do any of the above, indicating that the suppression will not be entirely effective.
## Proposed API
```diff
namespace Microsoft.CodeAnalysis
{
public static WellKnownDiagnosticTags
{
+ public const string RequiresUnconditionalSuppression = nameof(RequiresUnconditionalSuppression);
}
}
```
## Usage Examples
``` C#
// some lines of code here
```
## Alternative Designs
## Risks
None that I can think of. Roslyn already recognizes `[UnconditionalSuppressMessage]`; this proposal adds better IDE integration for it.
Contributor guide
Assessment
This issue has not been assessed yet.