A log message is built with string interpolation instead of a template
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.
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); }} 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:
[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.