From 4e8ed11efce04a8a2e6e1cb24e92bc62c2d394cd Mon Sep 17 00:00:00 2001 From: Sebastian Date: Thu, 19 Jan 2023 15:54:53 +0100 Subject: [PATCH] Safe copy. --- .../ContentWrapper/ContentFieldObject.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/ContentWrapper/ContentFieldObject.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/ContentWrapper/ContentFieldObject.cs index 576d3d7e0..7af6d31d9 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/ContentWrapper/ContentFieldObject.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/ContentWrapper/ContentFieldObject.cs @@ -148,16 +148,18 @@ public sealed class ContentFieldObject : ObjectInstance private void EnsurePropertiesInitialized() { - if (valueProperties == null) + if (valueProperties != null) { - valueProperties = new Dictionary(fieldData?.Count ?? 0); + return; + } + + valueProperties = new Dictionary(fieldData?.Count ?? 0, StringComparer.OrdinalIgnoreCase); - if (fieldData != null) + if (fieldData != null) + { + foreach (var (key, value) in fieldData) { - foreach (var (key, value) in fieldData) - { - valueProperties.Add(key, new ContentFieldProperty(this, value)); - } + valueProperties[key] = new ContentFieldProperty(this, value); } } }