Skip to content

Commit

Permalink
Support ICU on Windows Server 2019 (#72656)
Browse files Browse the repository at this point in the history
  • Loading branch information
tarekgh authored Jul 22, 2022
1 parent 768500c commit 7eaa6d1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public static partial class PlatformDetection
public static bool IsWindows8x => IsWindows && GetWindowsVersion() == 6 && (GetWindowsMinorVersion() == 2 || GetWindowsMinorVersion() == 3);
public static bool IsWindows8xOrLater => IsWindowsVersionOrLater(6, 2);
public static bool IsWindows10OrLater => IsWindowsVersionOrLater(10, 0);
public static bool IsWindowsServer2019 => IsWindows && IsNotWindowsNanoServer && GetWindowsVersion() == 10 && GetWindowsMinorVersion() == 0 && GetWindowsBuildVersion() == 17763;
public static bool IsWindowsNanoServer => IsWindows && (IsNotWindowsIoTCore && GetWindowsInstallationType().Equals("Nano Server", StringComparison.OrdinalIgnoreCase));
public static bool IsWindowsServerCore => IsWindows && GetWindowsInstallationType().Equals("Server Core", StringComparison.OrdinalIgnoreCase);
public static int WindowsVersion => IsWindows ? (int)GetWindowsVersion() : -1;
Expand Down Expand Up @@ -173,6 +174,7 @@ internal static Version GetWindowsVersionObject()

internal static uint GetWindowsVersion() => (uint)GetWindowsVersionObject().Major;
internal static uint GetWindowsMinorVersion() => (uint)GetWindowsVersionObject().Minor;
internal static uint GetWindowsBuildVersion() => (uint)GetWindowsVersionObject().Build;

internal static bool IsWindowsVersionOrLater(int major, int minor, int build = -1)
{
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/System.Globalization/tests/IcuTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace System.Globalization.Tests
public class IcuTests
{
private static bool IsIcuCompatiblePlatform => PlatformDetection.IsNotWindows ||
(PlatformDetection.IsWindows10Version1903OrGreater &&
((PlatformDetection.IsWindowsServer2019 || PlatformDetection.IsWindows10Version1903OrGreater) &&
// Server core doesn't have icu.dll on SysWOW64
!(PlatformDetection.IsWindowsServerCore && PlatformDetection.IsX86Process));

Expand Down
11 changes: 11 additions & 0 deletions src/native/libs/System.Globalization.Native/pal_icushim.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,17 @@ static int FindICULibs()
libicuuc = LoadLibraryExW(L"icu.dll", NULL, LOAD_LIBRARY_SEARCH_SYSTEM32);
if (libicuuc == NULL)
{
// On Windows Server 2019, the ICU library is installed as icuuc.dll and icuin.dll. Try to load these.
libicuuc = LoadLibraryExW(L"icuuc.dll", NULL, LOAD_LIBRARY_SEARCH_SYSTEM32);
if (libicuuc != NULL)
{
libicui18n = LoadLibraryExW(L"icuin.dll", NULL, LOAD_LIBRARY_SEARCH_SYSTEM32);
if (libicui18n != NULL)
{
return true;
}
}

return false;
}

Expand Down

0 comments on commit 7eaa6d1

Please sign in to comment.