Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support ICU on Windows Server 2019 #72656

Merged
merged 2 commits into from
Jul 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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