Bug 36786 - Dictionary constructed with StringComparer.OrdinalIgnoreCase malfunctions if culture is changed after adding values
Summary: Dictionary constructed with StringComparer.OrdinalIgnoreCase malfunctions if ...
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib ()
Version: 4.2.0 (C6)
Hardware: Other Linux
: --- normal
Target Milestone: Untriaged
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2015-12-09 18:18 UTC by Tauhka
Modified: 2015-12-14 12:31 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

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