提交 66372b91 编写于 作者: A Alexander Köplinger

[corlib] Rename private method in TimeZoneInfo to avoid conflict with public one via reflection

A private overload of the public GetSystemTimeZones() method was added in 4dc9a90d.
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).
上级 85c134c4
......@@ -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);
......
......@@ -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)) {
......
......@@ -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);
}
......
......@@ -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]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册