S6678 — Use PascalCase for named placeholders

Language
C#
Type
Code smell
Severity
Minor
Tags
logging

Within a message template each named placeholder should be in PascalCase.

Why is this an issue?

Using consistent naming conventions is important for the readability and maintainability of code. In the case of message templates, using PascalCase for named placeholders ensures consistency with structured logging conventions, where each named placeholder is used as a property name in the structured data.

The rule covers the following logging frameworks:

How to fix it

Use PascalCase for named placeholders.

Code examples

Noncompliant code example


logger.LogDebug("User {firstName} logged in", firstName); // Noncompliant

Compliant solution


logger.LogDebug("User {FirstName} logged in", firstName); // Compliant

Resources

Documentation

↑ Back to top