V14: Migrate nucache to use System.Text.Json (#15685)

* Create system text serializer

* Assign property names with system text

* Use the new serializer

* Impement AutoInterningStringConverter with System.Text.Json

* Implement TextAutoInterningStringKeyCaseInsensitiveDictionaryConverter

* Make CaseInsensitiveDictionaryConverter

* Force datetimes to be read as UTC

* Remove usages of Newtonsoft.Json

* Remove text prefixes

* Remove unused Newtonsoft converter

* Remove more newtonsoft

* Remove duplicate implementation

* Rmove usage of missing class in tests

* Ignore null values

* Fix tests

* Remove Newtonstoft reference from NuCache

---------

Co-authored-by: Elitsa <elm@umbraco.dk>
This commit is contained in:
Mole
2024-02-14 12:10:45 +01:00
committed by GitHub
parent 4f04669dce
commit 2dcdff5392
13 changed files with 167 additions and 248 deletions

View File

@@ -1,6 +1,6 @@
using System.ComponentModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using System.Text.Json.Serialization;
using Umbraco.Cms.Infrastructure.Serialization;
namespace Umbraco.Cms.Infrastructure.PublishedCache.DataSource;
@@ -14,7 +14,7 @@ public class PropertyData
[DataMember(Order = 0)]
[JsonConverter(typeof(AutoInterningStringConverter))]
[DefaultValue("")]
[JsonProperty(DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate, PropertyName = "c")]
[JsonPropertyName("c")]
public string? Culture
{
get => _culture;
@@ -26,7 +26,7 @@ public class PropertyData
[DataMember(Order = 1)]
[JsonConverter(typeof(AutoInterningStringConverter))]
[DefaultValue("")]
[JsonProperty(DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate, PropertyName = "s")]
[JsonPropertyName("s")]
public string? Segment
{
get => _segment;
@@ -36,26 +36,25 @@ public class PropertyData
}
[DataMember(Order = 2)]
[JsonProperty("v")]
[JsonPropertyName("v")]
public object? Value { get; set; }
// Legacy properties used to deserialize existing nucache db entries
[IgnoreDataMember]
[JsonProperty("culture")]
private string LegacyCulture
{
set => Culture = value;
}
[IgnoreDataMember]
[JsonProperty("seg")]
[JsonPropertyName("seg")]
private string LegacySegment
{
set => Segment = value;
}
[IgnoreDataMember]
[JsonProperty("val")]
[JsonPropertyName("val")]
private object LegacyValue
{
set => Value = value;