Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Merge branch 'main' into hg-compare
  • Loading branch information
ilonatommy committed Apr 4, 2023
commit 54cc7743c24dea981bb5d88b0b735e1833029360
13 changes: 11 additions & 2 deletions docs/design/features/hybrid-globalization.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,21 @@ Hybrid mode does not use ICU data for some functions connected with globalizatio

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.

**String comparison**

Affected public APIs:
- CompareInfo.Compare,
- String.Compare
- String.Equals
- String.Compare,
- String.Equals.

The number of `CompareOptions` and `StringComparison` combinations is limited. Originally supported combinations can be found [here for CompareOptions](https://learn.microsoft.com/dotnet/api/system.globalization.compareoptions) and [here for StringComparison](https://learn.microsoft.com/dotnet/api/system.stringcomparison).

Expand Down
4 changes: 3 additions & 1 deletion src/mono/wasm/runtime/corebindings.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ extern void mono_wasm_typed_array_from_ref (int ptr, int begin, int end, int byt
// Blazor specific custom routines - see dotnet_support.js for backing code
extern void* mono_wasm_invoke_js_blazor (MonoString **exceptionMessage, void *callInfo, void* arg0, void* arg1, void* arg2);
#endif /* ENABLE_LEGACY_JS_INTEROP */
extern int mono_wasm_compare_string(MonoString **exceptionMessage, MonoString **culture, const uint16_t* str1, int32_t str1Length, const uint16_t* str2, int32_t str2Length, int32_t options);

// HybridGlobalization
extern void mono_wasm_change_case_invariant(MonoString **exceptionMessage, const uint16_t* src, int32_t srcLength, uint16_t* dst, int32_t dstLength, mono_bool bToUpper);
extern void mono_wasm_change_case(MonoString **exceptionMessage, MonoString **culture, const uint16_t* src, int32_t srcLength, uint16_t* dst, int32_t dstLength, mono_bool bToUpper);
extern int mono_wasm_compare_string(MonoString **exceptionMessage, MonoString **culture, const uint16_t* str1, int32_t str1Length, const uint16_t* str2, int32_t str2Length, int32_t options);

void bindings_initialize_internals (void)
{
Expand Down Expand Up @@ -74,5 +74,7 @@ void bindings_initialize_internals (void)
// Blazor specific custom routines - see dotnet_support.js for backing code
mono_add_internal_call ("WebAssembly.JSInterop.InternalCalls::InvokeJS", mono_wasm_invoke_js_blazor);
#endif /* ENABLE_LEGACY_JS_INTEROP */
mono_add_internal_call ("System.Globalization.TextInfoInterop::ChangeCaseInvariantJS", mono_wasm_change_case_invariant);
mono_add_internal_call ("System.Globalization.TextInfoInterop::ChangeCaseJS", mono_wasm_change_case);
mono_add_internal_call ("System.Globalization.CompareInfoInterop::CompareStringJS", mono_wasm_compare_string);
}
2 changes: 2 additions & 0 deletions src/mono/wasm/runtime/es6/dotnet.es6.lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ let linked_functions = [
"mono_wasm_invoke_import",
"mono_wasm_bind_cs_function",
"mono_wasm_marshal_promise",
"mono_wasm_change_case_invariant",
"mono_wasm_change_case",
"mono_wasm_compare_string",

"icudt68_dat",
Expand Down
4 changes: 3 additions & 1 deletion src/mono/wasm/runtime/exports-linker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { mono_wasm_typed_array_to_array_ref } from "./net6-legacy/js-to-cs";
import { mono_wasm_typed_array_from_ref } from "./net6-legacy/buffers";
import {
mono_wasm_invoke_js_blazor, mono_wasm_invoke_js_with_args_ref, mono_wasm_get_object_property_ref, mono_wasm_set_object_property_ref,
mono_wasm_get_by_index_ref, mono_wasm_set_by_index_ref, mono_wasm_get_global_object_ref, mono_wasm_compare_string
mono_wasm_get_by_index_ref, mono_wasm_set_by_index_ref, mono_wasm_get_global_object_ref, mono_wasm_change_case_invariant, mono_wasm_change_case, mono_wasm_compare_string
} from "./net6-legacy/method-calls";

// the methods would be visible to EMCC linker
Expand Down Expand Up @@ -93,6 +93,8 @@ export function export_linker(): any {
mono_wasm_invoke_import,
mono_wasm_bind_cs_function,
mono_wasm_marshal_promise,
mono_wasm_change_case_invariant,
mono_wasm_change_case,
mono_wasm_compare_string,

// threading exports, if threading is enabled
Expand Down
4 changes: 2 additions & 2 deletions src/mono/wasm/runtime/net6-legacy/method-calls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { get_js_obj, mono_wasm_get_jsobj_from_js_handle } from "../gc-handles";
import { Module, runtimeHelpers, INTERNAL } from "../imports";
import { wrap_error_root, wrap_no_error_root } from "../invoke-js";
import { _release_temp_frame, setU16 } from "../memory";
import { setU16, _release_temp_frame } from "../memory";
import { mono_wasm_new_external_root, mono_wasm_new_root } from "../roots";
import { find_entry_point } from "../run";
import { conv_string_root, js_string_to_mono_string_root } from "../strings";
Expand Down Expand Up @@ -299,7 +299,7 @@ export function mono_wasm_invoke_js_blazor(exceptionMessage: Int32Ptr, callInfo:
}
}

export function mono_wasm_change_case_invariant(exceptionMessage: Int32Ptr, src: number, srcLength: number, dst: number, dstLength: number, toUpper: boolean) : void{
export function mono_wasm_change_case_invariant(exceptionMessage: Int32Ptr, src: number, srcLength: number, dst: number, dstLength: number, toUpper: number) : void{
try{
const input = get_uft16_string(src, srcLength);
let result = toUpper ? input.toUpperCase() : input.toLowerCase();
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.