From 29b6fb76141ad5c81883a418a5a90c1356be11ff Mon Sep 17 00:00:00 2001 From: abhiramch018 Date: Wed, 26 Nov 2025 14:12:59 +0530 Subject: [PATCH 1/2] Update ca1873.md --- docs/fundamentals/code-analysis/quality-rules/ca1873.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/fundamentals/code-analysis/quality-rules/ca1873.md b/docs/fundamentals/code-analysis/quality-rules/ca1873.md index 3124289584046..706616e9fe9fc 100644 --- a/docs/fundamentals/code-analysis/quality-rules/ca1873.md +++ b/docs/fundamentals/code-analysis/quality-rules/ca1873.md @@ -30,14 +30,15 @@ In many situations, logging is disabled or set to a log level that results in an ## Rule description -When logging methods are called, their arguments are evaluated regardless of whether the logging level is enabled. This can result in expensive operations being executed even when the log message won't be written. For better performance, guard expensive logging calls with a check to or use the `LoggerMessage` pattern. +When logging methods are called, their arguments are evaluated regardless of whether the logging level is enabled. This can result in expensive operations being executed even when the log message won't be written. For better performance, guard expensive logging calls with a check to or use **source-generated logging** with the attribute. + ## How to fix violations To fix a violation of this rule, use one of the following approaches: - Guard the logging call with a check to . -- Use the `LoggerMessage` pattern with . +- Use **source-generated logging** with the attribute for better performance and compile-time safety. - Ensure expensive operations aren't performed in logging arguments unless necessary. ## Example From 25bf61e5b84f30426af0d97ce180daf77d790aa6 Mon Sep 17 00:00:00 2001 From: "Meaghan Osagie (Lewis)" Date: Wed, 26 Nov 2025 10:58:57 -0800 Subject: [PATCH 2/2] Remove extra line --- docs/fundamentals/code-analysis/quality-rules/ca1873.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/fundamentals/code-analysis/quality-rules/ca1873.md b/docs/fundamentals/code-analysis/quality-rules/ca1873.md index 706616e9fe9fc..6ae965935c274 100644 --- a/docs/fundamentals/code-analysis/quality-rules/ca1873.md +++ b/docs/fundamentals/code-analysis/quality-rules/ca1873.md @@ -32,7 +32,6 @@ In many situations, logging is disabled or set to a log level that results in an When logging methods are called, their arguments are evaluated regardless of whether the logging level is enabled. This can result in expensive operations being executed even when the log message won't be written. For better performance, guard expensive logging calls with a check to or use **source-generated logging** with the attribute. - ## How to fix violations To fix a violation of this rule, use one of the following approaches: