diff --git a/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/SourceGenRegressionTests/Net60/Net60GeneratedContext.ClassWithCustomConverter.g.cs b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/SourceGenRegressionTests/Net60/Net60GeneratedContext.ClassWithCustomConverter.g.cs
new file mode 100644
index 00000000000000..01b7c74488ebd5
--- /dev/null
+++ b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/SourceGenRegressionTests/Net60/Net60GeneratedContext.ClassWithCustomConverter.g.cs
@@ -0,0 +1,46 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+// Source files represent a source generated JsonSerializerContext as produced by the .NET 6 SDK.
+// Used to validate correctness of contexts generated by previous SDKs against the current System.Text.Json runtime components.
+// Unless absolutely necessary DO NOT MODIFY any of these files -- it would invalidate the purpose of the regression tests.
+
+//
+#nullable enable
+
+// Suppress warnings about [Obsolete] member usage in generated code.
+#pragma warning disable CS0618
+
+namespace System.Text.Json.Tests.SourceGenRegressionTests.Net60
+{
+ public partial class Net60GeneratedContext
+ {
+ private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? _ClassWithCustomConverter;
+ public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ClassWithCustomConverter
+ {
+ get
+ {
+ if (_ClassWithCustomConverter == null)
+ {
+ global::System.Text.Json.Serialization.JsonConverter? customConverter;
+ if (Options.Converters.Count > 0 && (customConverter = GetRuntimeProvidedCustomConverter(typeof(global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.ClassWithCustomConverter))) != null)
+ {
+ _ClassWithCustomConverter = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo(Options, customConverter);
+ }
+ else
+ {
+ global::System.Text.Json.Serialization.JsonConverter converter = new global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.ClassWithCustomConverter.CustomConverter();
+ global::System.Type typeToConvert = typeof(global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.ClassWithCustomConverter);
+ if (!converter.CanConvert(typeToConvert))
+ {
+ throw new global::System.InvalidOperationException(string.Format("The converter '{0}' is not compatible with the type '{1}'.", converter.GetType(), typeToConvert));
+ }
+ _ClassWithCustomConverter = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo (Options, converter);
+ }
+ }
+
+ return _ClassWithCustomConverter;
+ }
+ }
+ }
+}
diff --git a/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/SourceGenRegressionTests/Net60/Net60GeneratedContext.DateTimeOffset.g.cs b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/SourceGenRegressionTests/Net60/Net60GeneratedContext.DateTimeOffset.g.cs
new file mode 100644
index 00000000000000..6d88adf36b3ad2
--- /dev/null
+++ b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/SourceGenRegressionTests/Net60/Net60GeneratedContext.DateTimeOffset.g.cs
@@ -0,0 +1,40 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+// Source files represent a source generated JsonSerializerContext as produced by the .NET 6 SDK.
+// Used to validate correctness of contexts generated by previous SDKs against the current System.Text.Json runtime components.
+// Unless absolutely necessary DO NOT MODIFY any of these files -- it would invalidate the purpose of the regression tests.
+
+//
+#nullable enable
+
+// Suppress warnings about [Obsolete] member usage in generated code.
+#pragma warning disable CS0618
+
+namespace System.Text.Json.Tests.SourceGenRegressionTests.Net60
+{
+ public partial class Net60GeneratedContext
+ {
+ private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? _DateTimeOffset;
+ public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo DateTimeOffset
+ {
+ get
+ {
+ if (_DateTimeOffset == null)
+ {
+ global::System.Text.Json.Serialization.JsonConverter? customConverter;
+ if (Options.Converters.Count > 0 && (customConverter = GetRuntimeProvidedCustomConverter(typeof(global::System.DateTimeOffset))) != null)
+ {
+ _DateTimeOffset = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo(Options, customConverter);
+ }
+ else
+ {
+ _DateTimeOffset = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo(Options, global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.DateTimeOffsetConverter);
+ }
+ }
+
+ return _DateTimeOffset;
+ }
+ }
+ }
+}
diff --git a/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/SourceGenRegressionTests/Net60/Net60GeneratedContext.DictionaryStringHighLowTemps.g.cs b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/SourceGenRegressionTests/Net60/Net60GeneratedContext.DictionaryStringHighLowTemps.g.cs
new file mode 100644
index 00000000000000..2066ab74b534cc
--- /dev/null
+++ b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/SourceGenRegressionTests/Net60/Net60GeneratedContext.DictionaryStringHighLowTemps.g.cs
@@ -0,0 +1,69 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+// Source files represent a source generated JsonSerializerContext as produced by the .NET 6 SDK.
+// Used to validate correctness of contexts generated by previous SDKs against the current System.Text.Json runtime components.
+// Unless absolutely necessary DO NOT MODIFY any of these files -- it would invalidate the purpose of the regression tests.
+
+//
+#nullable enable
+
+// Suppress warnings about [Obsolete] member usage in generated code.
+#pragma warning disable CS0618
+
+namespace System.Text.Json.Tests.SourceGenRegressionTests.Net60
+{
+ public partial class Net60GeneratedContext
+ {
+ private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo>? _DictionaryStringHighLowTemps;
+ public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo> DictionaryStringHighLowTemps
+ {
+ get
+ {
+ if (_DictionaryStringHighLowTemps == null)
+ {
+ global::System.Text.Json.Serialization.JsonConverter? customConverter;
+ if (Options.Converters.Count > 0 && (customConverter = GetRuntimeProvidedCustomConverter(typeof(global::System.Collections.Generic.Dictionary))) != null)
+ {
+ _DictionaryStringHighLowTemps = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo>(Options, customConverter);
+ }
+ else
+ {
+ global::System.Text.Json.Serialization.Metadata.JsonCollectionInfoValues> info = new global::System.Text.Json.Serialization.Metadata.JsonCollectionInfoValues>()
+ {
+ ObjectCreator = () => new global::System.Collections.Generic.Dictionary(),
+ KeyInfo = this.String,
+ ElementInfo = this.HighLowTemps,
+ NumberHandling = default,
+ SerializeHandler = DictionaryStringHighLowTempsSerializeHandler
+ };
+
+ _DictionaryStringHighLowTemps = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateDictionaryInfo, global::System.String, global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.HighLowTemps>(Options, info);
+
+ }
+ }
+
+ return _DictionaryStringHighLowTemps;
+ }
+ }
+
+ private static void DictionaryStringHighLowTempsSerializeHandler(global::System.Text.Json.Utf8JsonWriter writer, global::System.Collections.Generic.Dictionary? value)
+ {
+ if (value == null)
+ {
+ writer.WriteNullValue();
+ return;
+ }
+
+ writer.WriteStartObject();
+
+ foreach (global::System.Collections.Generic.KeyValuePair pair in value)
+ {
+ writer.WritePropertyName(pair.Key);
+ HighLowTempsSerializeHandler(writer, pair.Value!);
+ }
+
+ writer.WriteEndObject();
+ }
+ }
+}
diff --git a/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/SourceGenRegressionTests/Net60/Net60GeneratedContext.GetJsonTypeInfo.g.cs b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/SourceGenRegressionTests/Net60/Net60GeneratedContext.GetJsonTypeInfo.g.cs
new file mode 100644
index 00000000000000..61eec78d7932d1
--- /dev/null
+++ b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/SourceGenRegressionTests/Net60/Net60GeneratedContext.GetJsonTypeInfo.g.cs
@@ -0,0 +1,33 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+// Source files represent a source generated JsonSerializerContext as produced by the .NET 6 SDK.
+// Used to validate correctness of contexts generated by previous SDKs against the current System.Text.Json runtime components.
+// Unless absolutely necessary DO NOT MODIFY any of these files -- it would invalidate the purpose of the regression tests.
+
+//
+#nullable enable
+
+// Suppress warnings about [Obsolete] member usage in generated code.
+#pragma warning disable CS0618
+
+namespace System.Text.Json.Tests.SourceGenRegressionTests.Net60
+{
+ public partial class Net60GeneratedContext
+ {
+ public override global::System.Text.Json.Serialization.Metadata.JsonTypeInfo GetTypeInfo(global::System.Type type)
+ {
+ if (type == typeof(global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.WeatherForecastWithPOCOs))
+ {
+ return this.WeatherForecastWithPOCOs;
+ }
+
+ if (type == typeof(global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.ClassWithCustomConverter))
+ {
+ return this.ClassWithCustomConverter;
+ }
+
+ return null!;
+ }
+ }
+}
diff --git a/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/SourceGenRegressionTests/Net60/Net60GeneratedContext.HighLowTemps.g.cs b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/SourceGenRegressionTests/Net60/Net60GeneratedContext.HighLowTemps.g.cs
new file mode 100644
index 00000000000000..04010f8b761bcd
--- /dev/null
+++ b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/SourceGenRegressionTests/Net60/Net60GeneratedContext.HighLowTemps.g.cs
@@ -0,0 +1,115 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+// Source files represent a source generated JsonSerializerContext as produced by the .NET 6 SDK.
+// Used to validate correctness of contexts generated by previous SDKs against the current System.Text.Json runtime components.
+// Unless absolutely necessary DO NOT MODIFY any of these files -- it would invalidate the purpose of the regression tests.
+
+//
+#nullable enable
+
+// Suppress warnings about [Obsolete] member usage in generated code.
+#pragma warning disable CS0618
+
+namespace System.Text.Json.Tests.SourceGenRegressionTests.Net60
+{
+ public partial class Net60GeneratedContext
+ {
+ private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? _HighLowTemps;
+ public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo HighLowTemps
+ {
+ get
+ {
+ if (_HighLowTemps == null)
+ {
+ global::System.Text.Json.Serialization.JsonConverter? customConverter;
+ if (Options.Converters.Count > 0 && (customConverter = GetRuntimeProvidedCustomConverter(typeof(global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.HighLowTemps))) != null)
+ {
+ _HighLowTemps = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo(Options, customConverter);
+ }
+ else
+ {
+ global::System.Text.Json.Serialization.Metadata.JsonObjectInfoValues objectInfo = new global::System.Text.Json.Serialization.Metadata.JsonObjectInfoValues()
+ {
+ ObjectCreator = static () => new global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.HighLowTemps(),
+ ObjectWithParameterizedConstructorCreator = null,
+ PropertyMetadataInitializer = HighLowTempsPropInit,
+ ConstructorParameterMetadataInitializer = null,
+ NumberHandling = default,
+ SerializeHandler = HighLowTempsSerializeHandler
+ };
+
+ _HighLowTemps = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateObjectInfo(Options, objectInfo);
+ }
+ }
+
+ return _HighLowTemps;
+ }
+ }
+
+ private static global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[] HighLowTempsPropInit(global::System.Text.Json.Serialization.JsonSerializerContext context)
+ {
+ global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.Net60GeneratedContext jsonContext = (global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.Net60GeneratedContext)context;
+ global::System.Text.Json.JsonSerializerOptions options = context.Options;
+
+ global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[] properties = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[2];
+
+ global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues info0 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues()
+ {
+ IsProperty = true,
+ IsPublic = true,
+ IsVirtual = false,
+ DeclaringType = typeof(global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.HighLowTemps),
+ PropertyTypeInfo = jsonContext.Int32,
+ Converter = null,
+ Getter = static (obj) => ((global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.HighLowTemps)obj).High,
+ Setter = static (obj, value) => ((global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.HighLowTemps)obj).High = value!,
+ IgnoreCondition = null,
+ HasJsonInclude = false,
+ IsExtensionData = false,
+ NumberHandling = default,
+ PropertyName = "High",
+ JsonPropertyName = null
+ };
+
+ properties[0] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo(options, info0);
+
+ global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues info1 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues()
+ {
+ IsProperty = true,
+ IsPublic = true,
+ IsVirtual = false,
+ DeclaringType = typeof(global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.HighLowTemps),
+ PropertyTypeInfo = jsonContext.Int32,
+ Converter = null,
+ Getter = static (obj) => ((global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.HighLowTemps)obj).Low,
+ Setter = static (obj, value) => ((global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.HighLowTemps)obj).Low = value!,
+ IgnoreCondition = null,
+ HasJsonInclude = false,
+ IsExtensionData = false,
+ NumberHandling = default,
+ PropertyName = "Low",
+ JsonPropertyName = null
+ };
+
+ properties[1] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo(options, info1);
+
+ return properties;
+ }
+
+ private static void HighLowTempsSerializeHandler(global::System.Text.Json.Utf8JsonWriter writer, global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.HighLowTemps? value)
+ {
+ if (value == null)
+ {
+ writer.WriteNullValue();
+ return;
+ }
+
+ writer.WriteStartObject();
+ writer.WriteNumber(PropName_High, value.High);
+ writer.WriteNumber(PropName_Low, value.Low);
+
+ writer.WriteEndObject();
+ }
+ }
+}
diff --git a/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/SourceGenRegressionTests/Net60/Net60GeneratedContext.Int32.g.cs b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/SourceGenRegressionTests/Net60/Net60GeneratedContext.Int32.g.cs
new file mode 100644
index 00000000000000..f6236edd6f5c2c
--- /dev/null
+++ b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/SourceGenRegressionTests/Net60/Net60GeneratedContext.Int32.g.cs
@@ -0,0 +1,40 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+// Source files represent a source generated JsonSerializerContext as produced by the .NET 6 SDK.
+// Used to validate correctness of contexts generated by previous SDKs against the current System.Text.Json runtime components.
+// Unless absolutely necessary DO NOT MODIFY any of these files -- it would invalidate the purpose of the regression tests.
+
+//
+#nullable enable
+
+// Suppress warnings about [Obsolete] member usage in generated code.
+#pragma warning disable CS0618
+
+namespace System.Text.Json.Tests.SourceGenRegressionTests.Net60
+{
+ public partial class Net60GeneratedContext
+ {
+ private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? _Int32;
+ public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo Int32
+ {
+ get
+ {
+ if (_Int32 == null)
+ {
+ global::System.Text.Json.Serialization.JsonConverter? customConverter;
+ if (Options.Converters.Count > 0 && (customConverter = GetRuntimeProvidedCustomConverter(typeof(global::System.Int32))) != null)
+ {
+ _Int32 = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo(Options, customConverter);
+ }
+ else
+ {
+ _Int32 = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo(Options, global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.Int32Converter);
+ }
+ }
+
+ return _Int32;
+ }
+ }
+ }
+}
diff --git a/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/SourceGenRegressionTests/Net60/Net60GeneratedContext.ListDateTimeOffset.g.cs b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/SourceGenRegressionTests/Net60/Net60GeneratedContext.ListDateTimeOffset.g.cs
new file mode 100644
index 00000000000000..f969da8b4c88cf
--- /dev/null
+++ b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/SourceGenRegressionTests/Net60/Net60GeneratedContext.ListDateTimeOffset.g.cs
@@ -0,0 +1,61 @@
+//
+#nullable enable
+
+// Suppress warnings about [Obsolete] member usage in generated code.
+#pragma warning disable CS0618
+
+namespace System.Text.Json.Tests.SourceGenRegressionTests.Net60
+{
+ public partial class Net60GeneratedContext
+ {
+ private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo>? _ListDateTimeOffset;
+ public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo> ListDateTimeOffset
+ {
+ get
+ {
+ if (_ListDateTimeOffset == null)
+ {
+ global::System.Text.Json.Serialization.JsonConverter? customConverter;
+ if (Options.Converters.Count > 0 && (customConverter = GetRuntimeProvidedCustomConverter(typeof(global::System.Collections.Generic.List))) != null)
+ {
+ _ListDateTimeOffset = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo>(Options, customConverter);
+ }
+ else
+ {
+ global::System.Text.Json.Serialization.Metadata.JsonCollectionInfoValues> info = new global::System.Text.Json.Serialization.Metadata.JsonCollectionInfoValues>()
+ {
+ ObjectCreator = () => new global::System.Collections.Generic.List(),
+ KeyInfo = null,
+ ElementInfo = this.DateTimeOffset,
+ NumberHandling = default,
+ SerializeHandler = ListDateTimeOffsetSerializeHandler
+ };
+
+ _ListDateTimeOffset = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateListInfo, global::System.DateTimeOffset>(Options, info);
+
+ }
+ }
+
+ return _ListDateTimeOffset;
+ }
+ }
+
+ private static void ListDateTimeOffsetSerializeHandler(global::System.Text.Json.Utf8JsonWriter writer, global::System.Collections.Generic.List? value)
+ {
+ if (value == null)
+ {
+ writer.WriteNullValue();
+ return;
+ }
+
+ writer.WriteStartArray();
+
+ for (int i = 0; i < value.Count; i++)
+ {
+ writer.WriteStringValue(value[i]);
+ }
+
+ writer.WriteEndArray();
+ }
+ }
+}
diff --git a/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/SourceGenRegressionTests/Net60/Net60GeneratedContext.PropertyNames.g.cs b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/SourceGenRegressionTests/Net60/Net60GeneratedContext.PropertyNames.g.cs
new file mode 100644
index 00000000000000..84f4b425d6e7a0
--- /dev/null
+++ b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/SourceGenRegressionTests/Net60/Net60GeneratedContext.PropertyNames.g.cs
@@ -0,0 +1,28 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+// Source files represent a source generated JsonSerializerContext as produced by the .NET 6 SDK.
+// Used to validate correctness of contexts generated by previous SDKs against the current System.Text.Json runtime components.
+// Unless absolutely necessary DO NOT MODIFY any of these files -- it would invalidate the purpose of the regression tests.
+
+//
+#nullable enable
+
+// Suppress warnings about [Obsolete] member usage in generated code.
+#pragma warning disable CS0618
+
+namespace System.Text.Json.Tests.SourceGenRegressionTests.Net60
+{
+ public partial class Net60GeneratedContext
+ {
+
+ private static readonly global::System.Text.Json.JsonEncodedText PropName_Date = global::System.Text.Json.JsonEncodedText.Encode("Date");
+ private static readonly global::System.Text.Json.JsonEncodedText PropName_TemperatureCelsius = global::System.Text.Json.JsonEncodedText.Encode("TemperatureCelsius");
+ private static readonly global::System.Text.Json.JsonEncodedText PropName_Summary = global::System.Text.Json.JsonEncodedText.Encode("Summary");
+ private static readonly global::System.Text.Json.JsonEncodedText PropName_DatesAvailable = global::System.Text.Json.JsonEncodedText.Encode("DatesAvailable");
+ private static readonly global::System.Text.Json.JsonEncodedText PropName_TemperatureRanges = global::System.Text.Json.JsonEncodedText.Encode("TemperatureRanges");
+ private static readonly global::System.Text.Json.JsonEncodedText PropName_SummaryWords = global::System.Text.Json.JsonEncodedText.Encode("SummaryWords");
+ private static readonly global::System.Text.Json.JsonEncodedText PropName_High = global::System.Text.Json.JsonEncodedText.Encode("High");
+ private static readonly global::System.Text.Json.JsonEncodedText PropName_Low = global::System.Text.Json.JsonEncodedText.Encode("Low");
+ }
+}
diff --git a/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/SourceGenRegressionTests/Net60/Net60GeneratedContext.String.g.cs b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/SourceGenRegressionTests/Net60/Net60GeneratedContext.String.g.cs
new file mode 100644
index 00000000000000..7f0c77bc9c81d6
--- /dev/null
+++ b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/SourceGenRegressionTests/Net60/Net60GeneratedContext.String.g.cs
@@ -0,0 +1,40 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+// Source files represent a source generated JsonSerializerContext as produced by the .NET 6 SDK.
+// Used to validate correctness of contexts generated by previous SDKs against the current System.Text.Json runtime components.
+// Unless absolutely necessary DO NOT MODIFY any of these files -- it would invalidate the purpose of the regression tests.
+
+//
+#nullable enable
+
+// Suppress warnings about [Obsolete] member usage in generated code.
+#pragma warning disable CS0618
+
+namespace System.Text.Json.Tests.SourceGenRegressionTests.Net60
+{
+ public partial class Net60GeneratedContext
+ {
+ private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? _String;
+ public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo String
+ {
+ get
+ {
+ if (_String == null)
+ {
+ global::System.Text.Json.Serialization.JsonConverter? customConverter;
+ if (Options.Converters.Count > 0 && (customConverter = GetRuntimeProvidedCustomConverter(typeof(global::System.String))) != null)
+ {
+ _String = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo(Options, customConverter);
+ }
+ else
+ {
+ _String = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo(Options, global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.StringConverter);
+ }
+ }
+
+ return _String;
+ }
+ }
+ }
+}
diff --git a/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/SourceGenRegressionTests/Net60/Net60GeneratedContext.StringArray.g.cs b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/SourceGenRegressionTests/Net60/Net60GeneratedContext.StringArray.g.cs
new file mode 100644
index 00000000000000..eb356f49052e1d
--- /dev/null
+++ b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/SourceGenRegressionTests/Net60/Net60GeneratedContext.StringArray.g.cs
@@ -0,0 +1,68 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+// Source files represent a source generated JsonSerializerContext as produced by the .NET 6 SDK.
+// Used to validate correctness of contexts generated by previous SDKs against the current System.Text.Json runtime components.
+// Unless absolutely necessary DO NOT MODIFY any of these files -- it would invalidate the purpose of the regression tests.
+
+//
+#nullable enable
+
+// Suppress warnings about [Obsolete] member usage in generated code.
+#pragma warning disable CS0618
+
+namespace System.Text.Json.Tests.SourceGenRegressionTests.Net60
+{
+ public partial class Net60GeneratedContext
+ {
+ private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? _StringArray;
+ public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo StringArray
+ {
+ get
+ {
+ if (_StringArray == null)
+ {
+ global::System.Text.Json.Serialization.JsonConverter? customConverter;
+ if (Options.Converters.Count > 0 && (customConverter = GetRuntimeProvidedCustomConverter(typeof(global::System.String[]))) != null)
+ {
+ _StringArray = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo(Options, customConverter);
+ }
+ else
+ {
+ global::System.Text.Json.Serialization.Metadata.JsonCollectionInfoValues info = new global::System.Text.Json.Serialization.Metadata.JsonCollectionInfoValues()
+ {
+ ObjectCreator = null,
+ KeyInfo = null,
+ ElementInfo = this.String,
+ NumberHandling = default,
+ SerializeHandler = StringArraySerializeHandler
+ };
+
+ _StringArray = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateArrayInfo(Options, info);
+
+ }
+ }
+
+ return _StringArray;
+ }
+ }
+
+ private static void StringArraySerializeHandler(global::System.Text.Json.Utf8JsonWriter writer, global::System.String[]? value)
+ {
+ if (value == null)
+ {
+ writer.WriteNullValue();
+ return;
+ }
+
+ writer.WriteStartArray();
+
+ for (int i = 0; i < value.Length; i++)
+ {
+ writer.WriteStringValue(value[i]);
+ }
+
+ writer.WriteEndArray();
+ }
+ }
+}
diff --git a/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/SourceGenRegressionTests/Net60/Net60GeneratedContext.WeatherForecastWithPOCOs.g.cs b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/SourceGenRegressionTests/Net60/Net60GeneratedContext.WeatherForecastWithPOCOs.g.cs
new file mode 100644
index 00000000000000..9d3592e1a0fd18
--- /dev/null
+++ b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/SourceGenRegressionTests/Net60/Net60GeneratedContext.WeatherForecastWithPOCOs.g.cs
@@ -0,0 +1,222 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+// Source files represent a source generated JsonSerializerContext as produced by the .NET 6 SDK.
+// Used to validate correctness of contexts generated by previous SDKs against the current System.Text.Json runtime components.
+// Unless absolutely necessary DO NOT MODIFY any of these files -- it would invalidate the purpose of the regression tests.
+
+//
+#nullable enable
+
+// Suppress warnings about [Obsolete] member usage in generated code.
+#pragma warning disable CS0618
+
+namespace System.Text.Json.Tests.SourceGenRegressionTests.Net60
+{
+ public partial class Net60GeneratedContext
+ {
+ private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? _WeatherForecastWithPOCOs;
+ public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo WeatherForecastWithPOCOs
+ {
+ get
+ {
+ if (_WeatherForecastWithPOCOs == null)
+ {
+ global::System.Text.Json.Serialization.JsonConverter? customConverter;
+ if (Options.Converters.Count > 0 && (customConverter = GetRuntimeProvidedCustomConverter(typeof(global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.WeatherForecastWithPOCOs))) != null)
+ {
+ _WeatherForecastWithPOCOs = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo(Options, customConverter);
+ }
+ else
+ {
+ global::System.Text.Json.Serialization.Metadata.JsonObjectInfoValues objectInfo = new global::System.Text.Json.Serialization.Metadata.JsonObjectInfoValues()
+ {
+ ObjectCreator = static () => new global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.WeatherForecastWithPOCOs(),
+ ObjectWithParameterizedConstructorCreator = null,
+ PropertyMetadataInitializer = WeatherForecastWithPOCOsPropInit,
+ ConstructorParameterMetadataInitializer = null,
+ NumberHandling = default,
+ SerializeHandler = WeatherForecastWithPOCOsSerializeHandler
+ };
+
+ _WeatherForecastWithPOCOs = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateObjectInfo(Options, objectInfo);
+ }
+ }
+
+ return _WeatherForecastWithPOCOs;
+ }
+ }
+
+ private static global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[] WeatherForecastWithPOCOsPropInit(global::System.Text.Json.Serialization.JsonSerializerContext context)
+ {
+ global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.Net60GeneratedContext jsonContext = (global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.Net60GeneratedContext)context;
+ global::System.Text.Json.JsonSerializerOptions options = context.Options;
+
+ global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[] properties = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[7];
+
+ global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues info0 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues()
+ {
+ IsProperty = true,
+ IsPublic = true,
+ IsVirtual = false,
+ DeclaringType = typeof(global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.WeatherForecastWithPOCOs),
+ PropertyTypeInfo = jsonContext.DateTimeOffset,
+ Converter = null,
+ Getter = static (obj) => ((global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.WeatherForecastWithPOCOs)obj).Date,
+ Setter = static (obj, value) => ((global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.WeatherForecastWithPOCOs)obj).Date = value!,
+ IgnoreCondition = null,
+ HasJsonInclude = false,
+ IsExtensionData = false,
+ NumberHandling = default,
+ PropertyName = "Date",
+ JsonPropertyName = null
+ };
+
+ properties[0] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo(options, info0);
+
+ global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues info1 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues()
+ {
+ IsProperty = true,
+ IsPublic = true,
+ IsVirtual = false,
+ DeclaringType = typeof(global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.WeatherForecastWithPOCOs),
+ PropertyTypeInfo = jsonContext.Int32,
+ Converter = null,
+ Getter = static (obj) => ((global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.WeatherForecastWithPOCOs)obj).TemperatureCelsius,
+ Setter = static (obj, value) => ((global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.WeatherForecastWithPOCOs)obj).TemperatureCelsius = value!,
+ IgnoreCondition = null,
+ HasJsonInclude = false,
+ IsExtensionData = false,
+ NumberHandling = default,
+ PropertyName = "TemperatureCelsius",
+ JsonPropertyName = null
+ };
+
+ properties[1] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo(options, info1);
+
+ global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues info2 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues()
+ {
+ IsProperty = true,
+ IsPublic = true,
+ IsVirtual = false,
+ DeclaringType = typeof(global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.WeatherForecastWithPOCOs),
+ PropertyTypeInfo = jsonContext.String,
+ Converter = null,
+ Getter = static (obj) => ((global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.WeatherForecastWithPOCOs)obj).Summary!,
+ Setter = static (obj, value) => ((global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.WeatherForecastWithPOCOs)obj).Summary = value!,
+ IgnoreCondition = null,
+ HasJsonInclude = false,
+ IsExtensionData = false,
+ NumberHandling = default,
+ PropertyName = "Summary",
+ JsonPropertyName = null
+ };
+
+ properties[2] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo(options, info2);
+
+ global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues> info3 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues>()
+ {
+ IsProperty = true,
+ IsPublic = true,
+ IsVirtual = false,
+ DeclaringType = typeof(global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.WeatherForecastWithPOCOs),
+ PropertyTypeInfo = jsonContext.ListDateTimeOffset,
+ Converter = null,
+ Getter = static (obj) => ((global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.WeatherForecastWithPOCOs)obj).DatesAvailable!,
+ Setter = static (obj, value) => ((global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.WeatherForecastWithPOCOs)obj).DatesAvailable = value!,
+ IgnoreCondition = null,
+ HasJsonInclude = false,
+ IsExtensionData = false,
+ NumberHandling = default,
+ PropertyName = "DatesAvailable",
+ JsonPropertyName = null
+ };
+
+ properties[3] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo>(options, info3);
+
+ global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues> info4 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues>()
+ {
+ IsProperty = true,
+ IsPublic = true,
+ IsVirtual = false,
+ DeclaringType = typeof(global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.WeatherForecastWithPOCOs),
+ PropertyTypeInfo = jsonContext.DictionaryStringHighLowTemps,
+ Converter = null,
+ Getter = static (obj) => ((global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.WeatherForecastWithPOCOs)obj).TemperatureRanges!,
+ Setter = static (obj, value) => ((global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.WeatherForecastWithPOCOs)obj).TemperatureRanges = value!,
+ IgnoreCondition = null,
+ HasJsonInclude = false,
+ IsExtensionData = false,
+ NumberHandling = default,
+ PropertyName = "TemperatureRanges",
+ JsonPropertyName = null
+ };
+
+ properties[4] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo>(options, info4);
+
+ global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues info5 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues()
+ {
+ IsProperty = true,
+ IsPublic = true,
+ IsVirtual = false,
+ DeclaringType = typeof(global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.WeatherForecastWithPOCOs),
+ PropertyTypeInfo = jsonContext.StringArray,
+ Converter = null,
+ Getter = static (obj) => ((global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.WeatherForecastWithPOCOs)obj).SummaryWords!,
+ Setter = static (obj, value) => ((global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.WeatherForecastWithPOCOs)obj).SummaryWords = value!,
+ IgnoreCondition = null,
+ HasJsonInclude = false,
+ IsExtensionData = false,
+ NumberHandling = default,
+ PropertyName = "SummaryWords",
+ JsonPropertyName = null
+ };
+
+ properties[5] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo(options, info5);
+
+ global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues info6 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues()
+ {
+ IsProperty = false,
+ IsPublic = true,
+ IsVirtual = false,
+ DeclaringType = typeof(global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.WeatherForecastWithPOCOs),
+ PropertyTypeInfo = jsonContext.String,
+ Converter = null,
+ Getter = static (obj) => ((global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.WeatherForecastWithPOCOs)obj).SummaryField!,
+ Setter = static (obj, value) => ((global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.WeatherForecastWithPOCOs)obj).SummaryField = value!,
+ IgnoreCondition = null,
+ HasJsonInclude = false,
+ IsExtensionData = false,
+ NumberHandling = default,
+ PropertyName = "SummaryField",
+ JsonPropertyName = null
+ };
+
+ properties[6] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo(options, info6);
+
+ return properties;
+ }
+
+ private static void WeatherForecastWithPOCOsSerializeHandler(global::System.Text.Json.Utf8JsonWriter writer, global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.WeatherForecastWithPOCOs? value)
+ {
+ if (value == null)
+ {
+ writer.WriteNullValue();
+ return;
+ }
+
+ writer.WriteStartObject();
+ writer.WriteString(PropName_Date, ((global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.WeatherForecastWithPOCOs)value).Date);
+ writer.WriteNumber(PropName_TemperatureCelsius, ((global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.WeatherForecastWithPOCOs)value).TemperatureCelsius);
+ writer.WriteString(PropName_Summary, ((global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.WeatherForecastWithPOCOs)value).Summary);
+ writer.WritePropertyName(PropName_DatesAvailable);
+ ListDateTimeOffsetSerializeHandler(writer, ((global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.WeatherForecastWithPOCOs)value).DatesAvailable!);
+ writer.WritePropertyName(PropName_TemperatureRanges);
+ DictionaryStringHighLowTempsSerializeHandler(writer, ((global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.WeatherForecastWithPOCOs)value).TemperatureRanges!);
+ writer.WritePropertyName(PropName_SummaryWords);
+ StringArraySerializeHandler(writer, ((global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.WeatherForecastWithPOCOs)value).SummaryWords!);
+
+ writer.WriteEndObject();
+ }
+ }
+}
diff --git a/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/SourceGenRegressionTests/Net60/Net60GeneratedContext.cs b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/SourceGenRegressionTests/Net60/Net60GeneratedContext.cs
new file mode 100644
index 00000000000000..7158db21983038
--- /dev/null
+++ b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/SourceGenRegressionTests/Net60/Net60GeneratedContext.cs
@@ -0,0 +1,48 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+// Source files represent a source generated JsonSerializerContext as produced by the .NET 6 SDK.
+// Used to validate correctness of contexts generated by previous SDKs against the current System.Text.Json runtime components.
+// Unless absolutely necessary DO NOT MODIFY any of these files -- it would invalidate the purpose of the regression tests.
+
+using System.Collections.Generic;
+using System.Text.Json.Serialization;
+
+namespace System.Text.Json.Tests.SourceGenRegressionTests.Net60
+{
+ //[JsonSerializable(typeof(WeatherForecastWithPOCOs))]
+ //[JsonSerializable(typeof(ClassWithCustomConverter))]
+ public partial class Net60GeneratedContext : JsonSerializerContext { }
+
+ public class WeatherForecastWithPOCOs
+ {
+ public DateTimeOffset Date { get; set; }
+ public int TemperatureCelsius { get; set; }
+ public string? Summary { get; set; }
+ public string? SummaryField;
+ public List? DatesAvailable { get; set; }
+ public Dictionary? TemperatureRanges { get; set; }
+ public string[]? SummaryWords { get; set; }
+ }
+
+ public class HighLowTemps
+ {
+ public int High { get; set; }
+ public int Low { get; set; }
+ }
+
+ [JsonConverter(typeof(CustomConverter))]
+ public class ClassWithCustomConverter
+ {
+ public int Value { get; set; }
+
+ public class CustomConverter : JsonConverter
+ {
+ public override ClassWithCustomConverter? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
+ => new ClassWithCustomConverter { Value = reader.GetInt32() - 1 };
+
+ public override void Write(Utf8JsonWriter writer, ClassWithCustomConverter value, JsonSerializerOptions options)
+ => writer.WriteNumberValue(value.Value + 1);
+ }
+ }
+}
diff --git a/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/SourceGenRegressionTests/Net60/Net60GeneratedContext.g.cs b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/SourceGenRegressionTests/Net60/Net60GeneratedContext.g.cs
new file mode 100644
index 00000000000000..6b6bf15a8e5449
--- /dev/null
+++ b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/SourceGenRegressionTests/Net60/Net60GeneratedContext.g.cs
@@ -0,0 +1,69 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+// Source files represent a source generated JsonSerializerContext as produced by the .NET 6 SDK.
+// Used to validate correctness of contexts generated by previous SDKs against the current System.Text.Json runtime components.
+// Unless absolutely necessary DO NOT MODIFY any of these files -- it would invalidate the purpose of the regression tests.
+
+//
+#nullable enable
+
+// Suppress warnings about [Obsolete] member usage in generated code.
+#pragma warning disable CS0618
+
+namespace System.Text.Json.Tests.SourceGenRegressionTests.Net60
+{
+
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Text.Json.SourceGeneration", "6.0.6.21309")]
+ public partial class Net60GeneratedContext
+ {
+
+ private static global::System.Text.Json.JsonSerializerOptions s_defaultOptions { get; } = new global::System.Text.Json.JsonSerializerOptions()
+ {
+ DefaultIgnoreCondition = global::System.Text.Json.Serialization.JsonIgnoreCondition.Never,
+ IgnoreReadOnlyFields = false,
+ IgnoreReadOnlyProperties = false,
+ IncludeFields = false,
+ WriteIndented = false,
+ };
+
+ private static global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.Net60GeneratedContext? s_defaultContext;
+ public static global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.Net60GeneratedContext Default => s_defaultContext ??= new global::System.Text.Json.Tests.SourceGenRegressionTests.Net60.Net60GeneratedContext(new global::System.Text.Json.JsonSerializerOptions(s_defaultOptions));
+
+ protected override global::System.Text.Json.JsonSerializerOptions? GeneratedSerializerOptions { get; } = s_defaultOptions;
+
+ public Net60GeneratedContext() : base(null)
+ {
+ }
+
+ public Net60GeneratedContext(global::System.Text.Json.JsonSerializerOptions options) : base(options)
+ {
+ }
+
+ private global::System.Text.Json.Serialization.JsonConverter? GetRuntimeProvidedCustomConverter(global::System.Type type)
+ {
+ global::System.Collections.Generic.IList converters = Options.Converters;
+
+ for (int i = 0; i < converters.Count; i++)
+ {
+ global::System.Text.Json.Serialization.JsonConverter? converter = converters[i];
+
+ if (converter.CanConvert(type))
+ {
+ if (converter is global::System.Text.Json.Serialization.JsonConverterFactory factory)
+ {
+ converter = factory.CreateConverter(type, Options);
+ if (converter == null || converter is global::System.Text.Json.Serialization.JsonConverterFactory)
+ {
+ throw new global::System.InvalidOperationException(string.Format("The converter '{0}' cannot return null or a JsonConverterFactory instance.", factory.GetType()));
+ }
+ }
+
+ return converter;
+ }
+ }
+
+ return null;
+ }
+ }
+}
diff --git a/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/SourceGenRegressionTests/Net60RegressionTests.cs b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/SourceGenRegressionTests/Net60RegressionTests.cs
new file mode 100644
index 00000000000000..1d768ac3286601
--- /dev/null
+++ b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/SourceGenRegressionTests/Net60RegressionTests.cs
@@ -0,0 +1,162 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Text.Json.Serialization.Metadata;
+using System.Text.Json.Serialization.Tests;
+using System.Text.Json.Tests.SourceGenRegressionTests.Net60;
+using System.Threading.Tasks;
+using Xunit;
+using HighLowTemps = System.Text.Json.Tests.SourceGenRegressionTests.Net60.HighLowTemps;
+using WeatherForecastWithPOCOs = System.Text.Json.Tests.SourceGenRegressionTests.Net60.WeatherForecastWithPOCOs;
+
+namespace System.Text.Json.Tests.SourceGenRegressionTests
+{
+ public static class Net60RegressionTests
+ {
+ [Theory]
+ [MemberData(nameof(GetSupportedTypeRoundtripData))]
+ public static void SupportedTypeRoundtrip(JsonTypeInfo jsonTypeInfo, T value, string expectedJson)
+ {
+ string json = JsonSerializer.Serialize(value, jsonTypeInfo);
+ JsonTestHelper.AssertJsonEqual(expectedJson, json);
+
+ T deserializedValue = JsonSerializer.Deserialize(json, jsonTypeInfo);
+ json = JsonSerializer.Serialize(deserializedValue, jsonTypeInfo);
+ JsonTestHelper.AssertJsonEqual(expectedJson, json);
+ }
+
+ public static IEnumerable