Skip to content

Comments

Update logging source generator docs: SYSLIB1011 now scoped to allows ref struct only#51839

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/update-logging-source-generator-docs
Draft

Update logging source generator docs: SYSLIB1011 now scoped to allows ref struct only#51839
Copilot wants to merge 2 commits intomainfrom
copilot/update-logging-source-generator-docs

Conversation

Copy link
Contributor

Copilot AI commented Feb 23, 2026

dotnet/runtime#124638 removed the blanket ban on generic logging methods. SYSLIB1011 now fires only when a type parameter uses the C# 13 allows ref struct anti-constraint (unsupported because the generator stores parameters in struct fields).

Changes

  • syslib1011.md — Updated title, description, and workaround to reflect the narrowed restriction
  • source-generator-overview.md — Updated SYSLIB1011 table entry description
  • source-generation.md — Updated "Log method constraints" bullet: generic methods are now valid; only allows ref struct is restricted

What's now valid

// Now works — no SYSLIB1011
[LoggerMessage(0, LogLevel.Trace, "Channel {Channel}: {Code}")]
public static partial void PacketReceived<TCode>(
    ILogger logger, ConnectionChannel channel, TCode code)
    where TCode : struct, Enum;

// Still emits SYSLIB1011
[LoggerMessage(1, LogLevel.Debug, "Value: {Value}")]
public static partial void LogValue<T>(
    ILogger logger, T value)
    where T : allows ref struct;

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

…llows ref struct restricted

Co-authored-by: svick <287848+svick@users.noreply.github.com>
Copilot AI changed the title [WIP] Update logging source generator documentation for changes Update logging source generator docs: SYSLIB1011 now scoped to allows ref struct only Feb 23, 2026
Copilot AI requested a review from svick February 23, 2026 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants