From 44a62f3703b0f55dec5e34a6aeea5c5a72ba5859 Mon Sep 17 00:00:00 2001 From: Eirik Tsarpalis Date: Wed, 23 Mar 2022 22:41:30 +0000 Subject: [PATCH 1/2] Ensure serializer reflection-dependency sentinel is accurate --- .../Json/Serialization/JsonSerializerOptions.Converters.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.Converters.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.Converters.cs index 77b5d7071f7120..2563794dcc55c2 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.Converters.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.Converters.cs @@ -10,6 +10,7 @@ using System.Text.Json.Serialization; using System.Text.Json.Serialization.Converters; using System.Text.Json.Serialization.Metadata; +using System.Threading; namespace System.Text.Json { @@ -30,10 +31,10 @@ public sealed partial class JsonSerializerOptions [RequiresUnreferencedCode(JsonSerializer.SerializationUnreferencedCodeMessage)] private void RootBuiltInConverters() { - if (s_defaultSimpleConverters is null) + if (Volatile.Read(ref s_defaultFactoryConverters) is null) { s_defaultSimpleConverters = GetDefaultSimpleConverters(); - s_defaultFactoryConverters = new JsonConverter[] + Volatile.Write(ref s_defaultFactoryConverters, new JsonConverter[] { // Check for disallowed types. new UnsupportedTypeConverterFactory(), @@ -48,7 +49,7 @@ private void RootBuiltInConverters() new IEnumerableConverterFactory(), // Object should always be last since it converts any type. new ObjectConverterFactory() - }; + }); } } From 7ffd968b5da858f588b93c80e7677b9f9c5ce706 Mon Sep 17 00:00:00 2001 From: Eirik Tsarpalis Date: Fri, 25 Mar 2022 11:36:51 +0000 Subject: [PATCH 2/2] update servicing version --- src/libraries/System.Text.Json/src/System.Text.Json.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Text.Json/src/System.Text.Json.csproj b/src/libraries/System.Text.Json/src/System.Text.Json.csproj index ee5d0b2c6e97d5..3ee7607c9b11bc 100644 --- a/src/libraries/System.Text.Json/src/System.Text.Json.csproj +++ b/src/libraries/System.Text.Json/src/System.Text.Json.csproj @@ -10,7 +10,7 @@ true true true - 3 + 4 Provides high-performance and low-allocating types that serialize objects to JavaScript Object Notation (JSON) text and deserialize JSON text to objects, with UTF-8 support built-in. Also provides types to read and write JSON text encoded as UTF-8, and to create an in-memory document object model (DOM), that is read-only, for random access of the JSON elements within a structured view of the data. Commonly Used Types: