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

Allow use of overloaded methods when using LoggerMessage #64573

Merged
merged 3 commits into from
Feb 2, 2022

Conversation

JakeYallop
Copy link
Contributor

Fixes #61814

Computes a unique name for LoggerMethods, allowing for overloaded methods to be used with the source generator.

Calculates and assigns a unique LoggerMethod name as required, and uses
this new unique name for generating types in the source generator. This
allows using the LoggerMessageAttribute on methods that share the same
name but have different method signatures.

Fix dotnet#61814
@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Jan 31, 2022
@ghost
Copy link

ghost commented Jan 31, 2022

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

Issue Details

Fixes #61814

Computes a unique name for LoggerMethods, allowing for overloaded methods to be used with the source generator.

Author: JakeYallop
Assignees: -
Labels:

area-Extensions-Logging

Milestone: -

@dnfadmin
Copy link

dnfadmin commented Jan 31, 2022

CLA assistant check
All CLA requirements met.

Copy link
Member

@maryamariyan maryamariyan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Nice work.

@maryamariyan
Copy link
Member

This could be merged once you get a chance to apply the minor feedback in this PR.

@maryamariyan maryamariyan self-assigned this Feb 1, 2022
Also resolves other PR feedback, an extra blank line and incorrect use
of an implicit type.
@JakeYallop
Copy link
Contributor Author

@maryamariyan

I've updated the PR based on feedback. The only thing left is the last two LoggerMessage overload tests - I've written a comment with my thinking on that - let me know if you still want me to remove them,

@maryamariyan
Copy link
Member

@JakeYallop Thanks for the quick turnaround.

I would still be tempted to remove the last two overloads. event name uniqueness is not currently being respected and I was thinking we should fix that first and just leave this PR to focus on overloads for now.

@JakeYallop
Copy link
Contributor Author

I've removed the tests.

@maryamariyan
Copy link
Member

Failures in CI seem unrelated and I also found them in #64593 and #64641

@maryamariyan
Copy link
Member

/backport to release/6.0

@github-actions
Copy link
Contributor

github-actions bot commented Feb 2, 2022

Started backporting to release/6.0: https://github.com/dotnet/runtime/actions/runs/1786697916

@github-actions
Copy link
Contributor

github-actions bot commented Feb 2, 2022

@maryamariyan backporting to release/6.0 failed, the patch most likely resulted in conflicts:

$ git am --3way --ignore-whitespace --keep-non-patch changes.patch

Applying: Compute unique method names for generated code
Using index info to reconstruct a base tree...
M	src/libraries/Microsoft.Extensions.Logging.Abstractions/gen/LoggerMessageGenerator.Emitter.cs
M	src/libraries/Microsoft.Extensions.Logging.Abstractions/gen/LoggerMessageGenerator.Parser.cs
Falling back to patching base and 3-way merge...
Auto-merging src/libraries/Microsoft.Extensions.Logging.Abstractions/gen/LoggerMessageGenerator.Parser.cs
Auto-merging src/libraries/Microsoft.Extensions.Logging.Abstractions/gen/LoggerMessageGenerator.Emitter.cs
CONFLICT (content): Merge conflict in src/libraries/Microsoft.Extensions.Logging.Abstractions/gen/LoggerMessageGenerator.Emitter.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Compute unique method names for generated code
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Error: The process '/usr/bin/git' failed with exit code 128

Please backport manually!

@eerhardt
Copy link
Member

eerhardt commented Feb 2, 2022

@maryamariyan - are we sure this needs to be backported to 6.0? It doesn't feel like this limitation is critical to fix in 6, but I guess I'd like your opinion/thoughts.

@maryamariyan
Copy link
Member

maryamariyan commented Feb 3, 2022

I assume it seems like a blocker to developers wanting to migrate to the logging source generator approach. Looking back at the issue doesn't seem like there'd been a lot of hits with this bug as much as there were for the @ prefixed issue. So I'd definitely service that one.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Extensions-Logging community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Logging Source Generator fails ungracefully with overloaded methods
4 participants