diff --git a/mcs/class/corlib/System/TimeZoneInfo.WinRT.cs b/mcs/class/corlib/System/TimeZoneInfo.WinRT.cs index f4a7ca7bbb46..4b5cff7f486f 100755 --- a/mcs/class/corlib/System/TimeZoneInfo.WinRT.cs +++ b/mcs/class/corlib/System/TimeZoneInfo.WinRT.cs @@ -359,6 +359,17 @@ internal static List GetSystemTimeZonesWinRTFallback () // EnumDynamicTimeZoneInformation() might not be available. } + // If we are in this function we know that TimeZoneKey is null and need to use the fallback + // Adding Local here will cause a stack overflow + if (result.Count == 0) + { + var l = GetLocalTimeZoneInfoWinRTFallback(); + if (Interlocked.CompareExchange (ref local, l, null) != null) + l = local; + + result.Add(l); + } + return result; } } diff --git a/mcs/class/corlib/System/TimeZoneInfo.cs b/mcs/class/corlib/System/TimeZoneInfo.cs index b84efd87afad..7afdbd857de2 100644 --- a/mcs/class/corlib/System/TimeZoneInfo.cs +++ b/mcs/class/corlib/System/TimeZoneInfo.cs @@ -787,10 +787,6 @@ public static ReadOnlyCollection GetSystemTimeZones () if (systemTimeZones == null) { var tz = new List (); GetSystemTimeZonesCore (tz); - // Don't want to return an empty list if we can help it - // but we don't want to stack overflow via a CreateLocal loop - if (tz.Count == 0 && local != null) - tz.Add(Local); Interlocked.CompareExchange (ref systemTimeZones, new ReadOnlyCollection (tz), null); }