You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Logging Source Generator fails ungracefully with overloaded methods #61814
The code compiles successfully. If the LoggerMessage generator explicitly does not support logging method overloads, then a diagnostic should be emitted instead.
Consider the following code, where an overload is specified without an EventName - should this compile?
The current behaviour of the source generator is to use the method name as the event name, this would emit logs with different event ids that share the same event name. If there are logging providers that rely on event names being unique, this could be problematic.
Actual behavior
Emits
LoggerMessage.g.cs(19,152,19,166): error CS0102: The type 'LoggerMessageGeneration' already contains a definition for '__Log1Callback".
Regression?
No
Known Workarounds
Do not use overloaded methods when using [LoggerMessage].
Configuration
> dotnet --info
.NET SDK (reflecting any global.json):
Version: 6.0.100
Commit: 9e8b04bbff
Runtime Environment:
OS Name: Windows
OS Version: 10.0.19043
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\6.0.100\
Host (useful for support):
Version: 6.0.0
Commit: 4822e3c3aa
@JakeYallop thanks for your interest. I have a fix prepared already. It also is addressing some other source generator feedback so we would end up having to keep either one of the two. I reviewed your PR in the meantime.
Activity
JakeYallop commentedon Jan 31, 2022
I'd love to take a look at providing a fix for this.
maryamariyan commentedon Feb 1, 2022
@JakeYallop thanks for your interest. I have a fix prepared already. It also is addressing some other source generator feedback so we would end up having to keep either one of the two. I reviewed your PR in the meantime.
Allow use of overloaded methods when using LoggerMessage (#64573)