Skip to content

LoggerMessage generator generates invalid code for a parameter #69893

@maxkoshevoi

Description

@maxkoshevoi

Description

Possibly related to #69490

Reproduction Steps

  1. Try compiling this code
[LoggerMessage(Level = LogLevel.Information, Message = "No recipients. DiscussionId={DiscussionId} AlertType={AlertType}")]
public static partial void LogNoDicusionRecipients(this ILogger logger, string alertType, int discusionId);
  1. See that generator haven't generated var DiscussionId = this._discusionId; line:

image

Expected behavior

Generator generates valid code

Actual behavior

Generator generates code that doesn't compile

Regression?

No response

Known Workarounds

No response

Configuration

  • .NET 6.0.300
  • Windows 11
  • VS 17.2.2
  • Microsoft.Extensions.Logging.Generators 6.0.6.21309

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions