-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Fix compilation error with generic type attributes #97613
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
Conversation
|
Tagging subscribers to this area: @dotnet/area-extensions-logging Issue DetailsStrip generic type parameter attributes from partial classes emitted by the logging source generator to avoid CS0579 errors from duplicate attributes. Fixes #97498.
|
|
@martincostello The original issue reported in #97498 was about I expect to fix this by fully qualifying the attribute in the emitted source. What exactly causes |
|
CC @eerhardt if you have any input for this. |
Having the attributes defined in both partial classes, it just flat-out doesn't compile. Adding the usings/fully-qualifying just causes a new CS0579 error. As far as I can tell, only one partial class can annotate the type parameters, so the generator shouldn't emit them and leave it up to the user's code to do so. That's what this PR does. |
|
@martincostello I see what you are saying now. Thanks for clarification. |
src/libraries/Microsoft.Extensions.Logging.Abstractions/gen/LoggerMessageGenerator.Parser.cs
Outdated
Show resolved
Hide resolved
src/libraries/Microsoft.Extensions.Logging.Abstractions/gen/LoggerMessageGenerator.Parser.cs
Outdated
Show resolved
Hide resolved
...ns/tests/Microsoft.Extensions.Logging.Generators.Tests/LoggerMessageGeneratorEmitterTests.cs
Outdated
Show resolved
Hide resolved
tarekgh
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @martincostello for your help providing the fix!
|
@tarekgh No problem! Is this change something that could be considered for backporting to 8.0 after merge? We have a base library targeting This issue blocks us from adopting native AoT there without significant refactoring of all the logging in that library, which in turn blocks all the apps built on top of it. |
I can check if this is meeting the servicing bar. Let's get this first in the main and then we can follow-up to see if we can port it to servicing. CC @ericstj |
Strip generic type parameter attributes from partial classes emitted by the logging source generated to avoid CS0579 errors from duplicate attributes. Fixes dotnet#97498.
Update comment as suggested by code review.
Verify that attributes on generic type parameters are not lost.
e452e4d to
b800efc
Compare
|
/backport to release/8.0-staging |
|
Started backporting to release/8.0-staging: https://github.com/dotnet/runtime/actions/runs/7716311245 |
|
@martincostello this is now ported to servicing branch. Will be released around March. |
|
@tarekgh Thanks! ❤️ |
Strip generic type parameter attributes from partial classes emitted by the logging source generator to avoid CS0579 errors from duplicate attributes.
Fixes #97498.