-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[browser][non-icu]
HybridGlobalization
change case (#84019)
* Enabled `HybridGlobalization` mode. * Enabled non-icu change case. * Tests. * Revert not connected changes. * Fix: Add the new file to the project. * Fix: this PR is for Browser, so add it to condition. * Fixed calls to js. * Trying to fix CI. * False is default, redundant lines. * Trying to fix the CI. * Remove redundant code. * This PR is partial solution, this file will be added in a follow-up. * Fix for EAT lib tests. * We do not trim anything for Hybrid currently. * Check if functions invoked only in specific modes. * Change confusing name + move the common property to the main part of the class. * Applied @mkhamoyan's suggestion. * Fix previous commit: missing directive. * Fix previous commit: missing directive. * It's not IOS-connected. * Move hybrid tests to correct dir + separate ios and wasm + update sln. * Invariant and hybrid cannot be both true. * Remove old version of hybrid tests proj. * Applied @kg's review.
- Loading branch information
1 parent
50c8895
commit 9afb7d4
Showing
21 changed files
with
227 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Hybrid Globalization | ||
|
||
Description, purpose and instruction how to use. | ||
|
||
## Behavioral differences | ||
|
||
Hybrid mode does not use ICU data for some functions connected with globalization but relies on functions native to the platform. Because native APIs do not fully cover all the functionalities we currently support and because ICU data can be excluded from the ICU datafile only in batches defined by ICU filters, not all functions will work the same way or not all will be supported. To see what to expect after switching on `HybridGlobalization`, read the following paragraphs. | ||
|
||
### WASM | ||
|
||
For WebAssembly, both on Browser and WASI, we are using Web API instead of some ICU data. | ||
|
||
**Case change** | ||
|
||
Affected public APIs: | ||
- TextInfo.ToLower, | ||
- TextInfo.ToUpper, | ||
- TextInfo.ToTitleCase. | ||
|
||
Case change with invariant culture uses `toUpperCase` / `toLoweCase` functions that do not guarantee a full match with the original invariant culture. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,4 @@ | |
<ItemGroup> | ||
<Compile Include="HybridMode.cs" /> | ||
</ItemGroup> | ||
</Project> | ||
</Project> |
10 changes: 10 additions & 0 deletions
10
src/libraries/System.Globalization/tests/Hybrid/Hybrid.WASM.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>$(NetCoreAppCurrent)</TargetFramework> | ||
<TestRuntime>true</TestRuntime> | ||
<HybridGlobalization>true</HybridGlobalization> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="..\System\Globalization\TextInfoTests.cs" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/libraries/System.Private.CoreLib/src/System/Globalization/TextInfo.WebAssembly.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Diagnostics; | ||
using System.Runtime.CompilerServices; | ||
|
||
namespace System.Globalization | ||
{ | ||
internal static unsafe class TextInfoInterop | ||
{ | ||
[MethodImplAttribute(MethodImplOptions.InternalCall)] | ||
internal static extern unsafe void ChangeCaseInvariantJS(out string exceptionMessage, char* src, int srcLen, char* dstBuffer, int dstBufferCapacity, bool bToUpper); | ||
[MethodImplAttribute(MethodImplOptions.InternalCall)] | ||
internal static extern unsafe void ChangeCaseJS(out string exceptionMessage, in string culture, char* src, int srcLen, char* dstBuffer, int dstBufferCapacity, bool bToUpper); | ||
} | ||
|
||
public partial class TextInfo | ||
{ | ||
internal unsafe void JsChangeCase(char* src, int srcLen, char* dstBuffer, int dstBufferCapacity, bool toUpper) | ||
{ | ||
Debug.Assert(!GlobalizationMode.Invariant); | ||
Debug.Assert(!GlobalizationMode.UseNls); | ||
Debug.Assert(GlobalizationMode.Hybrid); | ||
|
||
string exceptionMessage; | ||
if (HasEmptyCultureName) | ||
{ | ||
TextInfoInterop.ChangeCaseInvariantJS(out exceptionMessage, src, srcLen, dstBuffer, dstBufferCapacity, toUpper); | ||
} | ||
else | ||
{ | ||
TextInfoInterop.ChangeCaseJS(out exceptionMessage, _cultureName, src, srcLen, dstBuffer, dstBufferCapacity, toUpper); | ||
} | ||
if (!string.IsNullOrEmpty(exceptionMessage)) | ||
throw new Exception(exceptionMessage); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.