From 9f4d6fc5f4363836a58f6128eb7e60bb9084ef80 Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Sun, 24 Dec 2023 13:55:31 -0800 Subject: [PATCH 1/2] Ensure that ICU is loaded in tests before checking its version Fixes #96279 --- .../Common/tests/TestUtilities/System/PlatformDetection.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs index ac7d5e5a3ee6d8..84e92e63ac145b 100644 --- a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs +++ b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs @@ -415,6 +415,13 @@ public static bool IsSubstAvailable private static Version GetICUVersion() { + try + { + // Ensure that ICU has been loaded + GC.KeepAlive(System.Globalization.CultureInfo.InstalledUICulture); + } + catch { } + int version = 0; try { From 263be3bcc9d22031a51bcc2264bc4c2712b9b3aa Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Sun, 24 Dec 2023 14:23:32 -0800 Subject: [PATCH 2/2] FB --- .../tests/TestUtilities/System/PlatformDetection.cs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs index 84e92e63ac145b..f3a8aae9b38fd6 100644 --- a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs +++ b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs @@ -415,13 +415,6 @@ public static bool IsSubstAvailable private static Version GetICUVersion() { - try - { - // Ensure that ICU has been loaded - GC.KeepAlive(System.Globalization.CultureInfo.InstalledUICulture); - } - catch { } - int version = 0; try { @@ -431,6 +424,9 @@ private static Version GetICUVersion() MethodInfo methodInfo = interopGlobalization.GetMethod("GetICUVersion", BindingFlags.NonPublic | BindingFlags.Static); if (methodInfo != null) { + // Ensure that ICU has been loaded + GC.KeepAlive(System.Globalization.CultureInfo.InstalledUICulture); + version = (int)methodInfo.Invoke(null, null); } }