Bug 4814 - Empty NumberFormatInfo.NumberGroupSeparator causes an Error
Summary: Empty NumberFormatInfo.NumberGroupSeparator causes an Error
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib ()
Version: 2.10.x
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2012-05-02 00:29 UTC by AlexK80
Modified: 2012-06-19 17:11 UTC (History)
4 users (show)

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:

Description AlexK80 2012-05-02 00:29:25 UTC

var nf = new NumberFormatInfo();
nf.NumberDecimalSeparator = ".";
nf.NumberGroupSeparator = ""; //this is the cause
decimal val = Decimal.Parse("1.5",nf); //throws this error:

System.IndexOutOfRangeException: Array index is out of range.
  at System.Decimal.stripStyles (System.String s, NumberStyles style, System.Globalization.NumberFormatInfo nfi, System.Int32& decPos, System.Boolean& isNegative, System.Boolean& expFlag, System.Int32& exp, Boolean throwex) 
  at System.Decimal.PerformParse (System.String s, NumberStyles style, IFormatProvider provider, System.Decimal& res, Boolean throwex)
  at System.Decimal.Parse (System.String s, NumberStyles style, IFormatProvider provider) 
  at System.Decimal.Parse (System.String s, IFormatProvider provider)

But MS implementation manages it well.
Comment 1 Adam Brengesjö 2012-06-13 16:01:47 UTC
Commit 782f7f9a7b from https://github.com/adbre/mono fixes this issue.

A pull request have been submitted and the fix will (hopefully) be merged into the mono/mono repo soon (https://github.com/mono/mono/pull/324).

While at it, I also observed that simlar errors would be thrown for other properties (not just NumberGroupSeparator).

Comment 2 Miguel de Icaza [MSFT] 2012-06-19 17:11:56 UTC
Thanks, the patch was applied.