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 should support generic methods (SYSLIB1011 should be lifted) #90589
This seems to be an unnecessary restriction that also works against the whole notion of high-performance logging.
I would like to be able to write a logging method like so:
[LoggerMessage(0,LogLevel.Trace,"C -> S {EndPoint}: {Channel}:{Code} ({Length} bytes)")]publicstaticpartialvoidPacketReceived<TCode>(ILoggerlogger,IPEndPointendPoint,ConnectionChannelchannel,TCodecode,intlength)whereTCode:struct,Enum;
Here, the type argument for TCode depends on the value of Channel. Of course, I could make the logging method non-generic and accept an Enum-typed value, but then I get unconditional boxing... certainly not what I want when logging in a fairly hot path. Alternatively, I could duplicate the method for as many TCodes as I have (which is what I'll do for now), but this is not great either, for all the expected maintenance reasons.
I think this restriction should just be lifted. Maybe there's a good reason for it, but if there is, it's not obvious to me.
Reacted by Felix Deierlein, Meir Blachman, Francisco Vilches, Paweł Słowik, Linus Sundqvist, Daniel Kovacs, Pavel Voronin, Anton Egorov and jogivanknobi
Reacted by Copilot
Activity
ghost added
untriagedNew issue has not been triaged by the area owner
Activity
cincuranet commentedon Feb 10, 2026
Triage: Niche scenario, but would be nice to have it one day.
Logging source generator: support generic methods (lift SYSLIB1011) (#…