From b98c1ed523b326597b0fb5f6bbf9a454648bfa31 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 6 May 2019 15:14:16 +0200 Subject: [PATCH] Casing fix. --- .../Contents/NamedContentData.cs | 4 ++-- .../Json/Newtonsoft/ConverterContractResolver.cs | 11 ++--------- .../Json/Newtonsoft/ConverterContractResolverTests.cs | 11 +++++++++++ 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/Squidex.Domain.Apps.Core.Model/Contents/NamedContentData.cs b/src/Squidex.Domain.Apps.Core.Model/Contents/NamedContentData.cs index fd298d5ef..d6afcd95f 100644 --- a/src/Squidex.Domain.Apps.Core.Model/Contents/NamedContentData.cs +++ b/src/Squidex.Domain.Apps.Core.Model/Contents/NamedContentData.cs @@ -13,12 +13,12 @@ namespace Squidex.Domain.Apps.Core.Contents public sealed class NamedContentData : ContentData, IEquatable { public NamedContentData() - : base(StringComparer.OrdinalIgnoreCase) + : base(StringComparer.Ordinal) { } public NamedContentData(int capacity) - : base(capacity, StringComparer.OrdinalIgnoreCase) + : base(capacity, StringComparer.Ordinal) { } diff --git a/src/Squidex.Infrastructure/Json/Newtonsoft/ConverterContractResolver.cs b/src/Squidex.Infrastructure/Json/Newtonsoft/ConverterContractResolver.cs index 53b203da3..a42d030f5 100644 --- a/src/Squidex.Infrastructure/Json/Newtonsoft/ConverterContractResolver.cs +++ b/src/Squidex.Infrastructure/Json/Newtonsoft/ConverterContractResolver.cs @@ -20,6 +20,8 @@ namespace Squidex.Infrastructure.Json.Newtonsoft public ConverterContractResolver(params JsonConverter[] converters) { + NamingStrategy = new CamelCaseNamingStrategy(false, true); + this.converters = converters; foreach (var converter in converters) @@ -34,15 +36,6 @@ namespace Squidex.Infrastructure.Json.Newtonsoft } } - protected override JsonDictionaryContract CreateDictionaryContract(Type objectType) - { - var contract = base.CreateDictionaryContract(objectType); - - contract.DictionaryKeyResolver = propertyName => propertyName; - - return contract; - } - protected override JsonConverter ResolveContractConverter(Type objectType) { var result = base.ResolveContractConverter(objectType); diff --git a/tests/Squidex.Infrastructure.Tests/Json/Newtonsoft/ConverterContractResolverTests.cs b/tests/Squidex.Infrastructure.Tests/Json/Newtonsoft/ConverterContractResolverTests.cs index aee6e6966..a3416165d 100644 --- a/tests/Squidex.Infrastructure.Tests/Json/Newtonsoft/ConverterContractResolverTests.cs +++ b/tests/Squidex.Infrastructure.Tests/Json/Newtonsoft/ConverterContractResolverTests.cs @@ -6,6 +6,7 @@ // ========================================================================== using System; +using System.Collections.Generic; using Newtonsoft.Json; using NodaTime; using Squidex.Infrastructure.TestHelpers; @@ -81,5 +82,15 @@ namespace Squidex.Infrastructure.Json.Newtonsoft Assert.Equal(value, serialized); } + + [Fact] + public void Should_serialize_and_deserialize_dictionary() + { + var value = new Dictionary { ["Description"] = "value" }; + + var serialized = value.SerializeAndDeserialize(); + + Assert.Equal(value, serialized); + } } }