Skip to content

Add applicable languages to CA and IDE code analysis rule documentation#52773

Merged
gewarren merged 9 commits intomainfrom
copilot/add-language-support-to-ca-docs
Apr 1, 2026
Merged

Add applicable languages to CA and IDE code analysis rule documentation#52773
gewarren merged 9 commits intomainfrom
copilot/add-language-support-to-ca-docs

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 31, 2026

CA quality rules lacked any indication of which .NET languages they apply to, unlike IDE style rules which had the info but as inconsistent hard-coded text.

Approach

CA rules (336 files)

Added | **Applicable languages** | row to every CA rule property table, sourcing the language from dev_langs frontmatter. Rules without dev_langs default to C# and Visual Basic (consistent with the issue comment that most rules apply to both).

| **Enabled by default in .NET 10**   | No                                             |
| **Applicable languages** | C# and Visual Basic |

IDE rules (119 files)

Added or standardized | **Applicable languages** | rows with inline language text.

The language text used across all files:

  • C# and Visual Basic — rules applying to both languages
  • C# — C#-only rules
  • Visual Basic — VB-only rules
  • C# 8+, C# 9+, C# 11+, C# 12+, C# 13+, C# 14+ — version-specific C# rules
  • F# — F#-only rules

Internal previews

Note

This table shows preview links for the 30 files with the most changes. For preview links for other files in this PR, select OpenPublishing.Build Details within checks.


Internal previews

Toggle expand/collapse
📄 File 🔗 Preview link
docs/fundamentals/code-analysis/quality-rules/ca1000.md CA1000: Do not declare static members on generic types
docs/fundamentals/code-analysis/quality-rules/ca1001.md "CA1001: Types that own disposable fields should be disposable (code analysis)"
docs/fundamentals/code-analysis/quality-rules/ca1002.md CA1002: Do not expose generic lists
docs/fundamentals/code-analysis/quality-rules/ca1003.md docs/fundamentals/code-analysis/quality-rules/ca1003
docs/fundamentals/code-analysis/quality-rules/ca1005.md CA1005: Avoid excessive parameters on generic types
docs/fundamentals/code-analysis/quality-rules/ca1008.md "CA1008: Enums should have zero value (code analysis)"
docs/fundamentals/code-analysis/quality-rules/ca1010.md CA1010: Collections should implement generic interface
docs/fundamentals/code-analysis/quality-rules/ca1012.md docs/fundamentals/code-analysis/quality-rules/ca1012
docs/fundamentals/code-analysis/quality-rules/ca1014.md CA1014: Mark assemblies with CLSCompliantAttribute
docs/fundamentals/code-analysis/quality-rules/ca1016.md "CA1016: Mark assemblies with AssemblyVersionAttribute (code analysis)"
docs/fundamentals/code-analysis/quality-rules/ca1017.md CA1017: Mark assemblies with ComVisibleAttribute
docs/fundamentals/code-analysis/quality-rules/ca1018.md docs/fundamentals/code-analysis/quality-rules/ca1018
docs/fundamentals/code-analysis/quality-rules/ca1019.md CA1019: Define accessors for attribute arguments
docs/fundamentals/code-analysis/quality-rules/ca1021.md "CA1021: Avoid out parameters (code analysis)"
docs/fundamentals/code-analysis/quality-rules/ca1024.md CA1024: Use properties where appropriate
docs/fundamentals/code-analysis/quality-rules/ca1027.md docs/fundamentals/code-analysis/quality-rules/ca1027
docs/fundamentals/code-analysis/quality-rules/ca1028.md CA1028: Enum storage should be Int32
docs/fundamentals/code-analysis/quality-rules/ca1030.md "CA1030: Use events where appropriate (code analysis)"
docs/fundamentals/code-analysis/quality-rules/ca1031.md CA1031: Do not catch general exception types
docs/fundamentals/code-analysis/quality-rules/ca1032.md docs/fundamentals/code-analysis/quality-rules/ca1032
docs/fundamentals/code-analysis/quality-rules/ca1033.md CA1033: Interface methods should be callable by child types
docs/fundamentals/code-analysis/quality-rules/ca1034.md "CA1034: Nested types should not be visible (code analysis)"
docs/fundamentals/code-analysis/quality-rules/ca1036.md CA1036: Override methods on comparable types
docs/fundamentals/code-analysis/quality-rules/ca1040.md docs/fundamentals/code-analysis/quality-rules/ca1040
docs/fundamentals/code-analysis/quality-rules/ca1041.md CA1041: Provide ObsoleteAttribute message
docs/fundamentals/code-analysis/quality-rules/ca1043.md "CA1043: Use integral or string argument for indexers (code analysis)"
docs/fundamentals/code-analysis/quality-rules/ca1044.md CA1044: Properties should not be write only
docs/fundamentals/code-analysis/quality-rules/ca1045.md docs/fundamentals/code-analysis/quality-rules/ca1045
docs/fundamentals/code-analysis/quality-rules/ca1046.md CA1046: Do not overload operator equals on reference types
docs/fundamentals/code-analysis/quality-rules/ca2227.md "CA2227: Collection properties should be read only (code analysis)"

