Skip to content

feat: add analyzer to detect and flag SuppressMessage attributes #420

@dnyw4l3n13

Description

@dnyw4l3n13

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

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions