Skip to content

Commit 43bad08

Browse files
committed
Add docs for diagnostics emitted by the System.Text.Json source generator
1 parent a66185e commit 43bad08

File tree

9 files changed

+134
-6
lines changed

9 files changed

+134
-6
lines changed

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

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,14 @@ 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-
<!-- commented out for now, as these do not exist.
47-
| [SYSLIB1030][1030] | [System.Text.Json.SourceGeneration] Did not generate serialization metadata for type. |
48-
| [SYSLIB1031][1031] | [System.Text.Json.SourceGeneration] Duplicate type name. |
49-
-->
46+
| [SYSLIB1030][1030] | The `System.Text.Json` source generator did not generate serialization metadata for type |
47+
| [SYSLIB1031][1031] | The `System.Text.Json` source generator encountered a duplicate JsonTypeInfo property name |
48+
| [SYSLIB1032][1032] | The `System.Text.Json` source generator encountered a context class that is not partial |
49+
| [SYSLIB1033][1033] | The `System.Text.Json` source generator encountered a type that has multiple [JsonConstructor] annotations|
50+
| [SYSLIB1035][1035] | The `System.Text.Json` source generator encountered a type that has multiple [JsonExtensionData] annotations |
51+
| [SYSLIB1036][1036] | The `System.Text.Json` source generator encountered an invalid [JsonExtensionData] annotation |
52+
| [SYSLIB1037][1037] | The `System.Text.Json` source generator encountered a type with init-only properties for which deserialization is not supported |
53+
| [SYSLIB1038][1038] | The `System.Text.Json` source generator encountered a property annotated with [JsonInclude] that has inaccessible accessors |
5054

5155
<!-- Include adds ## Suppress warnings (H2 heading) -->
5256
[!INCLUDE [suppress-source-generator-diagnostics](includes/suppress-source-generator-diagnostics.md)]
@@ -74,7 +78,11 @@ The following table provides an index to the `SYSLIB1XXX` diagnostics in .NET 6
7478
[1021]: syslib1021.md
7579
[1022]: syslib1022.md
7680
[1023]: syslib1023.md
77-
<!--
7881
[1030]: syslib1030.md
7982
[1031]: syslib1031.md
80-
-->
83+
[1032]: syslib1032.md
84+
[1033]: syslib1033.md
85+
[1035]: syslib1035.md
86+
[1036]: syslib1036.md
87+
[1037]: syslib1037.md
88+
[1039]: syslib1038.md
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
title: SYSLIB1030 warning
3+
description: Learn about the diagnostic that generates compile-time warning SYSLIB1030.
4+
ms.date: 05/07/2021
5+
---
6+
7+
# SYSLIB1030: `System.Text.Json` source generator did not generate output for type
8+
9+
The `System.Text.Json` source generator did not generate output for a given type in the input object graph. This typically means that the type is not supported by `JsonSerializer`, for example multi-dimensional arrays like `int[,]`.
10+
11+
## Workarounds
12+
13+
Register a [custom converter](../../standard/serialization/system-text-json-converters-how-to.md) for the type.
14+
15+
[!INCLUDE [suppress-syslib-warning](includes/suppress-source-generator-diagnostics.md)]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
title: SYSLIB1031 warning
3+
description: Learn about the diagnostic that generates compile-time warning SYSLIB1031.
4+
ms.date: 05/07/2021
5+
---
6+
7+
# SYSLIB1031: `System.Text.Json` source generator encountered a duplicate type info property name
8+
9+
The `System.Text.Json` source generator encountered a duplicate type info property name to be generated on the specified partial context type.
10+
11+
## Workarounds
12+
13+
Specify a new type info property name for the duplicate instance using `System.Text.Json.Serialization.JsonSerializableAttribute.TypeInfoPropertyName`.
14+
15+
[!INCLUDE [suppress-syslib-warning](includes/suppress-source-generator-diagnostics.md)]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
title: SYSLIB1032 error
3+
description: Learn about the diagnostic that generates compile-time warning SYSLIB1032.
4+
ms.date: 05/07/2021
5+
---
6+
7+
# SYSLIB1032: Context classes to be augmented by the `System.Text.Json` source generator must be declared as partial
8+
9+
The `System.Text.Json` source generator encountered a context type included for source generation which is not partial, or whose containing type(s) is not partial.
10+
11+
## Workarounds
12+
13+
Make the context type and all containing types partial.
14+
15+
[!INCLUDE [suppress-syslib-warning](includes/suppress-source-generator-diagnostics.md)]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
title: SYSLIB1033 error
3+
description: Learn about the diagnostic that generates compile-time error SYSLIB1033.
4+
ms.date: 05/07/2021
5+
---
6+
7+
# SYSLIB1033: `System.Text.Json` source generator encountered a type with multiple `[JsonConstructor]` annotations
8+
9+
The `System.Text.Json` source generator encountered a serializable type with multiple `[JsonConstructor]` annotations.
10+
11+
## Workarounds
12+
13+
Remove duplicate `[JsonConstructor]` annotations.
14+
15+
[!INCLUDE [suppress-syslib-warning](includes/suppress-source-generator-diagnostics.md)]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
title: SYSLIB1035 error
3+
description: Learn about the diagnostic that generates compile-time error SYSLIB1035.
4+
ms.date: 05/07/2021
5+
---
6+
7+
# SYSLIB1035: `System.Text.Json` source generator encountered a type with multiple `[JsonExtensionData]` annotations
8+
9+
The `System.Text.Json` source generator encountered a serializable type with multiple `[JsonExtensionData]` annotations.
10+
11+
## Workarounds
12+
13+
Remove duplicate `[JsonExtensionData]` annotations.
14+
15+
[!INCLUDE [suppress-syslib-warning](includes/suppress-source-generator-diagnostics.md)]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
title: SYSLIB1036 error
3+
description: Learn about the diagnostic that generates compile-time error SYSLIB1036.
4+
ms.date: 05/07/2021
5+
---
6+
7+
# SYSLIB1036: `System.Text.Json` source generator encountered an invalid `[JsonExtensionData]` annotation
8+
9+
The `System.Text.Json` source generator encountered a property or field annotated with `[JsonExtensionData]` but whose data type does not implement `IDictionary<string, JsonElement>`, `IDictionary<string, object>`, `IDictionary<string, JsonNode>`, or `JsonNode`.
10+
11+
## Workarounds
12+
13+
Ensure that the data type for any property or field that is annotated with `[JsonExtensionData]` implements `IDictionary<string, JsonElement>`, `IDictionary<string, object>`, `IDictionary<string, JsonNode>`, or `JsonNode`.
14+
15+
[!INCLUDE [suppress-syslib-warning](includes/suppress-source-generator-diagnostics.md)]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
title: SYSLIB1037 warning
3+
description: Learn about the diagnostic that generates compile-time warning SYSLIB1037.
4+
ms.date: 05/07/2021
5+
---
6+
7+
# SYSLIB1037: `System.Text.Json` source generator encountered a type with init-only properties which are not supported for deserialization
8+
9+
The `System.Text.Json` source generator encountered a type with init-only properties, such as a record type. These properties are currently not supported by the source generator for deserialization.
10+
11+
## Workarounds
12+
13+
If deserialization of init-only properties is required, use the [reflection-based `JsonSerializer` implementation](../../standard/serialization/system-text-json-source-generation-modes.md).
14+
15+
[!INCLUDE [suppress-syslib-warning](includes/suppress-source-generator-diagnostics.md)]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
title: SYSLIB1038 warning
3+
description: Learn about the diagnostic that generates compile-time warning SYSLIB1038.
4+
ms.date: 05/07/2021
5+
---
6+
7+
# SYSLIB1038: `System.Text.Json` source generator encountered a property annotated with `[JsonInclude]` but with inaccessible accessors
8+
9+
The `System.Text.Json` source generator encountered a property annotated with `[JsonInclude]` but with accessors that are inaccessible to the source generator, i.e. that are not `public` or `internal`.
10+
11+
## Workarounds
12+
13+
If serialization or deserialization of properties with accessors that are not `public` or `internal` is required, use the [reflection-based `JsonSerializer` implementation](../../standard/serialization/system-text-json-source-generation-modes.md).
14+
15+
[!INCLUDE [suppress-syslib-warning](includes/suppress-source-generator-diagnostics.md)]

0 commit comments

Comments
 (0)