Note

This table shows preview links for the 30 files with the most changes. For preview links for other files in this PR, select OpenPublishing.Build Details within checks.

Copilot AI changed the title [WIP] Add applicable languages to CA rules documentation Add applicable languages to CA and IDE code analysis rule documentation Mar 31, 2026
Copilot AI requested a review from BillWagner March 31, 2026 16:34
@BillWagner
Copy link
Copy Markdown
Member

@copilot can you resolve the merge conflict in docs/fundamentals/code-analysis/quality-rules/ca2227.md.

…pplicable languages row

Agent-Logs-Url: https://github.com/dotnet/docs/sessions/76230132-17e1-479d-8549-7e818f206cb7

Co-authored-by: BillWagner <493969+BillWagner@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 31, 2026

@copilot can you resolve the merge conflict in docs/fundamentals/code-analysis/quality-rules/ca2227.md.

Resolved in commit 3734214967. Took the updated version from main (which had rewritten "How to fix violations" content, new ms.date: 03/30/2026, and ai-usage: ai-assisted frontmatter) and added the | **Applicable languages** | row to it.

Copy link
Copy Markdown
Member

@BillWagner BillWagner left a comment

Choose a reason for hiding this comment

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

I'll admit I didn't check every rule, but spot checked many of them.

This LGTM.

Note to reviewers: Hide whitespace.

@BillWagner BillWagner marked this pull request as ready for review March 31, 2026 19:44
@BillWagner BillWagner requested review from a team and gewarren as code owners March 31, 2026 19:44
Copilot AI review requested due to automatic review settings March 31, 2026 19:44
Co-authored-by: Bill Wagner <wiwagn@microsoft.com>
Copy link
Copy Markdown
Member

@BillWagner BillWagner left a comment

Choose a reason for hiding this comment

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

@copilot

I have two sets of changes to make this build correctly.

…use csharp-8 and csharp-9

Agent-Logs-Url: https://github.com/dotnet/docs/sessions/a4bbba80-c77f-4448-a785-8a2a000d54b0

Co-authored-by: BillWagner <493969+BillWagner@users.noreply.github.com>
Copilot AI requested a review from BillWagner March 31, 2026 20:02
Copy link
Copy Markdown
Contributor

@gewarren gewarren left a comment

Choose a reason for hiding this comment

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

I'm not crazy about using include files for these. Do you think it's a good idea?

@BillWagner
Copy link
Copy Markdown
Member

I'm not crazy about using include files for these. Do you think it's a good idea?

@gewarren I thought that would remove duplication, with only a few phrases needed. I don't have strong feelings either way. Easy to tell copilot to switch it.

@BillWagner
Copy link
Copy Markdown
Member

@copilot Per the discussion above, update this PR to place the text for applicable language inline in each article, and remove the include files added in this PR.

…nclude files

Agent-Logs-Url: https://github.com/dotnet/docs/sessions/07609c45-9d95-46c0-bafb-c533994a8507

Co-authored-by: BillWagner <493969+BillWagner@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 1, 2026

@copilot Per the discussion above, update this PR to place the text for applicable language inline in each article, and remove the include files added in this PR.

Done in commit 8efe90c5. Replaced all [!INCLUDE[applicable-languages-*]] directives with inline text across all 438 files, and deleted all 10 applicable-languages-*.md include files.

@BillWagner
Copy link
Copy Markdown
Member

@copilot Many of the assignments to language are incorrect. You'll need to look in this file to find the correct answer: https://github.com/dotnet/sdk/blob/main/src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.NetAnalyzers.sarif

The devlang slug indicates which language the samples are displayed in. It has no bearing on the rules themselves.

Make the necessary updates.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 1, 2026

@copilot Many of the assignments to language are incorrect. You'll need to look in this file to find the correct answer: https://github.com/dotnet/sdk/blob/main/src/Microsoft.CodeAnalysis.NetAnalyzers...

Fixed in commit a959367e. Used Microsoft.CodeAnalysis.NetAnalyzers.sarif as the source of truth — rules in the Microsoft.CodeAnalysis.CSharp.NetAnalyzers run only are C#, rules in the Microsoft.CodeAnalysis.VisualBasic.NetAnalyzers run only are Visual Basic, and all others are C# and Visual Basic. 62 rules corrected:

  • 59 rules: C#C# and Visual Basic (had dev_langs: csharp for code samples but apply to both languages)
  • CA2020: C# and Visual BasicC#
  • CA2224: C# and Visual BasicVisual Basic
  • CA2260: C# and Visual BasicC#

@gewarren gewarren enabled auto-merge (squash) April 1, 2026 21:47
@gewarren gewarren merged commit b137906 into main Apr 1, 2026
11 checks passed
@gewarren gewarren deleted the copilot/add-language-support-to-ca-docs branch April 1, 2026 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add applicable languages to CA rules documentation

3 participants