Bug 57496 - [Slovenian CultureInfo + others] .Parse throws exception when parsing negative values
Summary: [Slovenian CultureInfo + others] .Parse throws exception when parsing negativ...
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib ()
Version: unspecified
Hardware: PC All
: --- normal
Target Milestone: Future Release
Assignee: Marek Safar
Depends on:
Reported: 2017-06-14 17:03 UTC by Iztok Delfin
Modified: 2017-09-13 11:50 UTC (History)
4 users (show)

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

ParseTest xamarin.android solution (184.46 KB, application/x-zip-compressed)
2017-06-14 17:03 UTC, Iztok Delfin

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:

Description Iztok Delfin 2017-06-14 17:03:42 UTC
Created attachment 22889 [details]
ParseTest xamarin.android solution

For Slovenian CultureInfo and others (Urdu,Arabic,Pashto)
The following code throws an exception "Input string was not in a correct format." :

int.Parse("-1", NumberFormatInfo.GetInstance(cultureInfo)); 

Probably Duplicate of https://bugzilla.xamarin.com/show_bug.cgi?id=14185 as all the CultureInfos that throw an exception have a different negative sign value than the invariant and other, working cultureInfos.

See attached demo Xamarin.Android project for detailed info.
Comment 1 Jerdna 2017-08-09 10:37:45 UTC
We are also facing the same issue with Slovenian culture info.

Can you please change importance to highest? The problem is, we cannot upgrade Xamarin till this bug is resolved, because our app will become unstable. Also we dont want to use workarounds for ex. Convert.ToInt32 or similar.
Comment 2 Iztok Delfin 2017-08-09 12:26:00 UTC
I cannot do that as a user. Hopefully someone from the team will pick up the ticket soon and assign appropriate priority to it.
Comment 3 Marek Safar 2017-09-12 14:03:09 UTC
Console repro

using System;
using System.Globalization;

class MainClass
	public static void Main (string [] args)
		CultureInfo culture = null;
		for (int i = 1; i < 30000; i++) {
			try {
				try {
					culture = CultureInfo.GetCultureInfo (i);
				} catch {
					// non-existent LCIDs are passed over.

				int.Parse ("-1", NumberFormatInfo.GetInstance (culture));
				//Uncomment to see all the working ones. They all have \u002D number sign.
				//Console.WriteLine($"WORKING - LCID: {i} , Culture Info: {culture.DisplayName} , Negative sign: \\u{((int)culture.NumberFormat.NegativeSign[0]).ToString("X4")} , NumberNegativePattern: {culture.NumberFormat.NumberNegativePattern}");

			} catch (Exception ex) {
				Console.WriteLine ($"ERROR - LCID: {i} , Culture Info: {culture.DisplayName} , Negative sign: \\u{((int)culture.NumberFormat.NegativeSign [0]).ToString ("X4")} , NumberNegativePattern: {culture.NumberFormat.NumberNegativePattern} , Exception message: {ex.Message}");
Comment 4 Marek Safar 2017-09-13 11:50:33 UTC
Fixed in master/2017-08/2017-06 branches