A log message is built with string interpolation instead of a template

tx0/csharp:interpolated-log-messagestrictwarningperformance/iodepth fastperformance, smell

What it finds

logger.LogInformation($"Order {id}") formats the string even when the level is off, and gives structured logging a different message for every value instead of one template with named values. logger.LogInformation("Order {Id}", id) does neither.

From the rule's source, interpolated_log_message.rs.

Example from the rule's tests
using Microsoft.Extensions.Logging; class Shop{    private readonly ILogger logger;     void Sell(int id)    {        logger.LogInformation($"Sold {id}");tx0 reports: this log message is interpolated instead of a template with arguments        logger.LogInformation("Sold {Id}", id);    }}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/csharp:interpolated-log-message" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/csharp:interpolated-log-message] reason="..."

tx0 explain tx0/csharp:interpolated-log-message shows the same in the terminal. Found a false positive? Report it.