Merge branch 'v8/dev' into v8/contrib

This commit is contained in:
Sebastiaan Janssen
2021-08-31 17:29:24 +02:00
5 changed files with 50 additions and 2 deletions

View File

@@ -7,7 +7,7 @@ using Newtonsoft.Json.Converters;
namespace Umbraco.Core.Serialization
{
/// <summary>
/// When applied to a dictionary with a string key, will ensure the deserialized string keys are interned
/// When applied to a dictionary with a string key, will ensure the deserialized string keys are interned
/// </summary>
/// <typeparam name="TValue"></typeparam>
/// <remarks>
@@ -26,7 +26,7 @@ namespace Umbraco.Core.Serialization
{
if (reader.TokenType == JsonToken.StartObject)
{
var dictionary = new Dictionary<string, TValue>();
var dictionary = Create(objectType);
while (reader.Read())
{
switch (reader.TokenType)

View File

@@ -608,6 +608,12 @@
return null;
}
// the Settings model has been changed to a new Element Type.
// we need to update the settingsData with the new Content Type key
if (settingsData.contentTypeKey !== settingsScaffold.contentTypeKey) {
settingsData.contentTypeKey = settingsScaffold.contentTypeKey;
}
blockObject.settingsData = settingsData;
// make basics from scaffold

View File

@@ -17,11 +17,13 @@ namespace Umbraco.Web.PublishedCache.NuCache.DataSource
[DataMember(Order = 0)]
[JsonProperty("pd")]
[JsonConverter(typeof(AutoInterningStringKeyCaseInsensitiveDictionaryConverter<PropertyData[]>))]
[MessagePackFormatter(typeof(MessagePackAutoInterningStringKeyCaseInsensitiveDictionaryFormatter<PropertyData[]>))]
public Dictionary<string, PropertyData[]> PropertyData { get; set; }
[DataMember(Order = 1)]
[JsonProperty("cd")]
[JsonConverter(typeof(AutoInterningStringKeyCaseInsensitiveDictionaryConverter<CultureVariation>))]
[MessagePackFormatter(typeof(MessagePackAutoInterningStringKeyCaseInsensitiveDictionaryFormatter<CultureVariation>))]
public Dictionary<string, CultureVariation> CultureData { get; set; }
[DataMember(Order = 2)]

View File

@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using MessagePack;
using MessagePack.Formatters;
namespace Umbraco.Web.PublishedCache.NuCache.DataSource
{
/// <summary>
/// A messagepack formatter (deserializer) for a string key dictionary that uses OrdinalIgnoreCase for the key string comparison
/// </summary>
/// <typeparam name="TValue"></typeparam>
public sealed class MessagePackAutoInterningStringKeyCaseInsensitiveDictionaryFormatter<TValue> : DictionaryFormatterBase<string, TValue, Dictionary<string, TValue>, Dictionary<string, TValue>.Enumerator, Dictionary<string, TValue>>
{
protected override void Add(Dictionary<string, TValue> collection, int index, string key, TValue value, MessagePackSerializerOptions options)
{
string.Intern(key);
collection.Add(key, value);
}
protected override Dictionary<string, TValue> Complete(Dictionary<string, TValue> intermediateCollection)
{
return intermediateCollection;
}
protected override Dictionary<string, TValue>.Enumerator GetSourceEnumerator(Dictionary<string, TValue> source)
{
return source.GetEnumerator();
}
protected override Dictionary<string, TValue> Create(int count, MessagePackSerializerOptions options)
{
return new Dictionary<string, TValue>(count, StringComparer.OrdinalIgnoreCase);
}
}
}

View File

@@ -297,6 +297,7 @@
<Compile Include="PublishedCache\NuCache\DataSource\JsonContentNestedDataSerializer.cs" />
<Compile Include="PublishedCache\NuCache\DataSource\JsonContentNestedDataSerializerFactory.cs" />
<Compile Include="PublishedCache\NuCache\DataSource\LazyCompressedString.cs" />
<Compile Include="PublishedCache\NuCache\DataSource\MessagePackAutoInterningStringKeyCaseInsensitiveDictionaryFormatter.cs" />
<Compile Include="PublishedCache\NuCache\DataSource\MsgPackContentNestedDataSerializer.cs" />
<Compile Include="PropertyEditors\Validation\ComplexEditorElementTypeValidationResult.cs" />
<Compile Include="PropertyEditors\Validation\ComplexEditorPropertyTypeValidationResult.cs" />