[corlib] Rename private method in TimeZoneInfo to avoid conflict with public one...
authorAlexander Köplinger <alex.koeplinger@outlook.com>
Thu, 20 Aug 2015 02:40:58 +0000 (04:40 +0200)
committerAlexander Köplinger <alex.koeplinger@outlook.com>
Thu, 20 Aug 2015 02:41:41 +0000 (04:41 +0200)
A private overload of the public GetSystemTimeZones() method was added in 4dc9a90d7f23f0f5a7a31f7357ea782408d3d9b5.
This broke code that tried to access that method via reflection and expected that there be only one.

Fixing this by renaming the private method to GetSystemTimeZonesCore (which is also more aligned with FindSystemTimeZoneByIdCore).

mcs/class/corlib/System/TimeZoneInfo.Android.cs
mcs/class/corlib/System/TimeZoneInfo.MonoTouch.cs
mcs/class/corlib/System/TimeZoneInfo.cs
mcs/class/corlib/Test/System/TimeZoneInfoTest.cs

index 8c661389b351873fafe0da6464dda2077e69bc94..45475e910b5caebc26b28d8ce92b16e5b026b2ef 100644 (file)
@@ -266,7 +266,7 @@ namespace System {
                        return timeZoneInfo;
                }
 
-               static void GetSystemTimeZones (List<TimeZoneInfo> systemTimeZones)
+               static void GetSystemTimeZonesCore (List<TimeZoneInfo> systemTimeZones)
                {
                        foreach (string id in AndroidTimeZones.GetAvailableIds ()) {
                                var tz = AndroidTimeZones.GetTimeZone (id, id);
index 3db0c0ab646d33141b3a373c49c7f557b43817d7..ba161b3f2e2f37856954f3f1be325ab10f286ee3 100644 (file)
@@ -58,7 +58,7 @@ namespace System {
                        }
                }
 
-               static void GetSystemTimeZones (List<TimeZoneInfo> systemTimeZones)
+               static void GetSystemTimeZonesCore (List<TimeZoneInfo> systemTimeZones)
                {
                        foreach (string name in GetMonoTouchNames ()) {
                                using (Stream stream = GetMonoTouchData (name, false)) {
index 3f0a069fa06f955fe23655bbd3e22ec0f21559b5..816694e57bc71a7a5edda6df5c6c302fb4ea234b 100644 (file)
@@ -135,7 +135,7 @@ namespace System
 #endif
                }
 
-               static void GetSystemTimeZones (List<TimeZoneInfo> systemTimeZones)
+               static void GetSystemTimeZonesCore (List<TimeZoneInfo> systemTimeZones)
                {
 #if !MOBILE_STATIC
                        if (TimeZoneKey != null) {
@@ -651,7 +651,7 @@ namespace System
                {
                        if (systemTimeZones == null) {
                                var tz = new List<TimeZoneInfo> ();
-                               GetSystemTimeZones (tz);
+                               GetSystemTimeZonesCore (tz);
                                Interlocked.CompareExchange (ref systemTimeZones, new ReadOnlyCollection<TimeZoneInfo> (tz), null);
                        }
 
index 003cea8ddfe9d5348b3e2a36ebf1f543b3f6c2dc..844f7505fab070284ebcb38aaf48b7f1107dc844 100644 (file)
@@ -690,6 +690,15 @@ namespace MonoTests.System
                                }
                                Assert.Fail ("Europe/Brussels not found in SystemTZ");
                        }
+
+                       [Test]
+                       public void ReflectionReturnsTheCorrectMethod ()
+                       {
+                               var method = (MethodInfo) typeof (TimeZoneInfo).GetMember ("GetSystemTimeZones", MemberTypes.Method, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)[0];
+
+                               var timeZones = (global::System.Collections.ObjectModel.ReadOnlyCollection<TimeZoneInfo>) method.Invoke (null, null);
+                               Assert.IsNotEmpty (timeZones);
+                       }
                }
                
                [TestFixture]