-
Notifications
You must be signed in to change notification settings - Fork 6k
Fix CA1848 documentation: Update link and add code examples #47579
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Update LoggerMessage link to point to high-performance logging article - Add before/after code examples showing CA1848 violation and fix - Examples demonstrate proper LoggerMessage pattern usage Co-authored-by: gewarren <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two code formatting nits, otherwise
Co-authored-by: David Pine <[email protected]>
PoliCheck Scan ReportThe following report lists PoliCheck issues in PR files. Before you merge the PR, you must fix all severity-1 issues. Other issues are also a high priority. The AI Review Details column lists suggestions for either removing or replacing the terms. If you find a false positive result, mention it in a PR comment and include this text: #policheck-false-positive. This feedback helps reduce false positives in future scans. ✅ No issues foundMore information about PoliCheckInformation: PoliCheck | Severity Guidance | Term |
This PR improves the CA1848 rule documentation by updating an incorrect link and adding practical code examples to help developers understand how to fix violations.
Changes Made
Updated LoggerMessage Link
The rule description previously linked to the
LoggerMessage
API documentation, but now correctly points to the high-performance logging article that provides comprehensive guidance on implementing the pattern:Microsoft.Extensions.Logging.LoggerMessage
API docs/dotnet/core/extensions/high-performance-logging
articleAdded Code Examples
Added clear before/after examples in the "How to fix violations" section showing:
Code that violates CA1848:
Corrected code using LoggerMessage pattern:
These examples demonstrate the key differences:
partial class
declarationILogger
extension method calls with generated delegate methods[LoggerMessage]
attribute to define the log message templateThe documentation now provides developers with concrete examples they can reference when fixing CA1848 violations in their code.
Fixes #46239.
💡 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.
Internal previews