Bug 59215 - Single.TryParse returns true for empty string when using Czech locale
Summary: Single.TryParse returns true for empty string when using Czech locale
Status: CONFIRMED
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib (show other bugs)
Version: 5.4 (2017-06)
Hardware: PC Mac OS
: --- normal
Target Milestone: Future Release
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-09-04 17:00 UTC by Matt Ward
Modified: 2017-09-04 21:09 UTC (History)
2 users (show)

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


Attachments
TestSingleConversionProject (7.40 KB, application/zip)
2017-09-04 17:00 UTC, Matt Ward
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 for Bug 59215 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
CONFIRMED

Description Matt Ward 2017-09-04 17:00:08 UTC
Created attachment 24560 [details]
TestSingleConversionProject

Mono version: 5.4.0.167 (2017-06/6b8abfeb7cc Thu Aug 17 18:17:27 EDT 2017)

The following code (also provided in the attached zip as a project) uses Single.TryParse to parse an empty string. When the machine's locale is set to Czech 'cs-CZ' the TryParse returns true. On Windows it returns false.

string culture = "cs-CZ";
Thread.CurrentThread.CurrentCulture = new CultureInfo (culture);

string text = "";
Single number;
bool result = Single.TryParse (text, out number);

// result should be false but it is true for 'cs-CZ' culture.
Console.WriteLine (result);
Comment 1 Marek Safar 2017-09-04 21:09:17 UTC
This is coming from referencesource which assumes that no culture has empty numeric symbols (e.g. NaN)