Summary
Add a Roslyn analyzer rule that detects [SuppressMessage] attributes (and potentially #pragma warning disable) and reports them as errors, unless they are in an explicitly allowed list.
Background
Per project policy, warnings should never be suppressed without explicit permission. An analyzer to enforce this would prevent suppressions from being silently introduced by developers or AI agents.
This was raised from a code review on credfeto/credfeto-changlog-manager#281 where [SuppressMessage] was used to silence MA0045/VSTHRD002/CA2012 instead of fixing the underlying async code structure.
Proposed Behaviour
- Error when a
[SuppressMessage] attribute is present on any type or member
- Optionally, an explicit allowlist of checkIds that are permitted (e.g. CA1812 for DI-registered internal classes)
- Should cover both attribute form (
[SuppressMessage(...)]) and pragma form (#pragma warning disable XXXXX)
References
Summary
Add a Roslyn analyzer rule that detects
[SuppressMessage]attributes (and potentially#pragma warning disable) and reports them as errors, unless they are in an explicitly allowed list.Background
Per project policy, warnings should never be suppressed without explicit permission. An analyzer to enforce this would prevent suppressions from being silently introduced by developers or AI agents.
This was raised from a code review on credfeto/credfeto-changlog-manager#281 where
[SuppressMessage]was used to silence MA0045/VSTHRD002/CA2012 instead of fixing the underlying async code structure.Proposed Behaviour
[SuppressMessage]attribute is present on any type or member[SuppressMessage(...)]) and pragma form (#pragma warning disable XXXXX)References