From d31b39e11acb6f7d5dcdbbffe56dce7fd11b9c89 Mon Sep 17 00:00:00 2001
From: Meri Khamoyan <96171496+mkhamoyan@users.noreply.github.com>
Date: Wed, 16 Aug 2023 18:16:21 +0400
Subject: [PATCH] [iOS][non-icu] HybridGlobalization implement normalization
functions (#90582)
[iOS] HybridGlobalization implement normalization functions
---
.../src/Interop/Interop.Normalization.iOS.cs | 17 ++++
....Globalization.Extensions.iOS.Tests.csproj | 19 ++++
.../tests/Normalization/NormalizationAll.cs | 2 +-
.../Normalization/StringNormalizationTests.cs | 2 +-
.../System.Private.CoreLib.Shared.projitems | 3 +
.../System/Globalization/Normalization.Icu.cs | 15 +++-
src/mono/mono/mini/CMakeLists.txt | 3 +-
.../CMakeLists.txt | 3 +-
.../System.Globalization.Native/entrypoints.c | 2 +
.../System.Globalization.Native/pal_casing.m | 31 -------
.../pal_icushim_internal.h | 32 +++++++
.../pal_normalization.h | 12 +++
.../pal_normalization.m | 87 +++++++++++++++++++
13 files changed, 192 insertions(+), 36 deletions(-)
create mode 100644 src/libraries/Common/src/Interop/Interop.Normalization.iOS.cs
create mode 100644 src/libraries/System.Globalization.Extensions/tests/Hybrid/System.Globalization.Extensions.iOS.Tests.csproj
create mode 100644 src/native/libs/System.Globalization.Native/pal_normalization.m
diff --git a/src/libraries/Common/src/Interop/Interop.Normalization.iOS.cs b/src/libraries/Common/src/Interop/Interop.Normalization.iOS.cs
new file mode 100644
index 0000000000000..4ba97148b4538
--- /dev/null
+++ b/src/libraries/Common/src/Interop/Interop.Normalization.iOS.cs
@@ -0,0 +1,17 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System.Runtime.InteropServices;
+using System.Text;
+
+internal static partial class Interop
+{
+ internal static partial class Globalization
+ {
+ [LibraryImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_IsNormalizedNative", StringMarshalling = StringMarshalling.Utf16)]
+ internal static unsafe partial int IsNormalizedNative(NormalizationForm normalizationForm, char* src, int srcLen);
+
+ [LibraryImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_NormalizeStringNative", StringMarshalling = StringMarshalling.Utf16)]
+ internal static unsafe partial int NormalizeStringNative(NormalizationForm normalizationForm, char* src, int srcLen, char* buffer, int bufferLength);
+ }
+}
diff --git a/src/libraries/System.Globalization.Extensions/tests/Hybrid/System.Globalization.Extensions.iOS.Tests.csproj b/src/libraries/System.Globalization.Extensions/tests/Hybrid/System.Globalization.Extensions.iOS.Tests.csproj
new file mode 100644
index 0000000000000..ada1f18597f6e
--- /dev/null
+++ b/src/libraries/System.Globalization.Extensions/tests/Hybrid/System.Globalization.Extensions.iOS.Tests.csproj
@@ -0,0 +1,19 @@
+
+
+ $(NetCoreAppCurrent)-ios;$(NetCoreAppCurrent)-tvos;$(NetCoreAppCurrent)-maccatalyst
+ true
+ true
+
+
+
+
+
+
+
+ NormalizationDataWin8
+
+
+ NormalizationDataWin7
+
+
+
diff --git a/src/libraries/System.Globalization.Extensions/tests/Normalization/NormalizationAll.cs b/src/libraries/System.Globalization.Extensions/tests/Normalization/NormalizationAll.cs
index 48f73a4527a38..8d27652096c51 100644
--- a/src/libraries/System.Globalization.Extensions/tests/Normalization/NormalizationAll.cs
+++ b/src/libraries/System.Globalization.Extensions/tests/Normalization/NormalizationAll.cs
@@ -52,7 +52,7 @@ public void Normalize()
VerifyConformanceInvariant(NormalizationForm.FormD, part0, part1, part2, part3, part4);
// Mobile / Browser ICU doesn't support FormKC and FormKD
- if (PlatformDetection.IsNotUsingLimitedCultures)
+ if (PlatformDetection.IsNotUsingLimitedCultures || PlatformDetection.IsHybridGlobalizationOnOSX)
{
// Form KC
VerifyConformanceInvariant(NormalizationForm.FormKC, part0, part1, part2, part3, part4);
diff --git a/src/libraries/System.Globalization.Extensions/tests/Normalization/StringNormalizationTests.cs b/src/libraries/System.Globalization.Extensions/tests/Normalization/StringNormalizationTests.cs
index 7fe18bb314049..252d19a16f17b 100644
--- a/src/libraries/System.Globalization.Extensions/tests/Normalization/StringNormalizationTests.cs
+++ b/src/libraries/System.Globalization.Extensions/tests/Normalization/StringNormalizationTests.cs
@@ -49,7 +49,7 @@ public static IEnumerable