Skip to content

CA1727 is not reported for LoggerMessageAttribute #6051

@DeKon0650

Description

@DeKon0650

Analyzer

Diagnostic ID: CA1727 : Use PascalCase for named placeholders

Analyzer source

SDK: Built-in CA analyzers in .NET 5 SDK or later

Version: SDK 6.0.301

Describe the bug

CA1727 is not reported for messages in LoggerMessageAttribute

Steps To Reproduce

  1. Make sure that CA1727 is enabled, e.g. by using <AnalysisMode>AllEnabledByDefault</AnalysisMode>
  2. Write a line like logger.LogError("Unsuccessful status code {statusCode}");
  3. Notice that CA1727 is shown.
  4. Remove the line and write a partial method with LoggerMessageAttribute like
[LoggerMessage(-1, LogLevel.Error, "Unsuccessful status code {statusCode}")]
private partial void LogUnsuccessfulStatusCode(HttpStatusCode statusCode);
  1. Notice that the warning is not shown any more.

Expected behavior

CA1727 should be shown.

Actual behavior

CA1727 is not shown.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions