Bug 31398 - Cultures zh-Hans and zh-CHS are equal when they should not be
Summary: Cultures zh-Hans and zh-CHS are equal when they should not be
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib ()
Version: unspecified
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2015-06-26 06:20 UTC by Adam Hartley [MSFT]
Modified: 2015-06-26 20:22 UTC (History)
7 users (show)

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


Attachments
Sample code (470 bytes, application/octet-stream)
2015-06-26 06:20 UTC, Adam Hartley [MSFT]
Details


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 Adam Hartley [MSFT] 2015-06-26 06:20:47 UTC
Created attachment 11748 [details]
Sample code

## Overview

In Xamarin.Mac, zh-Hans and zh-CHS are treated as equal, whereas in .NET on Windows this is not the case.

## Steps to reproduce

1. Download attached .cs file which provides example code.
2. Compile and run.

## Expected result

No exception.

## Actual result

"An item with the same key has already been added" exception due to zh-Hans and zh-CHS being equal when they should not be.

## Notes

If you run the resulting exe on Windows it works without throwing an exception.
Comment 2 Chris Hamons 2015-06-26 09:51:32 UTC
Xamarin.Mac is the Mac bindings for writing GUI applications. In the example above, there is no GUI needed to reproduce the issue. I'm moving to the ClassLib section.
Comment 3 Marek Safar 2015-06-26 10:31:24 UTC
Fixed in master and Mono 4.2
Comment 4 Dan Smith 2015-06-26 20:22:52 UTC
Thanks for attempting to fix this Marek!

The fix (c67cb40) you provided still doesn't quite match the documentation & the MS implementation.  

Mono Docs: http://developer.xamarin.com/api/member/System.Globalization.CultureInfo.Equals(System.Object)/

"Two CultureInfo objects are considered equal if their CultureInfo.Name and CultureInfo.CompareInfo properties are equal."

The implementation you provided checks the CultureInfo.Name, but not the CultureInfo.CompareInfo property.  (It still checks the LCID)