Skip to content
Open
8 changes: 0 additions & 8 deletions .openpublishing.redirection.fundamentals.json
Original file line number Diff line number Diff line change
Expand Up @@ -253,14 +253,6 @@
"source_path_from_root": "/docs/fundamentals/syslib-diagnostics/syslib1004.md",
"redirect_url": "/dotnet/fundamentals/syslib-diagnostics/source-generator-overview"
},
{
"source_path_from_root": "/docs/fundamentals/syslib-diagnostics/syslib1028.md",
"redirect_url": "/dotnet/fundamentals/syslib-diagnostics/source-generator-overview"
},
{
"source_path_from_root": "/docs/fundamentals/syslib-diagnostics/syslib1029.md",
"redirect_url": "/dotnet/fundamentals/syslib-diagnostics/source-generator-overview"
},
{
"source_path_from_root": "/docs/fundamentals/syslib-diagnostics/syslib1040.md",
"redirect_url": "/dotnet/fundamentals/syslib-diagnostics/syslib1040-1049"
Expand Down
3 changes: 2 additions & 1 deletion docs/core/extensions/logging/source-generation.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ Logging methods that are decorated with `LoggerMessageAttribute` must meet the f
- Logging methods must be `partial` and return `void`.
- Logging method names must *not* start with an underscore.
- Parameter names of logging methods must *not* start with an underscore.
- Logging methods *can't* be generic.
- Logging methods support generic type parameters, but the C# 13 `allows ref struct` anti-constraint isn't supported.
- Logging method parameters can't use the `params`, `scoped`, or `out` modifiers, and can't be ref struct types.
- If a logging method is `static`, the `ILogger` instance is required as a parameter.

The code-generation model depends on code being compiled with a modern C# compiler, that is, version 9 or later. For information about changing the language version, see [C# language versioning](../../../csharp/language-reference/configure-language-version.md).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ The following table provides an index to the `SYSLIB1XXX` diagnostics in .NET 6
| [SYSLIB1008][1008] | One of the arguments to a logging method must implement the `Microsoft.Extensions.Logging.ILogger` interface |
| [SYSLIB1009][1009] | Logging methods must be `static` |
| [SYSLIB1010][1010] | Logging methods must be `partial` |
| [SYSLIB1011][1011] | Logging methods cannot be generic |
| [SYSLIB1011][1011] | Logging methods cannot use the `allows ref struct` constraint |
| [SYSLIB1012][1012] | Redundant qualifier in logging message |
| [SYSLIB1013][1013] | Don't include exception parameters as templates in the logging message |
| [SYSLIB1014][1014] | Logging template has no corresponding method argument |
Expand All @@ -47,8 +47,8 @@ The following table provides an index to the `SYSLIB1XXX` diagnostics in .NET 6
| [SYSLIB1025][1025] | Multiple logging methods cannot use the same event name within a class |
| [SYSLIB1026][1026] | C# language version not supported by the logging source generator. |
| [SYSLIB1027][1027] | Primary constructor parameter of type `Microsoft.Extensions.Logging.ILogger` is hidden by a field |
| SYSLIB1028 | (Reserved for logging.) |
| SYSLIB1029 | (Reserved for logging.) |
| [SYSLIB1028][1028] | Logging method argument uses unsupported `params` or `scoped` parameter modifier |
| [SYSLIB1029][1029] | Logging method parameter is a ref struct |
| [SYSLIB1030][1030] | The `System.Text.Json` source generator did not generate serialization metadata for type |
| [SYSLIB1031][1031] | The `System.Text.Json` source generator encountered a duplicate `JsonTypeInfo` property name |
| [SYSLIB1032][1032] | The `System.Text.Json` source generator encountered a context class that is not partial |
Expand Down Expand Up @@ -198,6 +198,8 @@ The following table provides an index to the `SYSLIB1XXX` diagnostics in .NET 6
[1025]: syslib1025.md
[1026]: syslib1026.md
[1027]: syslib1027.md
[1028]: syslib1028.md
[1029]: syslib1029.md
[1030]: syslib1030.md
[1031]: syslib1031.md
[1032]: syslib1032.md
Expand Down
8 changes: 4 additions & 4 deletions docs/fundamentals/syslib-diagnostics/syslib1011.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
---
title: SYSLIB1011 error
description: Learn about the diagnostic that generates compile-time error SYSLIB1011.
ms.date: 05/07/2021
ms.date: 02/23/2026
f1_keywords:
- syslib1011
---

# SYSLIB1011: Logging methods cannot be generic
# SYSLIB1011: Logging methods cannot use the `allows ref struct` constraint

A method annotated with the `LoggerMessageAttribute` contains parameters with generic types.
A method annotated with `LoggerMessageAttribute` uses the C# 13 `allows ref struct` anti-constraint on a type parameter. The logging source generator stores parameters in struct fields, so it can't hold ref struct type arguments.

## Workarounds

Logging methods cannot have any generically typed parameters. Use fully resolved types instead.
Logging methods support generic type parameters and most constraint forms (`class`, `struct`, `unmanaged`, `notnull`, base types, interfaces, and `new()`). Remove the `allows ref struct` anti-constraint from the type parameter to resolve this error.

[!INCLUDE [suppress-syslib-warning](includes/suppress-source-generator-diagnostics.md)]
17 changes: 17 additions & 0 deletions docs/fundamentals/syslib-diagnostics/syslib1028.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
title: SYSLIB1028 error
description: Learn about the diagnostic that generates compile-time error SYSLIB1028.
ms.date: 02/25/2026
f1_keywords:
- SYSLIB1028
---

# SYSLIB1028: Argument is using the unsupported 'params' or 'scoped' parameter modifier

The `params` and `scoped` parameter modifiers aren't supported for <xref:Microsoft.Extensions.Logging.LoggerMessageAttribute>-annotated logging methods.

## Workarounds

Remove the `params` or `scoped` modifier from the parameter.

[!INCLUDE [suppress-syslib-warning](includes/suppress-source-generator-diagnostics.md)]
17 changes: 17 additions & 0 deletions docs/fundamentals/syslib-diagnostics/syslib1029.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
title: SYSLIB1029 error
description: Learn about the diagnostic that generates compile-time error SYSLIB1029.
ms.date: 02/25/2026
f1_keywords:
- SYSLIB1029
---

# SYSLIB1029: Logging method parameter is a ref struct

Ref struct types aren't supported as parameters for <xref:Microsoft.Extensions.Logging.LoggerMessageAttribute>-annotated logging methods. The logging source generator stores parameters in struct fields, which can't hold ref struct values.

## Workarounds

Use a non-ref struct type for the parameter.

[!INCLUDE [suppress-syslib-warning](includes/suppress-source-generator-diagnostics.md)]
2 changes: 1 addition & 1 deletion docs/whats-new/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ landingContent:
- text: .NET 11
url: ../core/whats-new/dotnet-11/overview.md
- text: ASP.NET Core 11.0
url: /aspnet/core/release-notes/aspnetcore-11.0
url: /aspnet/core/release-notes/aspnetcore-11
- title: .NET 10 release updates
linkLists:
- linkListType: whats-new
Expand Down