Skip to content

LoggerMessageAttribute generated source does not respect escaped characters and does not compile #56203

@JakenVeina

Description

@JakenVeina

Description

The source code generated for the following log method does not compile.

[LoggerMessage(
    EventId = 1,
    Level   = LogLevel.Debug,
    Message = "This is a log message: \"{Value1}\"")]
public static partial void SomeEvent(ILogger logger, string value1, string value2);

The fact that this log method includes parameters that are not encoded into Message forces a custom log state type to be generated, with the following code:

public override string ToString()
{
    var Value1 = this._value1;

    return $"This is a log message: "{Value1}"";
}

Configuration

Running .NET SDK 6.0.100-preview.6.21355.2 with version 6.0.0-preview.6.21352.12 of Microsoft.Extensions.Logging.Abstractions.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions