Skip to content

Commit 9d4685b

Browse files
authored
Add LSG diagnostic articles (#49678)
1 parent 0803ef3 commit 9d4685b

File tree

8 files changed

+103
-23
lines changed

8 files changed

+103
-23
lines changed

.openpublishing.redirection.fundamentals.json

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -249,22 +249,6 @@
249249
"source_path_from_root": "/docs/fundamentals/syslib-diagnostics/syslib1004.md",
250250
"redirect_url": "/dotnet/fundamentals/syslib-diagnostics/source-generator-overview"
251251
},
252-
{
253-
"source_path_from_root": "/docs/fundamentals/syslib-diagnostics/syslib1024.md",
254-
"redirect_url": "/dotnet/fundamentals/syslib-diagnostics/source-generator-overview"
255-
},
256-
{
257-
"source_path_from_root": "/docs/fundamentals/syslib-diagnostics/syslib1025.md",
258-
"redirect_url": "/dotnet/fundamentals/syslib-diagnostics/source-generator-overview"
259-
},
260-
{
261-
"source_path_from_root": "/docs/fundamentals/syslib-diagnostics/syslib1026.md",
262-
"redirect_url": "/dotnet/fundamentals/syslib-diagnostics/source-generator-overview"
263-
},
264-
{
265-
"source_path_from_root": "/docs/fundamentals/syslib-diagnostics/syslib1027.md",
266-
"redirect_url": "/dotnet/fundamentals/syslib-diagnostics/source-generator-overview"
267-
},
268252
{
269253
"source_path_from_root": "/docs/fundamentals/syslib-diagnostics/syslib1028.md",
270254
"redirect_url": "/dotnet/fundamentals/syslib-diagnostics/source-generator-overview"

docs/fundamentals/syslib-diagnostics/source-generator-overview.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Analyzer diagnostics in .NET 6+
33
description: Learn about analyzer diagnostics created by source generators in .NET 6 and later versions that produce SYSLIB compiler warnings.
4-
ms.date: 10/27/2023
4+
ms.date: 11/07/2025
55
---
66

77
# Source-generator diagnostics in .NET 6+
@@ -43,10 +43,10 @@ The following table provides an index to the `SYSLIB1XXX` diagnostics in .NET 6
4343
| [SYSLIB1021][1021] | Multiple message-template item names differ only by case |
4444
| [SYSLIB1022][1022] | Can't have malformed format strings (for example, dangling curly braces) |
4545
| [SYSLIB1023][1023] | Generating more than six arguments is not supported |
46-
| SYSLIB1024 | Logging method argument uses unsupported `out` parameter modifier |
47-
| SYSLIB1025 | Multiple logging methods cannot use the same event name within a class |
48-
| SYSLIB1026 | C# language version not supported by the logging source generator. |
49-
| SYSLIB1027 | Primary constructor parameter of type Microsoft.Extensions.Logging.ILogger is hidden by a field |
46+
| [SYSLIB1024][1024] | Logging method argument uses unsupported `out` parameter modifier |
47+
| [SYSLIB1025][1025] | Multiple logging methods cannot use the same event name within a class |
48+
| [SYSLIB1026][1026] | C# language version not supported by the logging source generator. |
49+
| [SYSLIB1027][1027] | Primary constructor parameter of type `Microsoft.Extensions.Logging.ILogger` is hidden by a field |
5050
| SYSLIB1028 | (Reserved for logging.) |
5151
| SYSLIB1029 | (Reserved for logging.) |
5252
| [SYSLIB1030][1030] | The `System.Text.Json` source generator did not generate serialization metadata for type |
@@ -194,6 +194,10 @@ The following table provides an index to the `SYSLIB1XXX` diagnostics in .NET 6
194194
[1021]: syslib1021.md
195195
[1022]: syslib1022.md
196196
[1023]: syslib1023.md
197+
[1024]: syslib1024.md
198+
[1025]: syslib1025.md
199+
[1026]: syslib1026.md
200+
[1027]: syslib1027.md
197201
[1030]: syslib1030.md
198202
[1031]: syslib1031.md
199203
[1032]: syslib1032.md
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
title: SYSLIB1024 error
3+
description: Learn about the diagnostic that generates compile-time error SYSLIB1024.
4+
ms.date: 11/07/2025
5+
f1_keywords:
6+
- SYSLIB1024
7+
---
8+
9+
# SYSLIB1024: Argument is using the unsupported 'out' parameter modifier
10+
11+
The `out` parameter modifier isn't supported for <xref:Microsoft.Extensions.Logging.LoggerMessageAttribute>-annotated logging methods.
12+
13+
## Workarounds
14+
15+
Remove the `out` parameter modifier.
16+
17+
[!INCLUDE [suppress-syslib-warning](includes/suppress-source-generator-diagnostics.md)]
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
title: SYSLIB1025 error
3+
description: Learn about the diagnostic that generates compile-time error SYSLIB1025.
4+
ms.date: 11/07/2025
5+
f1_keywords:
6+
- SYSLIB1025
7+
---
8+
9+
# SYSLIB1025: Multiple logging methods should not use the same event name within a class
10+
11+
Within the scope of a class, log methods annotated with <xref:Microsoft.Extensions.Logging.LoggerMessageAttribute> must use unique event names.
12+
13+
## Workarounds
14+
15+
Use a unique event name.
16+
17+
[!INCLUDE [suppress-syslib-warning](includes/suppress-source-generator-diagnostics.md)]
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
title: SYSLIB1026 error
3+
description: Learn about the diagnostic that generates compile-time error SYSLIB1026.
4+
ms.date: 11/07/2025
5+
f1_keywords:
6+
- SYSLIB1026
7+
---
8+
9+
# SYSLIB1026: C# language version not supported by the source generator
10+
11+
The logging source generator generates code using the [nullable](../../csharp/nullable-references.md) feature, which is only supported starting in C# 8.
12+
13+
## Workarounds
14+
15+
Set your C# language version to 8 or later.
16+
17+
[!INCLUDE [suppress-syslib-warning](includes/suppress-source-generator-diagnostics.md)]
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
title: SYSLIB1027 error
3+
description: Learn about the diagnostic that generates compile-time error SYSLIB1027.
4+
ms.date: 11/07/2025
5+
f1_keywords:
6+
- SYSLIB1027
7+
---
8+
9+
# SYSLIB1027: Primary constructor parameter of type 'Microsoft.Extensions.Logging.ILogger' is hidden by a field
10+
11+
A class has a primary constructor parameter of type <xref:Microsoft.Extensions.Logging.ILogger> that's hidden by a field in the class or a base class, which prevents its use.
12+
13+
For example, the following class raises the `SYSLIB1027` diagnostic:
14+
15+
```csharp
16+
partial class C(ILogger logger)
17+
{
18+
private readonly object logger = logger;
19+
20+
[LoggerMessage(EventId = 0, Level = LogLevel.Debug, Message = "...")]
21+
public partial void M1();
22+
}
23+
```
24+
25+
## Workarounds
26+
27+
Either remove the field or the primary constructor. For more information, see [Basic usage](../../core/extensions/logger-message-generator.md#basic-usage).
28+
29+
[!INCLUDE [suppress-syslib-warning](includes/suppress-source-generator-diagnostics.md)]
30+
31+
## See also
32+
33+
- [Compile-time logging source generation](../../core/extensions/logger-message-generator.md)

docs/fundamentals/syslib-diagnostics/syslib1220-1229.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: SYSLIB diagnostics for System.Text.Json.SourceGeneration
33
description: Learn about the System.Text.Json source-generation analyzers that generate compile-time suggestions SYSLIB1220 through SYSLIB1229.
4-
ms.date: 10/24/2023
4+
ms.date: 11/07/2025
55
f1_keywords:
66
- syslib1220
77
- syslib1221
@@ -25,7 +25,7 @@ The following table shows the diagnostic IDs for System.Text.Json source-generat
2525
| `SYSLIB1222` | Constructor annotated with `JsonConstructorAttribute` is inaccessible. |
2626
| `SYSLIB1223` | Attributes deriving from `JsonConverterAttribute` are not supported by the source generator. |
2727
| `SYSLIB1224` | Types annotated with `JsonSerializableAttribute` must be classes deriving from `JsonSerializerContext`. |
28-
| `SYSLIB1225` | Reserved for System.Text.Json.SourceGeneration. |
28+
| `SYSLIB1225` | Type includes `ref` like property, field, or constructor parameter. |
2929
| `SYSLIB1226` | Reserved for System.Text.Json.SourceGeneration. |
3030
| `SYSLIB1227` | Reserved for System.Text.Json.SourceGeneration. |
3131
| `SYSLIB1228` | Reserved for System.Text.Json.SourceGeneration. |

docs/navigate/tools-diagnostics/toc.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4112,6 +4112,14 @@ items:
41124112
href: ../../fundamentals/syslib-diagnostics/syslib1022.md
41134113
- name: SYSLIB1023
41144114
href: ../../fundamentals/syslib-diagnostics/syslib1023.md
4115+
- name: SYSLIB1024
4116+
href: ../../fundamentals/syslib-diagnostics/syslib1024.md
4117+
- name: SYSLIB1025
4118+
href: ../../fundamentals/syslib-diagnostics/syslib1025.md
4119+
- name: SYSLIB1026
4120+
href: ../../fundamentals/syslib-diagnostics/syslib1026.md
4121+
- name: SYSLIB1027
4122+
href: ../../fundamentals/syslib-diagnostics/syslib1027.md
41154123
- name: SYSLIB1030
41164124
href: ../../fundamentals/syslib-diagnostics/syslib1030.md
41174125
- name: SYSLIB1031

0 commit comments

Comments
 (0)