Skip to content

Conversation

@stephentoub
Copy link
Member

Clean cherry-pick of #51818 to release/10.0.1xx


Several improvements to the analyzer:

  • Property accesses are common in logging calls, and property accesses are supposed to be cheap. Avoid raising diagnostics for property accesses.
  • GetType/GetHashCode/GetTimestamp are used reasonably-frequently in logging calls; special-case them to avoid diagnostics for them.
  • The main reason this rule exists is to eliminate cost on hot paths. Generally such hot paths aren't raising warning/error/critical diagnostics, such that the more rare warning/errors don't need as much attention to overheads. As such, I've changed the checks to only kick in by default for information and below, with a configuration switch that can be used to override to what levels it applies.

Several improvements to the analyzer:

- Property accesses are common in logging calls, and property accesses are supposed to be cheap. Avoid raising diagnostics for property accesses.
- GetType/GetHashCode/GetTimestamp are used reasonably-frequently in logging calls; special-case them to avoid diagnostics for them.
- The main reason this rule exists is to eliminate cost on hot paths. Generally such hot paths aren't raising warning/error/critical diagnostics, such that the more rare warning/errors don't need as much attention to overheads. As such, I've changed the checks to only kick in by default for information and below, with a configuration switch that can be used to override to what levels it applies.
@stephentoub stephentoub requested a review from a team as a code owner November 21, 2025 01:30
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.

2 participants