Skip to content

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 area-Extensions-Logging community-contribution Indicates that the PR has been added by a community member labels 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
Contributor

@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
Contributor

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
Contributor

@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
Contributor

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

@maryamariyan
Copy link
Contributor

/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
Contributor

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