[corlib] First specific culture returned by enumerator was not fully initialized...
authorMarek Safar <marek.safar@gmail.com>
Mon, 13 Apr 2015 17:16:29 +0000 (19:16 +0200)
committerMarek Safar <marek.safar@gmail.com>
Mon, 13 Apr 2015 17:16:29 +0000 (19:16 +0200)
mcs/class/corlib/System.Globalization/CultureInfo.cs
mcs/class/corlib/Test/System.Globalization/CultureInfoTest.cs

index a092bc05a6e819bbdf270d2418c36e6bc6332f97..b806082b188853ad5e30e10dfbde8b3e9a9c01e3 100644 (file)
@@ -427,11 +427,12 @@ namespace System.Globalization
                        // The runtime returns a NULL in the first position of the array when
                        // 'neutral' is true. We fill it in with a clone of InvariantCulture
                        // since it must not be read-only
+                       int i = 0;
                        if (neutral && infos.Length > 0 && infos [0] == null) {
-                               infos [0] = (CultureInfo) InvariantCulture.Clone ();
+                               infos [i++] = (CultureInfo) InvariantCulture.Clone ();
                        }
 
-                       for (int i = 1; i < infos.Length; ++i) {
+                       for (; i < infos.Length; ++i) {
                                var ci = infos [i];
                                var ti = ci.GetTextInfoData ();
                                infos [i].m_cultureData = CultureData.GetCultureData (ci.m_name, false, ci.datetime_index, ci.CalendarType, ci.number_index, ci.iso2lang,
index 3b7438453719cdaa66c66564ec60c24fcc90a6e2..48a8e76b63d2e9f318fa91ed934f417b125a3c75 100644 (file)
@@ -225,6 +225,15 @@ namespace MonoTests.System.Globalization
                        Assert.Fail ("InvariantCulture not found in the array from GetCultures()");
                }
 
+               [Test]
+               public void GetAllCultures_Specific ()
+               {
+                       CultureInfo [] infos = CultureInfo.GetCultures (CultureTypes.SpecificCultures);
+                       foreach (CultureInfo ci in infos) {
+                               Assert.IsNotNull (ci.DateTimeFormat);
+                       }
+               }
+
                [Test]
 #if !NET_4_0
                [ExpectedException (typeof (NotSupportedException))]