Skip to content

Commit d099f07

Browse files
committed
Merge in 'release/7.0' changes
2 parents bebb595 + 0cee4aa commit d099f07

File tree

4 files changed

+78
-1
lines changed

4 files changed

+78
-1
lines changed

src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Unix.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public static partial class PlatformDetection
1414
// do it in a way that failures don't cascade.
1515
//
1616

17-
private static bool IsLinux => RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
17+
public static bool IsLinux => RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
1818
public static bool IsOpenSUSE => IsDistroAndVersion("opensuse");
1919
public static bool IsUbuntu => IsDistroAndVersion("ubuntu");
2020
public static bool IsDebian => IsDistroAndVersion("debian");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
4+
<TestRuntime>true</TestRuntime>
5+
<IncludeRemoteExecutor>true</IncludeRemoteExecutor>
6+
</PropertyGroup>
7+
<ItemGroup>
8+
<Compile Include="IcuAppLocal.cs" />
9+
</ItemGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Microsoft.ICU.ICU4C.Runtime" Version="68.2.0.9" />
13+
14+
<!--
15+
We define this switch dynamically during the runtime using RemoteExecutor.
16+
The reason is, if we enable ICU app-local here, this test will compile and run
17+
on all supported OSs even the ICU NuGet package not have native bits support such OSs.
18+
Note, it doesn't matter if we have test case conditioned to not run on such OSs, because
19+
the test has to start running first before filtering the test cases and the globalization
20+
code will run and fail fast at that time.
21+
22+
<RuntimeHostConfigurationOption Include="System.Globalization.AppLocalIcu" Value="68.2.0.9" />
23+
-->
24+
</ItemGroup>
25+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using Microsoft.DotNet.RemoteExecutor;
5+
using System.Diagnostics;
6+
using System.Reflection;
7+
using Xunit;
8+
9+
namespace System.Globalization.Tests
10+
{
11+
public class IcuAppLocalTests
12+
{
13+
private static bool SupportsIcuPackageDownload => RemoteExecutor.IsSupported &&
14+
((PlatformDetection.IsWindows && !PlatformDetection.IsArmProcess) ||
15+
(PlatformDetection.IsLinux && (PlatformDetection.IsX64Process || PlatformDetection.IsArm64Process) &&
16+
!PlatformDetection.IsAlpine && !PlatformDetection.IsLinuxBionic));
17+
18+
19+
[ConditionalFact(nameof(SupportsIcuPackageDownload))]
20+
public void TestIcuAppLocal()
21+
{
22+
// We define this switch dynamically during the runtime using RemoteExecutor.
23+
// The reason is, if we enable ICU app-local here, this test will compile and run
24+
// on all supported OSs even the ICU NuGet package not have native bits support such OSs.
25+
// Note, it doesn't matter if we have test case conditioned to not run on such OSs, because
26+
// the test has to start running first before filtering the test cases and the globalization
27+
// code will run and fail fast at that time.
28+
29+
ProcessStartInfo psi = new ProcessStartInfo();
30+
psi.Environment.Add("DOTNET_SYSTEM_GLOBALIZATION_APPLOCALICU", "68.2.0.9");
31+
32+
RemoteExecutor.Invoke(() =>
33+
{
34+
// Ensure initializing globalization code before checking the ICU version.
35+
CultureInfo ci = CultureInfo.GetCultureInfo("en-US");
36+
37+
Type? interopGlobalization = Type.GetType("Interop+Globalization, System.Private.CoreLib");
38+
Assert.NotNull(interopGlobalization);
39+
40+
MethodInfo? methodInfo = interopGlobalization.GetMethod("GetICUVersion", BindingFlags.NonPublic | BindingFlags.Static);
41+
Assert.NotNull(methodInfo);
42+
43+
// Assert the ICU version 0x44020009 is 68.2.0.9
44+
Assert.Equal(0x44020009, (int)methodInfo.Invoke(null, null));
45+
46+
// Now call globalization API to ensure the binding working without any problem.
47+
Assert.Equal(-1, ci.CompareInfo.Compare("sample\u0000", "Sample\u0000", CompareOptions.IgnoreSymbols));
48+
}, new RemoteInvokeOptions { StartInfo = psi }).Dispose();
49+
}
50+
}
51+
}

src/native/libs/System.Globalization.Native/pal_icushim.c

+1
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,7 @@ void GlobalizationNative_InitICUFunctions(void* icuuc, void* icuin, const char*
539539
ValidateICUDataCanLoad();
540540

541541
InitializeVariableMaxAndTopPointers(symbolVersion);
542+
InitializeUColClonePointers(symbolVersion);
542543
}
543544

544545
#undef PER_FUNCTION_BLOCK

0 commit comments

Comments
 (0)