-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
[browser][non-icu] HybridGlobalization
change case
#84019
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
e9b6ebb
Enabled `HybridGlobalization` mode.
ilonatommy 1fb1e22
Enabled non-icu change case.
ilonatommy c8e80ee
Tests.
ilonatommy 738c702
Revert not connected changes.
ilonatommy f397168
Fix: Add the new file to the project.
ilonatommy d4de126
Fix: this PR is for Browser, so add it to condition.
ilonatommy 7a1b55c
Fixed calls to js.
ilonatommy 30c7039
Trying to fix CI.
ilonatommy f6f9fcf
False is default, redundant lines.
ilonatommy a8ef060
Trying to fix the CI.
ilonatommy 76abac8
Remove redundant code.
ilonatommy 376d12d
This PR is partial solution, this file will be added in a follow-up.
ilonatommy ceee24a
Fix for EAT lib tests.
ilonatommy 9afe416
We do not trim anything for Hybrid currently.
ilonatommy 4349310
Check if functions invoked only in specific modes.
ilonatommy ab8fb10
Change confusing name + move the common property to the main part of …
ilonatommy 89cbb73
Applied @mkhamoyan's suggestion.
ilonatommy de57dec
Fix previous commit: missing directive.
ilonatommy 9066e11
Fix previous commit: missing directive.
ilonatommy 1d15645
It's not IOS-connected.
ilonatommy 52935e3
Merge branch 'main' into hg-change-case
ilonatommy c082aea
Move hybrid tests to correct dir + separate ios and wasm + update sln.
ilonatommy 1f8d4f9
Invariant and hybrid cannot be both true.
ilonatommy 1aea9a8
Remove old version of hybrid tests proj.
ilonatommy ef626b4
Applied @kg's review.
ilonatommy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ internal static partial class GlobalizationMode | |
private static partial class Settings | ||
{ | ||
internal static bool Invariant { get; } = AppContextConfigHelper.GetBooleanConfig("System.Globalization.Invariant", "DOTNET_SYSTEM_GLOBALIZATION_INVARIANT"); | ||
#if TARGET_OSX || TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS | ||
ilonatommy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#if TARGET_OSX || TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS || TARGET_BROWSER || TARGET_WASI | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no WASI ? |
||
internal static bool Hybrid { get; } = AppContextConfigHelper.GetBooleanConfig("System.Globalization.Hybrid", "DOTNET_SYSTEM_GLOBALIZATION_HYBRID"); | ||
#endif | ||
internal static bool PredefinedCulturesOnly { get; } = AppContextConfigHelper.GetBooleanConfig("System.Globalization.PredefinedCulturesOnly", "DOTNET_SYSTEM_GLOBALIZATION_PREDEFINED_CULTURES_ONLY", GlobalizationMode.Invariant); | ||
|
@@ -23,7 +23,7 @@ private static partial class Settings | |
// This allows for the whole Settings nested class to be trimmed when Invariant=true, and allows for the Settings | ||
// static cctor (on Unix) to be preserved when Invariant=false. | ||
internal static bool Invariant => Settings.Invariant; | ||
#if TARGET_OSX || TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS | ||
#if TARGET_OSX || TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS || TARGET_BROWSER || TARGET_WASI | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no WASI ? |
||
internal static bool Hybrid => Settings.Hybrid; | ||
#endif | ||
internal static bool PredefinedCulturesOnly => Settings.PredefinedCulturesOnly; | ||
|
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); | ||
ilonatommy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no Web API in WASI. It probably means that the whole
Hybrid Globalization
can't be implemented there.