Skip to content

Commit d9a4a64

Browse files
[release/5.0] Handle non-ASCII strings in GetNonRandomizedHashCodeOrdinalIgnoreCase (#45062)
* Backports #44681 fix to 5.0 * Backports #44695 fix to 5.0
1 parent 90b8f7e commit d9a4a64

File tree

4 files changed

+229
-107
lines changed

4 files changed

+229
-107
lines changed

src/libraries/System.Collections/tests/Generic/Dictionary/Dictionary.Tests.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,22 @@ public void CantAcceptDuplicateKeysFromSourceDictionary()
337337
AssertExtensions.Throws<ArgumentException>(null, () => new Dictionary<string, int>(source, StringComparer.OrdinalIgnoreCase));
338338
}
339339

340+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))]
341+
// https://github.com/dotnet/runtime/issues/44681
342+
public void DictionaryOrdinalIgnoreCaseCyrillicKeys()
343+
{
344+
const string Lower = "абвгдеёжзийклмнопрстуфхцчшщьыъэюя";
345+
const string Higher = "АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЬЫЪЭЮЯ";
346+
347+
var dictionary = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);
348+
349+
for (int i = 0; i < Lower.Length; i++)
350+
{
351+
dictionary[Lower[i].ToString()] = i;
352+
Assert.Equal(i, dictionary[Higher[i].ToString()]);
353+
}
354+
}
355+
340356
public static IEnumerable<object[]> CopyConstructorStringComparerData
341357
{
342358
get

0 commit comments

Comments
 (0)