Add example section to CA2017 documentation with C# and VB code snippets #48743
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.
Fixes #[issue-number] by adding comprehensive examples to the CA2017 code analysis rule documentation.
Changes Made
Added an Example section to the CA2017 documentation (
ca2017.md
) that demonstrates both violations and correct usage of logging message templates with parameter count mismatches.Code Snippets Added
C# Example (
snippets/csharp/all-rules/ca2017.cs
):VB Example (
snippets/vb/all-rules/ca2017-parameter-count-mismatch_1.vb
):Project Updates
Microsoft.Extensions.Logging
package dependency to both C# and VB snippet projectsVerification
The code snippets compile successfully and correctly trigger CA2017 warnings on the violating lines, demonstrating the rule's behavior in real scenarios. This provides users with clear, actionable examples of when the rule fires and how to resolve violations.
The examples cover common scenarios developers encounter when working with structured logging in .NET applications, making the documentation more helpful and practical.
Additional instructions:
Fixes #47980
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.
Internal previews