Skip to content

Update logging source generator docs for generic support, SYSLIB1028, and SYSLIB1029#51839

Open
Copilot wants to merge 9 commits intomainfrom
copilot/update-logging-source-generator-docs
Open

Update logging source generator docs for generic support, SYSLIB1028, and SYSLIB1029#51839
Copilot wants to merge 9 commits intomainfrom
copilot/update-logging-source-generator-docs

Conversation

Copy link
Contributor

Copilot AI commented Feb 23, 2026

Documents two changes to the LoggerMessageAttribute source generator (#124638, #124589) that expand what's supported and tighten what's explicitly diagnosed.

SYSLIB1011 — narrowed restriction (#124638)

Generic logging methods are now fully supported. SYSLIB1011 fires only when a type parameter uses the C# 13 allows ref struct anti-constraint (the generator stores parameters in struct fields and can't hold ref struct type arguments).

// ✅ Now valid — was SYSLIB1011 before
[LoggerMessage(0, LogLevel.Trace, "Code: {Code}")]
public static partial void LogPacket<TCode>(ILogger logger, TCode code)
    where TCode : struct, Enum;

// ❌ Still SYSLIB1011
public static partial void LogValue<T>(ILogger logger, T value)
    where T : allows ref struct;
  • syslib1011.md — title/description updated from "cannot be generic" → "cannot use the allows ref struct constraint"

SYSLIB1028 and SYSLIB1029 — new diagnostics (#124589)

params and scoped modifiers are now explicitly rejected (SYSLIB1028); ref struct parameter types are rejected (SYSLIB1029). The ref readonly modifier is preserved correctly.

  • syslib1028.md (new)params and scoped modifiers unsupported
  • syslib1029.md (new) — ref struct parameter types unsupported
  • source-generator-overview.md — SYSLIB1011/1028/1029 table entries updated; 1028/1029 promoted from reserved placeholders to linked entries
  • source-generation.md — "Log method constraints" list updated to reflect all changes; notes ref readonly is supported
  • .openpublishing.redirection.fundamentals.json — removed stale redirect entries for the two new pages (caused build warnings)

🔒 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.


Internal previews

📄 File 🔗 Preview link
docs/core/extensions/logging/source-generation.md Compile-time logging source generation
docs/fundamentals/syslib-diagnostics/source-generator-overview.md Analyzer diagnostics in .NET 6+
docs/fundamentals/syslib-diagnostics/syslib1011.md SYSLIB1011: Logging methods cannot use the allows ref struct constraint
docs/fundamentals/syslib-diagnostics/syslib1028.md docs/fundamentals/syslib-diagnostics/syslib1028
docs/fundamentals/syslib-diagnostics/syslib1029.md SYSLIB1029: Logging method parameter is a ref struct
docs/whats-new/index.yml .NET - what's new?

…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
…-generation constraints

Co-authored-by: svick <287848+svick@users.noreply.github.com>
Copilot AI changed the title Update logging source generator docs: SYSLIB1011 now scoped to allows ref struct only Update logging source generator docs for SYSLIB1028/1029 and generic method support Feb 25, 2026
Co-authored-by: svick <287848+svick@users.noreply.github.com>
Copilot AI changed the title Update logging source generator docs for SYSLIB1028/1029 and generic method support Update logging source generator docs: SYSLIB1011, SYSLIB1028, SYSLIB1029 Feb 25, 2026
Copilot stopped work on behalf of svick due to an error February 27, 2026 10:44
Co-authored-by: svick <287848+svick@users.noreply.github.com>
Copilot AI changed the title Update logging source generator docs: SYSLIB1011, SYSLIB1028, SYSLIB1029 Update logging source generator docs for generic method support, SYSLIB1028, and SYSLIB1029 Feb 27, 2026
@svick svick marked this pull request as ready for review February 27, 2026 10:50
@svick svick requested review from a team and gewarren as code owners February 27, 2026 10:50
Copilot AI review requested due to automatic review settings February 27, 2026 10:50
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the logging source generator documentation to reflect two significant runtime changes in .NET. The changes narrow SYSLIB1011 from blocking all generic methods to only blocking the allows ref struct anti-constraint, and introduce two new diagnostic codes (SYSLIB1028 and SYSLIB1029) for previously undiagnosed parameter restrictions.

Changes:

  • SYSLIB1011 narrowed: generic logging methods now supported, except when using the C# 13 allows ref struct anti-constraint
  • Two new diagnostics added: SYSLIB1028 for params/scoped modifiers and SYSLIB1029 for ref struct parameter types
  • Log method constraints updated to reflect the expanded support for generics and explicit restrictions

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
docs/fundamentals/syslib-diagnostics/syslib1011.md Updated to reflect narrowed scope - only blocks allows ref struct constraint, not all generics
docs/fundamentals/syslib-diagnostics/syslib1028.md New diagnostic documentation for unsupported params and scoped parameter modifiers
docs/fundamentals/syslib-diagnostics/syslib1029.md New diagnostic documentation for ref struct parameter types
docs/fundamentals/syslib-diagnostics/source-generator-overview.md Updated table entries for SYSLIB1011, promoted SYSLIB1028/1029 from reserved to documented
docs/core/extensions/logging/source-generation.md Updated constraints section to reflect generic support and explicit modifier/type restrictions

Co-authored-by: svick <287848+svick@users.noreply.github.com>
@dotnet-policy-service dotnet-policy-service bot added the okr-quality Content-quality KR: Concerns article defects (bugs), freshness, or build warnings. label Mar 2, 2026
Copilot AI changed the title Update logging source generator docs for generic method support, SYSLIB1028, and SYSLIB1029 Update logging source generator docs for generic support, SYSLIB1028, and SYSLIB1029 Mar 2, 2026
Copilot AI requested a review from svick March 2, 2026 10:45
Copilot finished work on behalf of svick March 2, 2026 10:45
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@BillWagner BillWagner self-requested a review as a code owner March 2, 2026 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dotnet-fundamentals/svc okr-quality Content-quality KR: Concerns article defects (bugs), freshness, or build warnings.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants