Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LSG] LoggerMessage source generator generates error when using template destructuring #69490

Closed
Tracked by #64015 ...
gingters opened this issue May 18, 2022 · 4 comments

Comments

@gingters
Copy link

Description

When using serilog object destructuring in a LoggerMessage template, the source generator won't recognize the parameter.

Reproduction Steps

Add this log message to a partial class:

[LoggerMessage(2020, LogLevel.Trace, "Transporting {@Response}")]
partial void LogTransporting(object response);

Expected behavior

The source generator should generate the logging method.

Actual behavior

The source generator creates an error: [SYSLIB1014] Template '@Response' is not provided as argument to the logging method

Regression?

No response

Known Workarounds

None. Using @ before the parameter name (as you would to escape reserved words) does not help.

Configuration

.NET 6.0.300

Other information

No response

@ghost ghost added the untriaged New issue has not been triaged by the area owner label May 18, 2022
@ghost
Copy link

ghost commented May 18, 2022

Tagging subscribers to this area: @dotnet/area-extensions-logging
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

When using serilog object destructuring in a LoggerMessage template, the source generator won't recognize the parameter.

Reproduction Steps

Add this log message to a partial class:

[LoggerMessage(2020, LogLevel.Trace, "Transporting {@Response}")]
partial void LogTransporting(object response);

Expected behavior

The source generator should generate the logging method.

Actual behavior

The source generator creates an error: [SYSLIB1014] Template '@Response' is not provided as argument to the logging method

Regression?

No response

Known Workarounds

None. Using @ before the parameter name (as you would to escape reserved words) does not help.

Configuration

.NET 6.0.300

Other information

No response

Author: gingters
Assignees: -
Labels:

untriaged, area-Extensions-Logging

Milestone: -

@maryamariyan maryamariyan added this to the 7.0.0 milestone May 24, 2022
@maryamariyan maryamariyan self-assigned this May 24, 2022
@ghost ghost removed the untriaged New issue has not been triaged by the area owner label May 24, 2022
@maryamariyan
Copy link
Member

Looking

@maryamariyan
Copy link
Member

fyi, as part of the bugfix in #60968 we fixed the sample case below:

    [LoggerMessage(EventId = 2020, Level = LogLevel.Trace, Message = "Transporting {Response}")]
    public static partial void LogTransporting(ILogger logger, string @response);

Where at sign goes over the method variable not the message template argument.
Wondering if it is a common scenario to have @ as part of the message templates. Also noticed an example in https://messagetemplates.org/

@maryamariyan maryamariyan added the help wanted [up-for-grabs] Good issue for external contributors label May 31, 2022
@maryamariyan maryamariyan removed their assignment Jun 6, 2022
@eerhardt eerhardt removed the help wanted [up-for-grabs] Good issue for external contributors label Jul 14, 2022
@eerhardt eerhardt modified the milestones: 7.0.0, Future Jul 20, 2022
@maryamariyan maryamariyan modified the milestones: Future, 8.0.0 Sep 28, 2022
@maryamariyan maryamariyan changed the title LoggerMessage source generator generates error when using template destructuring [LSG] - LoggerMessage source generator generates error when using template destructuring Nov 16, 2022
@maryamariyan maryamariyan changed the title [LSG] - LoggerMessage source generator generates error when using template destructuring [LSG] LoggerMessage source generator generates error when using template destructuring Nov 16, 2022
@tarekgh
Copy link
Member

tarekgh commented Jan 11, 2023

This should be already fixed by #79038

@tarekgh tarekgh closed this as completed Jan 11, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Feb 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants