From 43bad082244abaea2581a5a010d3ca971c639f12 Mon Sep 17 00:00:00 2001 From: Layomi Akinrinade Date: Thu, 18 Nov 2021 14:18:22 -0800 Subject: [PATCH 1/9] Add docs for diagnostics emitted by the System.Text.Json source generator --- .../source-generator-overview.md | 20 +++++++++++++------ .../syslib-diagnostics/syslib1030.md | 15 ++++++++++++++ .../syslib-diagnostics/syslib1031.md | 15 ++++++++++++++ .../syslib-diagnostics/syslib1032.md | 15 ++++++++++++++ .../syslib-diagnostics/syslib1033.md | 15 ++++++++++++++ .../syslib-diagnostics/syslib1035.md | 15 ++++++++++++++ .../syslib-diagnostics/syslib1036.md | 15 ++++++++++++++ .../syslib-diagnostics/syslib1037.md | 15 ++++++++++++++ .../syslib-diagnostics/syslib1038.md | 15 ++++++++++++++ 9 files changed, 134 insertions(+), 6 deletions(-) create mode 100644 docs/fundamentals/syslib-diagnostics/syslib1030.md create mode 100644 docs/fundamentals/syslib-diagnostics/syslib1031.md create mode 100644 docs/fundamentals/syslib-diagnostics/syslib1032.md create mode 100644 docs/fundamentals/syslib-diagnostics/syslib1033.md create mode 100644 docs/fundamentals/syslib-diagnostics/syslib1035.md create mode 100644 docs/fundamentals/syslib-diagnostics/syslib1036.md create mode 100644 docs/fundamentals/syslib-diagnostics/syslib1037.md create mode 100644 docs/fundamentals/syslib-diagnostics/syslib1038.md diff --git a/docs/fundamentals/syslib-diagnostics/source-generator-overview.md b/docs/fundamentals/syslib-diagnostics/source-generator-overview.md index 87b79a13002e4..0062f6d2b1611 100644 --- a/docs/fundamentals/syslib-diagnostics/source-generator-overview.md +++ b/docs/fundamentals/syslib-diagnostics/source-generator-overview.md @@ -43,10 +43,14 @@ The following table provides an index to the `SYSLIB1XXX` diagnostics in .NET 6 | [SYSLIB1021][1021] | Multiple message-template item names differ only by case | | [SYSLIB1022][1022] | Can't have malformed format strings (for example, dangling curly braces) | | [SYSLIB1023][1023] | Generating more than six arguments is not supported | - +| [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 | +| [SYSLIB1033][1033] | The `System.Text.Json` source generator encountered a type that has multiple [JsonConstructor] annotations| +| [SYSLIB1035][1035] | The `System.Text.Json` source generator encountered a type that has multiple [JsonExtensionData] annotations | +| [SYSLIB1036][1036] | The `System.Text.Json` source generator encountered an invalid [JsonExtensionData] annotation | +| [SYSLIB1037][1037] | The `System.Text.Json` source generator encountered a type with init-only properties for which deserialization is not supported | +| [SYSLIB1038][1038] | The `System.Text.Json` source generator encountered a property annotated with [JsonInclude] that has inaccessible accessors | [!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 [1021]: syslib1021.md [1022]: syslib1022.md [1023]: syslib1023.md - +[1032]: syslib1032.md +[1033]: syslib1033.md +[1035]: syslib1035.md +[1036]: syslib1036.md +[1037]: syslib1037.md +[1039]: syslib1038.md diff --git a/docs/fundamentals/syslib-diagnostics/syslib1030.md b/docs/fundamentals/syslib-diagnostics/syslib1030.md new file mode 100644 index 0000000000000..6e5b2a70c7306 --- /dev/null +++ b/docs/fundamentals/syslib-diagnostics/syslib1030.md @@ -0,0 +1,15 @@ +--- +title: SYSLIB1030 warning +description: Learn about the diagnostic that generates compile-time warning SYSLIB1030. +ms.date: 05/07/2021 +--- + +# SYSLIB1030: `System.Text.Json` source generator did not generate output for type + +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[,]`. + +## Workarounds + +Register a [custom converter](../../standard/serialization/system-text-json-converters-how-to.md) for the type. + +[!INCLUDE [suppress-syslib-warning](includes/suppress-source-generator-diagnostics.md)] diff --git a/docs/fundamentals/syslib-diagnostics/syslib1031.md b/docs/fundamentals/syslib-diagnostics/syslib1031.md new file mode 100644 index 0000000000000..34ac9bb19e1ee --- /dev/null +++ b/docs/fundamentals/syslib-diagnostics/syslib1031.md @@ -0,0 +1,15 @@ +--- +title: SYSLIB1031 warning +description: Learn about the diagnostic that generates compile-time warning SYSLIB1031. +ms.date: 05/07/2021 +--- + +# SYSLIB1031: `System.Text.Json` source generator encountered a duplicate type info property name + +The `System.Text.Json` source generator encountered a duplicate type info property name to be generated on the specified partial context type. + +## Workarounds + +Specify a new type info property name for the duplicate instance using `System.Text.Json.Serialization.JsonSerializableAttribute.TypeInfoPropertyName`. + +[!INCLUDE [suppress-syslib-warning](includes/suppress-source-generator-diagnostics.md)] diff --git a/docs/fundamentals/syslib-diagnostics/syslib1032.md b/docs/fundamentals/syslib-diagnostics/syslib1032.md new file mode 100644 index 0000000000000..ed4280d38360b --- /dev/null +++ b/docs/fundamentals/syslib-diagnostics/syslib1032.md @@ -0,0 +1,15 @@ +--- +title: SYSLIB1032 error +description: Learn about the diagnostic that generates compile-time warning SYSLIB1032. +ms.date: 05/07/2021 +--- + +# SYSLIB1032: Context classes to be augmented by the `System.Text.Json` source generator must be declared as partial + +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. + +## Workarounds + +Make the context type and all containing types partial. + +[!INCLUDE [suppress-syslib-warning](includes/suppress-source-generator-diagnostics.md)] diff --git a/docs/fundamentals/syslib-diagnostics/syslib1033.md b/docs/fundamentals/syslib-diagnostics/syslib1033.md new file mode 100644 index 0000000000000..8912e773833ac --- /dev/null +++ b/docs/fundamentals/syslib-diagnostics/syslib1033.md @@ -0,0 +1,15 @@ +--- +title: SYSLIB1033 error +description: Learn about the diagnostic that generates compile-time error SYSLIB1033. +ms.date: 05/07/2021 +--- + +# SYSLIB1033: `System.Text.Json` source generator encountered a type with multiple `[JsonConstructor]` annotations + +The `System.Text.Json` source generator encountered a serializable type with multiple `[JsonConstructor]` annotations. + +## Workarounds + +Remove duplicate `[JsonConstructor]` annotations. + +[!INCLUDE [suppress-syslib-warning](includes/suppress-source-generator-diagnostics.md)] diff --git a/docs/fundamentals/syslib-diagnostics/syslib1035.md b/docs/fundamentals/syslib-diagnostics/syslib1035.md new file mode 100644 index 0000000000000..06005b25d57eb --- /dev/null +++ b/docs/fundamentals/syslib-diagnostics/syslib1035.md @@ -0,0 +1,15 @@ +--- +title: SYSLIB1035 error +description: Learn about the diagnostic that generates compile-time error SYSLIB1035. +ms.date: 05/07/2021 +--- + +# SYSLIB1035: `System.Text.Json` source generator encountered a type with multiple `[JsonExtensionData]` annotations + +The `System.Text.Json` source generator encountered a serializable type with multiple `[JsonExtensionData]` annotations. + +## Workarounds + +Remove duplicate `[JsonExtensionData]` annotations. + +[!INCLUDE [suppress-syslib-warning](includes/suppress-source-generator-diagnostics.md)] diff --git a/docs/fundamentals/syslib-diagnostics/syslib1036.md b/docs/fundamentals/syslib-diagnostics/syslib1036.md new file mode 100644 index 0000000000000..996859c3c81f5 --- /dev/null +++ b/docs/fundamentals/syslib-diagnostics/syslib1036.md @@ -0,0 +1,15 @@ +--- +title: SYSLIB1036 error +description: Learn about the diagnostic that generates compile-time error SYSLIB1036. +ms.date: 05/07/2021 +--- + +# SYSLIB1036: `System.Text.Json` source generator encountered an invalid `[JsonExtensionData]` annotation + +The `System.Text.Json` source generator encountered a property or field annotated with `[JsonExtensionData]` but whose data type does not implement `IDictionary`, `IDictionary`, `IDictionary`, or `JsonNode`. + +## Workarounds + +Ensure that the data type for any property or field that is annotated with `[JsonExtensionData]` implements `IDictionary`, `IDictionary`, `IDictionary`, or `JsonNode`. + +[!INCLUDE [suppress-syslib-warning](includes/suppress-source-generator-diagnostics.md)] diff --git a/docs/fundamentals/syslib-diagnostics/syslib1037.md b/docs/fundamentals/syslib-diagnostics/syslib1037.md new file mode 100644 index 0000000000000..d5c738e77c474 --- /dev/null +++ b/docs/fundamentals/syslib-diagnostics/syslib1037.md @@ -0,0 +1,15 @@ +--- +title: SYSLIB1037 warning +description: Learn about the diagnostic that generates compile-time warning SYSLIB1037. +ms.date: 05/07/2021 +--- + +# SYSLIB1037: `System.Text.Json` source generator encountered a type with init-only properties which are not supported for deserialization + +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. + +## Workarounds + +If deserialization of init-only properties is required, use the [reflection-based `JsonSerializer` implementation](../../standard/serialization/system-text-json-source-generation-modes.md). + +[!INCLUDE [suppress-syslib-warning](includes/suppress-source-generator-diagnostics.md)] diff --git a/docs/fundamentals/syslib-diagnostics/syslib1038.md b/docs/fundamentals/syslib-diagnostics/syslib1038.md new file mode 100644 index 0000000000000..15a0b33f0aec4 --- /dev/null +++ b/docs/fundamentals/syslib-diagnostics/syslib1038.md @@ -0,0 +1,15 @@ +--- +title: SYSLIB1038 warning +description: Learn about the diagnostic that generates compile-time warning SYSLIB1038. +ms.date: 05/07/2021 +--- + +# SYSLIB1038: `System.Text.Json` source generator encountered a property annotated with `[JsonInclude]` but with inaccessible accessors + +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`. + +## Workarounds + +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). + +[!INCLUDE [suppress-syslib-warning](includes/suppress-source-generator-diagnostics.md)] From bd3d8fa1aa61bef4cf9a1e9b1abfc11ad816b564 Mon Sep 17 00:00:00 2001 From: Layomi Akinrinade Date: Wed, 1 Dec 2021 14:11:24 -0500 Subject: [PATCH 2/9] Update docs/fundamentals/syslib-diagnostics/source-generator-overview.md Co-authored-by: Tom Dykstra --- .../syslib-diagnostics/source-generator-overview.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/fundamentals/syslib-diagnostics/source-generator-overview.md b/docs/fundamentals/syslib-diagnostics/source-generator-overview.md index 0062f6d2b1611..a7d74a214162f 100644 --- a/docs/fundamentals/syslib-diagnostics/source-generator-overview.md +++ b/docs/fundamentals/syslib-diagnostics/source-generator-overview.md @@ -44,7 +44,7 @@ The following table provides an index to the `SYSLIB1XXX` diagnostics in .NET 6 | [SYSLIB1022][1022] | Can't have malformed format strings (for example, dangling curly braces) | | [SYSLIB1023][1023] | Generating more than six arguments is not supported | | [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 | +| [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 | | [SYSLIB1033][1033] | The `System.Text.Json` source generator encountered a type that has multiple [JsonConstructor] annotations| | [SYSLIB1035][1035] | The `System.Text.Json` source generator encountered a type that has multiple [JsonExtensionData] annotations | From 3e556e0a187f3c37b55f0a6e17c77e56a8de8620 Mon Sep 17 00:00:00 2001 From: Layomi Akinrinade Date: Wed, 1 Dec 2021 14:11:44 -0500 Subject: [PATCH 3/9] Update docs/fundamentals/syslib-diagnostics/source-generator-overview.md Co-authored-by: Tom Dykstra --- .../syslib-diagnostics/source-generator-overview.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/fundamentals/syslib-diagnostics/source-generator-overview.md b/docs/fundamentals/syslib-diagnostics/source-generator-overview.md index a7d74a214162f..67642e63062ab 100644 --- a/docs/fundamentals/syslib-diagnostics/source-generator-overview.md +++ b/docs/fundamentals/syslib-diagnostics/source-generator-overview.md @@ -46,7 +46,7 @@ The following table provides an index to the `SYSLIB1XXX` diagnostics in .NET 6 | [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 | -| [SYSLIB1033][1033] | The `System.Text.Json` source generator encountered a type that has multiple [JsonConstructor] annotations| +| [SYSLIB1033][1033] | The `System.Text.Json` source generator encountered a type that has multiple `[JsonConstructor]` annotations| | [SYSLIB1035][1035] | The `System.Text.Json` source generator encountered a type that has multiple [JsonExtensionData] annotations | | [SYSLIB1036][1036] | The `System.Text.Json` source generator encountered an invalid [JsonExtensionData] annotation | | [SYSLIB1037][1037] | The `System.Text.Json` source generator encountered a type with init-only properties for which deserialization is not supported | From 464015c13221da1ec2b9b6d2d66159ceb8742745 Mon Sep 17 00:00:00 2001 From: Layomi Akinrinade Date: Wed, 1 Dec 2021 14:12:02 -0500 Subject: [PATCH 4/9] Update docs/fundamentals/syslib-diagnostics/source-generator-overview.md Co-authored-by: Tom Dykstra --- .../syslib-diagnostics/source-generator-overview.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/fundamentals/syslib-diagnostics/source-generator-overview.md b/docs/fundamentals/syslib-diagnostics/source-generator-overview.md index 67642e63062ab..20c5f72924590 100644 --- a/docs/fundamentals/syslib-diagnostics/source-generator-overview.md +++ b/docs/fundamentals/syslib-diagnostics/source-generator-overview.md @@ -48,7 +48,7 @@ The following table provides an index to the `SYSLIB1XXX` diagnostics in .NET 6 | [SYSLIB1032][1032] | The `System.Text.Json` source generator encountered a context class that is not partial | | [SYSLIB1033][1033] | The `System.Text.Json` source generator encountered a type that has multiple `[JsonConstructor]` annotations| | [SYSLIB1035][1035] | The `System.Text.Json` source generator encountered a type that has multiple [JsonExtensionData] annotations | -| [SYSLIB1036][1036] | The `System.Text.Json` source generator encountered an invalid [JsonExtensionData] annotation | +| [SYSLIB1036][1036] | The `System.Text.Json` source generator encountered an invalid `[JsonExtensionData]` annotation | | [SYSLIB1037][1037] | The `System.Text.Json` source generator encountered a type with init-only properties for which deserialization is not supported | | [SYSLIB1038][1038] | The `System.Text.Json` source generator encountered a property annotated with [JsonInclude] that has inaccessible accessors | From d28c7316e228d010907b5076446966f0c433f635 Mon Sep 17 00:00:00 2001 From: Layomi Akinrinade Date: Wed, 1 Dec 2021 14:12:10 -0500 Subject: [PATCH 5/9] Update docs/fundamentals/syslib-diagnostics/source-generator-overview.md Co-authored-by: Tom Dykstra --- .../syslib-diagnostics/source-generator-overview.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/fundamentals/syslib-diagnostics/source-generator-overview.md b/docs/fundamentals/syslib-diagnostics/source-generator-overview.md index 20c5f72924590..8f855dac81c6c 100644 --- a/docs/fundamentals/syslib-diagnostics/source-generator-overview.md +++ b/docs/fundamentals/syslib-diagnostics/source-generator-overview.md @@ -50,7 +50,7 @@ The following table provides an index to the `SYSLIB1XXX` diagnostics in .NET 6 | [SYSLIB1035][1035] | The `System.Text.Json` source generator encountered a type that has multiple [JsonExtensionData] annotations | | [SYSLIB1036][1036] | The `System.Text.Json` source generator encountered an invalid `[JsonExtensionData]` annotation | | [SYSLIB1037][1037] | The `System.Text.Json` source generator encountered a type with init-only properties for which deserialization is not supported | -| [SYSLIB1038][1038] | The `System.Text.Json` source generator encountered a property annotated with [JsonInclude] that has inaccessible accessors | +| [SYSLIB1038][1038] | The `System.Text.Json` source generator encountered a property annotated with `[JsonInclude]` that has inaccessible accessors | [!INCLUDE [suppress-source-generator-diagnostics](includes/suppress-source-generator-diagnostics.md)] From ba6adb79282d8193c52b52141f52632d0f24a984 Mon Sep 17 00:00:00 2001 From: Layomi Akinrinade Date: Wed, 1 Dec 2021 14:12:24 -0500 Subject: [PATCH 6/9] Update docs/fundamentals/syslib-diagnostics/source-generator-overview.md Co-authored-by: Tom Dykstra --- .../syslib-diagnostics/source-generator-overview.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/fundamentals/syslib-diagnostics/source-generator-overview.md b/docs/fundamentals/syslib-diagnostics/source-generator-overview.md index 8f855dac81c6c..2d1673e749eb0 100644 --- a/docs/fundamentals/syslib-diagnostics/source-generator-overview.md +++ b/docs/fundamentals/syslib-diagnostics/source-generator-overview.md @@ -85,4 +85,4 @@ The following table provides an index to the `SYSLIB1XXX` diagnostics in .NET 6 [1035]: syslib1035.md [1036]: syslib1036.md [1037]: syslib1037.md -[1039]: syslib1038.md +[1038]: syslib1038.md From 4ed36f6535cbdafcd00d97fafea04993523a7959 Mon Sep 17 00:00:00 2001 From: Layomi Akinrinade Date: Wed, 1 Dec 2021 14:12:44 -0500 Subject: [PATCH 7/9] Update docs/fundamentals/syslib-diagnostics/syslib1038.md Co-authored-by: Tom Dykstra --- docs/fundamentals/syslib-diagnostics/syslib1038.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/fundamentals/syslib-diagnostics/syslib1038.md b/docs/fundamentals/syslib-diagnostics/syslib1038.md index 15a0b33f0aec4..070328f9657fa 100644 --- a/docs/fundamentals/syslib-diagnostics/syslib1038.md +++ b/docs/fundamentals/syslib-diagnostics/syslib1038.md @@ -6,7 +6,7 @@ ms.date: 05/07/2021 # SYSLIB1038: `System.Text.Json` source generator encountered a property annotated with `[JsonInclude]` but with inaccessible accessors -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`. +The `System.Text.Json` source generator encountered a property that is annotated with `[JsonInclude]` but has accessors that are inaccessible to the source generator. The property must have `public` or `internal` accessors. ## Workarounds From 3e1383154489043c31e4a301298055c1e4439525 Mon Sep 17 00:00:00 2001 From: Layomi Akinrinade Date: Wed, 1 Dec 2021 14:13:04 -0500 Subject: [PATCH 8/9] Update docs/fundamentals/syslib-diagnostics/syslib1032.md Co-authored-by: Tom Dykstra --- docs/fundamentals/syslib-diagnostics/syslib1032.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/fundamentals/syslib-diagnostics/syslib1032.md b/docs/fundamentals/syslib-diagnostics/syslib1032.md index ed4280d38360b..3c641ce96e7b9 100644 --- a/docs/fundamentals/syslib-diagnostics/syslib1032.md +++ b/docs/fundamentals/syslib-diagnostics/syslib1032.md @@ -6,7 +6,7 @@ ms.date: 05/07/2021 # SYSLIB1032: Context classes to be augmented by the `System.Text.Json` source generator must be declared as partial -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. +The `System.Text.Json` source generator encountered a context type included for source generation that is not partial, or whose containing type(s) is not partial. ## Workarounds From 09b8a85a3ef600de887774a7246ba6b1c5850af9 Mon Sep 17 00:00:00 2001 From: Layomi Akinrinade Date: Wed, 1 Dec 2021 16:23:29 -0500 Subject: [PATCH 9/9] Update docs/fundamentals/syslib-diagnostics/source-generator-overview.md Co-authored-by: Tom Dykstra --- .../syslib-diagnostics/source-generator-overview.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/fundamentals/syslib-diagnostics/source-generator-overview.md b/docs/fundamentals/syslib-diagnostics/source-generator-overview.md index 2d1673e749eb0..fd3c0e7c64a7a 100644 --- a/docs/fundamentals/syslib-diagnostics/source-generator-overview.md +++ b/docs/fundamentals/syslib-diagnostics/source-generator-overview.md @@ -47,7 +47,7 @@ The following table provides an index to the `SYSLIB1XXX` diagnostics in .NET 6 | [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 | | [SYSLIB1033][1033] | The `System.Text.Json` source generator encountered a type that has multiple `[JsonConstructor]` annotations| -| [SYSLIB1035][1035] | The `System.Text.Json` source generator encountered a type that has multiple [JsonExtensionData] annotations | +| [SYSLIB1035][1035] | The `System.Text.Json` source generator encountered a type that has multiple `[JsonExtensionData]` annotations | | [SYSLIB1036][1036] | The `System.Text.Json` source generator encountered an invalid `[JsonExtensionData]` annotation | | [SYSLIB1037][1037] | The `System.Text.Json` source generator encountered a type with init-only properties for which deserialization is not supported | | [SYSLIB1038][1038] | The `System.Text.Json` source generator encountered a property annotated with `[JsonInclude]` that has inaccessible accessors |