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] warning CS8785: Generator 'LoggerMessageGenerator' failed to generate source. #77525

Closed
Tracked by #77390 ...
pengweiqhca opened this issue Oct 27, 2022 · 9 comments
Closed
Tracked by #77390 ...
Labels
area-Extensions-Logging needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration
Milestone

Comments

@pengweiqhca
Copy link

pengweiqhca commented Oct 27, 2022

Description

LoggerMessageGenerator not support [Obsolete] with argment(s).

Reproduction Steps

public static partial class LoggerExtensions
{
	[LoggerMessage((int)LogLevel.Trace, LogLevel.Trace, "{Msg}")]
	[Obsolete("test")]
	public static partial void Trace(this ILogger logger, string msg, Exception? ex = null);
}

Expected behavior

Not error.

Actual behavior

warning CS8785: Generator 'LoggerMessageGenerator' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type 'InvalidCastException' with message 'Specified cast is not valid.'

Regression?

No response

Known Workarounds

Delete [Obsolete] argment.

Configuration

No response

Other information

No response

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

ghost commented Oct 27, 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

LoggerMessageGenerator not support [Obsolete] with parameter.

Reproduction Steps

public static partial class LoggerExtensions
{
	[LoggerMessage((int)LogLevel.Trace, LogLevel.Trace, "{Msg}")]
	[Obsolete("test")]
	public static partial void Trace(this ILogger logger, string msg, Exception? ex = null);
}

Expected behavior

Not error.

Actual behavior

warning CS8785: Generator 'LoggerMessageGenerator' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type 'InvalidCastException' with message 'Specified cast is not valid.'

Regression?

No response

Known Workarounds

Delete [Obsolete] parameter.

Configuration

No response

Other information

No response

Author: pengweiqhca
Assignees: -
Labels:

untriaged, area-Extensions-Logging

Milestone: -

@danmoseley
Copy link
Member

Thanks for the report. Would you be interested to offer a PR?

@maryamariyan maryamariyan removed the untriaged New issue has not been triaged by the area owner label Nov 1, 2022
@maryamariyan maryamariyan added this to the 8.0.0 milestone Nov 1, 2022
@maryamariyan maryamariyan changed the title warning CS8785: Generator 'LoggerMessageGenerator' failed to generate source. [LSG] warning CS8785: Generator 'LoggerMessageGenerator' failed to generate source. Nov 16, 2022
@allantargino
Copy link
Contributor

I wasn't able to reproduce this error using Microsoft.Extensions.Logging version 7.0.0.

I don't get any compilation errors, and I can confirm the annotations are being added by the compiler to the assembly:
image

Do you have more information about your environment/runtime?

@pengweiqhca
Copy link
Author

@allantargino Sorray, I test again, dotnet sdk 7.0.100, Microsoft.Extensions.Logging 7.0.0 no error, 6.0.0 is error.

@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Dec 20, 2022
@tarekgh
Copy link
Member

tarekgh commented Dec 22, 2022

@allantargino @pengweiqhca how this is important to port to 6.0? We have a servicing bar which needs some justification to port it. I am seeing there is an easy workaround to reference 7.0 version of the logging libraries. right?

@tarekgh tarekgh added the needs-author-action An issue or pull request that requires more info or actions from the author. label Dec 22, 2022
@ghost
Copy link

ghost commented Dec 22, 2022

This issue has been marked needs-author-action and may be missing some important information.

@pengweiqhca
Copy link
Author

I have solved in other way. But I think it's a compatibility issue, and .NET 6 still servicing.

@ghost ghost added needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration and removed needs-author-action An issue or pull request that requires more info or actions from the author. labels Dec 23, 2022
@allantargino
Copy link
Contributor

@tarekgh I'd say this isn't a critical fix. Like you said, the workaround is just to reference the new version. Given it doesn't have any breaking changes, I believe it is fair to not port it back.

@tarekgh
Copy link
Member

tarekgh commented Dec 25, 2022

Per the replies I am going to close this issue and the PR and we can consider the porting to 6.0 if we see more demands on it in the future.

@tarekgh tarekgh closed this as completed Dec 25, 2022
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Dec 25, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Jan 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Extensions-Logging needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration
Projects
None yet
Development

No branches or pull requests

5 participants