Skip to content

Latest commit

 

History

History
22 lines (16 loc) · 719 Bytes

File metadata and controls

22 lines (16 loc) · 719 Bytes

Message template is not a compile time constant

Noncompliant Code Examples:

Log.Error($"Disk quota {quota} MB exceeded by {user}");
Log.Error(string.Format("Disk quota {0} MB exceeded by {1}", quota, user));

Compliant Solution:

Log.Error("Disk quota {Quota} MB exceeded by {User}", quota, user);

Also applies to custom logging wrappers.

Does not apply to ZLogger 2.x ZLog* calls: their template parameter is an interpolated string handler, so the interpolation is the template and it is prepared at compile time. An interpolated string passed to a ZLogger 1.x format parameter is still reported.