From 3be78eda9a4df8151b175d3b4ee6f3793c931fea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yakup=20=C3=96ZDEN?= Date: Mon, 13 Aug 2018 11:59:28 +0300 Subject: [PATCH 1/2] =?UTF-8?q?#Bug=20which=20occurs=20in=20tr-TR=20langua?= =?UTF-8?q?ge=20environment=20while=20comparing=20property=20names=20after?= =?UTF-8?q?=20converting=20toLower,=20(i.e=20lower=20of=20Id=20=20->=20?= =?UTF-8?q?=C4=B1d=20not=20id=20in=20Turkish)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Slapper.AutoMapper.InternalHelpers.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Slapper.AutoMapper/Slapper.AutoMapper.InternalHelpers.cs b/Slapper.AutoMapper/Slapper.AutoMapper.InternalHelpers.cs index 55a6a5c..4bc7f65 100644 --- a/Slapper.AutoMapper/Slapper.AutoMapper.InternalHelpers.cs +++ b/Slapper.AutoMapper/Slapper.AutoMapper.InternalHelpers.cs @@ -33,6 +33,7 @@ dynamic data into static types and populate complex nested child objects. using System; using System.Collections; using System.Collections.Generic; +using System.Globalization; using System.Linq; using System.Reflection; using System.Runtime.Remoting.Messaging; @@ -49,6 +50,8 @@ public static partial class AutoMapper /// internal static class InternalHelpers { + + private static CultureInfo cultureInfo = CultureInfo.InvariantCulture; /// /// Combine several hashcodes into a single new one. This implementation was grabbed from http://stackoverflow.com/a/34229665 where it is introduced /// as MS implementation of GetHashCode() for strings. @@ -202,7 +205,7 @@ public static Cache.TypeMap CreateTypeMap(Type type) { identifiers.Add(memberName); } - else if (conventionIdentifiers.Exists(x => x.ToLower() == memberName.ToLower())) + else if (conventionIdentifiers.Exists(x => x.ToLower(cultureInfo) == memberName.ToLower(cultureInfo))) { identifiers.Add(memberName); } @@ -217,7 +220,7 @@ public static Cache.TypeMap CreateTypeMap(Type type) { identifiers.Add(memberName); } - else if (conventionIdentifiers.Exists(x => x.ToLower() == memberName.ToLower())) + else if (conventionIdentifiers.Exists(x => x.ToLower(cultureInfo) == memberName.ToLower(cultureInfo))) { identifiers.Add(memberName); } @@ -486,7 +489,7 @@ internal static object Map(IDictionary dictionary, object instan foreach (var fieldOrProperty in fieldsAndProperties) { - var memberName = fieldOrProperty.Key.ToLower(); + var memberName = fieldOrProperty.Key.ToLower(cultureInfo); var member = fieldOrProperty.Value; @@ -505,7 +508,7 @@ internal static object Map(IDictionary dictionary, object instan if (memberType.IsClass || memberType.IsInterface) { // Try to find any keys that start with the current member name - var nestedDictionary = dictionary.Where(x => x.Key.ToLower().StartsWith(memberName + "_")).ToList(); + var nestedDictionary = dictionary.Where(x => x.Key.ToLower(cultureInfo).StartsWith(memberName + "_")).ToList(); // If there weren't any keys if (!nestedDictionary.Any()) @@ -524,7 +527,7 @@ internal static object Map(IDictionary dictionary, object instan continue; } var regex = new Regex(Regex.Escape(memberName + "_")); - var newDictionary = nestedDictionary.ToDictionary(pair => regex.Replace(pair.Key.ToLower(), string.Empty, 1), + var newDictionary = nestedDictionary.ToDictionary(pair => regex.Replace(pair.Key.ToLower(cultureInfo), string.Empty, 1), pair => pair.Value, StringComparer.OrdinalIgnoreCase); // Try to get the value of the complex member. If the member From cdd92ea6c71b0fcd50087088d3afd22bd137c424 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yakup=20=C3=96ZDEN?= Date: Mon, 13 Aug 2018 13:16:31 +0300 Subject: [PATCH 2/2] Nunit Test Adapter Updated --- Slapper.AutoMapper.Tests/Slapper.Tests.csproj | 3 +++ Slapper.AutoMapper.Tests/packages.config | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Slapper.AutoMapper.Tests/Slapper.Tests.csproj b/Slapper.AutoMapper.Tests/Slapper.Tests.csproj index 78efd18..ebf2d37 100644 --- a/Slapper.AutoMapper.Tests/Slapper.Tests.csproj +++ b/Slapper.AutoMapper.Tests/Slapper.Tests.csproj @@ -80,6 +80,9 @@ + + +