Cysharp / ZLogger

Zero Allocation Text/Structured Logger for .NET with StringInterpolation and Source Generator, built on top of a Microsoft.Extensions.Logging.
MIT License
1.11k stars 79 forks source link

Possible symbol name collisions in generated code #139

Closed ltrzesniewski closed 5 months ago

ltrzesniewski commented 5 months ago

I noticed that the generator can use the wrong type in the emitted code when the enclosing namespace defines a LogLevel enum for instance:

image

This may also be caused by several other types such as JsonEncodedText, Unsafe or EventId for instance.

Adding global:: with the full namespace everywhere would fix this, but I'm not sure if you want to do that given the chance for this problem to occur is quite low, so feel free to close this issue. I wanted to notify you just in case.

The problem can be bypassed by the user by generating the messages in a separate namespace.

neuecc commented 5 months ago

thanks for reporting, I'll check soon.

hadashiA commented 5 months ago

I have taken care of this issue in #144. We changed most of the conflict-prone symbols to fullname. (although it may not be perfect).