-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add STJ source gen diagnostics (#37777)
- Loading branch information
Showing
7 changed files
with
106 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
title: SYSLIB1034 error | ||
description: Learn about the diagnostic that generates compile-time error SYSLIB1034. | ||
ms.date: 10/26/2023 | ||
--- | ||
|
||
# SYSLIB1034: JsonSourceGenerator encountered a [JsonStringEnumConverter] annotation | ||
|
||
The non-generic <xref:System.Text.Json.Serialization.JsonStringEnumConverter> requires dynamic code and can't be used with source generation. | ||
|
||
## Workarounds | ||
|
||
Use <xref:System.Text.Json.Serialization.JsonStringEnumConverter%601> instead, which doesn't require run-time code generation. | ||
|
||
[!INCLUDE [suppress-syslib-warning](includes/suppress-source-generator-diagnostics.md)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
title: SYSLIB1039 error | ||
description: Learn about the diagnostic that generates compile-time error SYSLIB1039. | ||
ms.date: 10/26/2023 | ||
--- | ||
|
||
# SYSLIB1039: JsonSourceGenerator encountered a `JsonDerivedTypeAttribute` annotation with `JsonSourceGenerationMode.Serialization` enabled | ||
|
||
<xref:System.Text.Json.Serialization.JsonDerivedTypeAttribute> annotations are supported for source generation, but not for contexts that are annotated with <xref:System.Text.Json.Serialization.JsonSourceGenerationMode.Serialization?displayProperty=nameWithType>. That is, the attribute works with the metadata source generator, but not in fast-path methods. | ||
|
||
## Workarounds | ||
|
||
Remove the attribute, or remove the <xref:System.Text.Json.Serialization.JsonSourceGenerationMode.Serialization?displayProperty=nameWithType> annotation from your serialization context. | ||
|
||
[!INCLUDE [suppress-syslib-warning](includes/suppress-source-generator-diagnostics.md)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
title: SYSLIB diagnostics for System.Text.Json.SourceGeneration | ||
description: Learn about the System.Text.Json source-generation analyzers that generate compile-time suggestions SYSLIB1220 through SYSLIB1229. | ||
ms.date: 10/24/2023 | ||
--- | ||
# SYSLIB diagnostics for System.Text.Json source generation | ||
|
||
The following table shows the diagnostic IDs for System.Text.Json source-generation analyzers in .NET 8 and later versions. | ||
|
||
| Diagnostic ID | Description | | ||
| - | - | | ||
| `SYSLIB1220` | JsonSourceGenerator encountered a `JsonConverterAttribute` with an invalid type argument. | | ||
| `SYSLIB1221` | JsonSourceGenerator does not support this C# language version. | | ||
| `SYSLIB1222` | Constructor annotated with `JsonConstructorAttribute` is inaccessible. | | ||
| `SYSLIB1223` | Attributes deriving from `JsonConverterAttribute` are not supported by the source generator. | | ||
| `SYSLIB1224` | Types annotated with `JsonSerializableAttribute` must be classes deriving from `JsonSerializerContext`. | | ||
| `SYSLIB1225` | Reserved for System.Text.Json.SourceGeneration. | | ||
| `SYSLIB1226` | Reserved for System.Text.Json.SourceGeneration. | | ||
| `SYSLIB1227` | Reserved for System.Text.Json.SourceGeneration. | | ||
| `SYSLIB1228` | Reserved for System.Text.Json.SourceGeneration. | | ||
| `SYSLIB1229` | Reserved for System.Text.Json.SourceGeneration. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters