Skip to content

feat(DC0011): require a comment on pragma warning disable directives - #588

Merged
Arthurvdv merged 2 commits into
ALCops:mainfrom
tkroes:feat/dc0011-pragma-disable-requires-comment
Oct 20, 2026
Merged

Arthurvdv merged 2 commits into
ALCops:mainfrom
tkroes:feat/dc0011-pragma-disable-requires-comment

Conversation

@tkroes

@tkroes tkroes commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds DocumentationCop rule DC0011 PragmaDisableRequiresComment, ported from an internal rule.

Reports #pragma warning disable directives without a comment explaining why the warning is disabled.

  • Category Style, Info severity, enabled by default; no CodeFix, not configurable
  • Checks disable pragmas only; restore pragmas are ignored
  • Accepts a non-empty trailing // comment or a standalone // / /* */ comment on the line directly above
  • A trailing comment on the preceding code line does not count

Notes

  • A block comment written on the pragma line itself is parsed as skipped tokens, so only // is recognised there. This follows the original rule's treatment of comments.
  • The comment above a stack of pragmas documents only the first pragma.
  • Rule doc: .claude/rules/diagnostics/dc0011-pragma-disable-requires-comment.md.
  • Docs-site page (alcops.dev repo) remains to be written.

Validation

  • 8 new tests; full DocumentationCop suite passes (99)
  • dotnet format --verify-no-changes clean
  • Release build with ContinuousIntegrationBuild=true succeeds
  • Validate-Rules.ps1 passes; /code-review found no issues

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

@Arthurvdv Arthurvdv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! Two small cleanups, both with ready-to-apply suggestions.

Comment thread src/ALCops.DocumentationCop/Analyzers/PragmaDisableRequiresComment.cs Outdated
Comment thread src/ALCops.DocumentationCop/Analyzers/PragmaDisableRequiresComment.cs Outdated
Co-authored-by: Arthur van de Vondervoort <44637996+Arthurvdv@users.noreply.github.com>
@tkroes

tkroes commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

I've applied your suggestions, they both seemed like sensible fixes 🙂

@Arthurvdv

Copy link
Copy Markdown
Member

Great, let's get this merged!

@Arthurvdv
Arthurvdv merged commit 3aaf345 into ALCops:main Oct 20, 2026
52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants