Skip to content

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

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

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

Conversation

Copy link
Contributor

Copilot AI commented Feb 23, 2026

Reflects two runtime changes to the LoggerMessageAttribute source generator:

  • dotnet/runtime#124638: Generic logging methods are now fully supported; SYSLIB1011 narrows from "cannot be generic" to "cannot use the allows ref struct anti-constraint"
  • dotnet/runtime#124589: params and scoped modifiers are now explicitly diagnosed as SYSLIB1028; ref struct parameter types as SYSLIB1029; ref readonly is now correctly preserved

Changes

  • syslib1011.md — Updated title, description, and workaround to reflect the narrowed restriction (allows ref struct only)
  • syslib1028.md (new) — Documents SYSLIB1028: params and scoped modifiers unsupported on logging method parameters
  • syslib1029.md (new) — Documents SYSLIB1029: ref struct types unsupported as logging method parameters
  • source-generator-overview.md — SYSLIB1011 entry updated; SYSLIB1028/1029 promoted from reserved placeholders to real entries with links
  • source-generation.md — "Log method constraints" updated to reflect all changes: generics now valid (except allows ref struct), params/scoped/out forbidden, ref struct forbidden, ref readonly supported

What's now valid / invalid

// ✅ Now works — generic method with value-type constraint
[LoggerMessage(0, LogLevel.Trace, "Channel {Channel}: code {Code}")]
public static partial void LogPacket<TCode>(
    ILogger logger, string channel, TCode code)
    where TCode : struct, Enum;

// ✅ Now works — ref readonly parameter (modifier is preserved)
[LoggerMessage(1, LogLevel.Debug, "Value: {Value}")]
public static partial void LogValue(ILogger logger, ref readonly int value);

// ❌ SYSLIB1011 — allows ref struct anti-constraint still blocked
[LoggerMessage(2, LogLevel.Debug, "Value: {Value}")]
public static partial void LogRef<T>(ILogger logger, T value)
    where T : allows ref struct;

// ❌ SYSLIB1028 — params and scoped modifiers blocked
// ❌ SYSLIB1029 — ref struct parameter types blocked

🔒 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 docs/core/extensions/logging/source-generation
docs/fundamentals/syslib-diagnostics/source-generator-overview.md docs/fundamentals/syslib-diagnostics/source-generator-overview
docs/fundamentals/syslib-diagnostics/syslib1011.md docs/fundamentals/syslib-diagnostics/syslib1011
docs/fundamentals/syslib-diagnostics/syslib1028.md docs/fundamentals/syslib-diagnostics/syslib1028
docs/fundamentals/syslib-diagnostics/syslib1029.md docs/fundamentals/syslib-diagnostics/syslib1029

…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

Comment on lines +5 to +9
f1_keywords:
- SYSLIB1028
---

# SYSLIB1028: Argument is using an unsupported parameter modifier
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

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

The title wording is inconsistent with SYSLIB1024, which uses "the unsupported" instead of "an unsupported". For consistency, consider changing to: "Argument is using the unsupported 'params' or 'scoped' parameter modifier" to match the pattern used in SYSLIB1024.

Suggested change
f1_keywords:
- SYSLIB1028
---
# SYSLIB1028: Argument is using an unsupported parameter modifier
ai-usage: ai-assisted
f1_keywords:
- SYSLIB1028
---
# SYSLIB1028: Argument is using the unsupported 'params' or 'scoped' parameter modifier

Copilot uses AI. Check for mistakes.
ms.date: 05/07/2021
ms.date: 02/23/2026
f1_keywords:
- syslib1011
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

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

The f1_keywords value uses lowercase "syslib1011", but newer SYSLIB diagnostic files use uppercase (e.g., "SYSLIB1024", "SYSLIB1028", "SYSLIB1029"). For consistency with the newer convention, consider changing this to "SYSLIB1011".

Suggested change
- syslib1011
- SYSLIB1011

Copilot uses AI. Check for mistakes.
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.

3 participants