Bug 36786

Summary: Dictionary constructed with StringComparer.OrdinalIgnoreCase malfunctions if culture is changed after adding values
Product: [Mono] Class Libraries Reporter: Tauhka <tauhka>
Component: mscorlibAssignee: Marek Safar <masafa>
Status: RESOLVED FIXED    
Severity: normal CC: masafa, mono-bugs+mono
Priority: ---    
Version: 4.2.0 (C6)   
Target Milestone: Untriaged   
Hardware: Other   
OS: Linux   
Tags: Is this bug a regression?: ---
Last known good build:

Description Tauhka 2015-12-09 18:18:35 UTC
A dictionary initialized with System.StringComparer.OrdinalIgnoreCase no longer finds values if culture has been changed from what it was at the time of inserting. This happens at least with "en-us" and "fi" cultures as in "fi" culture "w" and "v" are treated as same when sorting, most likely causing malfunction in GetHashCode or comparison. Dictionary works fine if culture is not changed. Tested on Raspberry Pi 2 + Arch Linux + Mono 4.2.1.201.

Following sample code prints out "ERROR" when run:

System.Threading.Thread.CurrentThread.CurrentCulture=new System.Globalization.CultureInfo("en-us");
var test=new System.Collections.Generic.Dictionary<string, int>(System.StringComparer.OrdinalIgnoreCase);
test.Add("w", 0);
System.Threading.Thread.CurrentThread.CurrentCulture=new System.Globalization.CultureInfo("fi");
if(!test.ContainsKey("w")) System.Console.WriteLine("ERROR");
Comment 1 Marek Safar 2015-12-14 12:31:30 UTC
Fixed in master