Consolidate C# code snippets from kurnakovv's PRs into single compilable project #49420
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR consolidates C# code snippets from 17 of @kurnakovv's open pull requests into the existing
all-rules
project, creating a single compilable code base for all the code analysis rule examples.Problem
Multiple open PRs from @kurnakovv are adding C# code examples for various CA (Code Analysis) rules. These snippets were scattered across different PRs and needed to be consolidated into a single project to ensure they:
Solution
Added 17 new C# snippet files to the existing
all-rules.csproj
project atdocs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/
:Files Added
Implementation Details
Special Handling
Some snippets (ca2224, ca2226) demonstrate code that intentionally violates rules in ways that would prevent compilation. These were handled by:
/* */
comments#pragma warning
directives to suppress expected analyzer warningsThis approach allows the documentation to show both incorrect and correct code while maintaining a compilable project.
Testing
dotnet build
Related PRs
This consolidates code snippets from the following open PRs by @kurnakovv:
#48959, #48961, #48963, #48965, #48967, #49034, #49036, #49038, #49040, #49059, #49061, #49063, #49065, #49087, #49090, #49107, #49110
Note: PRs #49042, #49088, and #49092 were reviewed but contain only fixes to existing code or inline markdown examples, not new snippet files.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.