Add CA2266 analyzer documentation#53992
Conversation
There was a problem hiding this comment.
Pull request overview
Adds documentation for the new CA2266 analyzer rule (file-based apps shebang requirement) and connects the new rule page to the existing code analysis indexes, TOC navigation, and .NET 10 SDK “file-based apps” content so users can discover it.
Changes:
- Adds a new rule article for CA2266 under code quality rules.
- Updates rule indexes and the .NET 10 “enabled rules” table to include CA2266.
- Adds CA2266 to the tools diagnostics TOC and links to it from the .NET 10 SDK file-based apps section.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| docs/navigate/tools-diagnostics/toc.yml | Adds CA2266 to the Code quality → Usage rules navigation. |
| docs/fundamentals/code-analysis/quality-rules/usage-warnings.md | Adds CA2266 to the Usage rules index table. |
| docs/fundamentals/code-analysis/quality-rules/index.md | Adds CA2266 to the main quality rules index table. |
| docs/fundamentals/code-analysis/quality-rules/ca2266.md | New CA2266 rule documentation page (cause, guidance, suppression, and example). |
| docs/fundamentals/code-analysis/overview.md | Adds CA2266 to the .NET 10 enabled-by-default rules table. |
| docs/core/whats-new/dotnet-10/sdk.md | Links CA2266 from the .NET 10 file-based apps enhancements section. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
| ```csharp | ||
| #pragma warning disable CA2266 | ||
| // The code that's violating the rule is on this line. | ||
| #pragma warning restore CA2266 |
There was a problem hiding this comment.
It might be better to have #:property NoWarn=CA2266 since I'm not sure it's guaranteed the diagnostic will have any location.
There was a problem hiding this comment.
Updated in 7a6e07b to use a #:property NoWarn=CA2266 suppression example instead of #pragma.
|
|
||
| ## See also | ||
|
|
||
| [Build file-based apps](../../../csharp/fundamentals/tutorials/file-based-programs.md) |
There was a problem hiding this comment.
Consider linking the docs (core/sdk/file-based-apps.md) instead of the tutorial.
There was a problem hiding this comment.
Updated in 7a6e07b to link the file-based apps docs instead of the tutorial.
Related to dotnet/sdk#53749 (comment).
CA2266 was introduced for file-based apps, but the docs set did not include a rule page or links from the analyzer indexes. This change adds the missing rule documentation and wires it into the relevant .NET 10 and code analysis entry points.
New rule article
CA2266: File-based program entry point should start with '#!'Analyzer index updates
Navigation and discovery
Example
Internal previews