Skip to content

Support loading ICU data from managed Interop#49406

Merged
steveisok merged 5 commits into
dotnet:mainfrom
steveisok:ios-load-icu-managed
Mar 13, 2021
Merged

Support loading ICU data from managed Interop#49406
steveisok merged 5 commits into
dotnet:mainfrom
steveisok:ios-load-icu-managed

Conversation

@steveisok

Copy link
Copy Markdown
Member

In iOS we support loading a custom dat file when working with ICU. The way this worked originally was the mono runtime exported a function that native code would call into (similar to wasm). After thinking about it a bit, it makes more sense to load ICU the same way we do on desktop, but with the ability to provide the path to an ICU dat file via an AppContext key ICU_DAT_FILE_PATH. The key can be provided before Xamarin iOS calls monovm_initialize and they won't have to worry about calling some special function.

In iOS we support loading a custom dat file when working with ICU.  The way this worked originally was the mono runtime exported a function that
native code would call into (similar to wasm).  After thinking about it a bit, it makes more sense to load this the same way we do on desktop, but with the
ability to provide the path to an ICU dat file via an AppContext key `ICU_DAT_FILE_PATH`.  This can be provided before Xamarin iOS calls `monovm_initialize` and they won't have to worry about calling some special function.
@ghost

ghost commented Mar 10, 2021

Copy link
Copy Markdown

Tagging subscribers to this area: @tarekgh, @safern
See info in area-owners.md if you want to be subscribed.

Issue Details

In iOS we support loading a custom dat file when working with ICU. The way this worked originally was the mono runtime exported a function that native code would call into (similar to wasm). After thinking about it a bit, it makes more sense to load ICU the same way we do on desktop, but with the ability to provide the path to an ICU dat file via an AppContext key ICU_DAT_FILE_PATH. The key can be provided before Xamarin iOS calls monovm_initialize and they won't have to worry about calling some special function.

Author: steveisok
Assignees: -
Labels:

area-System.Globalization

Milestone: -

Comment thread src/libraries/Common/src/Interop/Interop.ICU.cs Outdated
@tarekgh

tarekgh commented Mar 10, 2021

Copy link
Copy Markdown
Member

How we'll guarantee the loaded data file will be compatible with the loaded ICU code library? I am guessing we can run into some issues that will be hard to diagnose if the data is not compatible with the code library.

@steveisok

Copy link
Copy Markdown
Member Author

How we'll guarantee the loaded data file will be compatible with the loaded ICU code library? I am guessing we can run into some issues that will be hard to diagnose if the data is not compatible with the code library.

For iOS, we'll control the version that we're using and the data file that comes with it. Beyond that, good question.

Comment thread src/tasks/AppleAppBuilder/Templates/runtime.m Outdated
Comment thread src/libraries/Common/src/Interop/Interop.ICU.cs Outdated
Comment thread src/tasks/AppleAppBuilder/Templates/runtime.m Outdated

@CoffeeFlux CoffeeFlux left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for hitting you with a bunch of style nits again.

Otherwise looks fine to me, thanks!

Comment thread src/libraries/Native/Unix/System.Globalization.Native/pal_icushim_static.c Outdated
Comment thread src/libraries/Native/Unix/System.Globalization.Native/pal_icushim_static.c Outdated
Comment thread src/libraries/Native/Unix/System.Globalization.Native/pal_icushim_static.c Outdated
Comment thread src/tasks/AppleAppBuilder/Templates/runtime.m Outdated
Comment thread src/tasks/AppleAppBuilder/Templates/runtime.m Outdated
Comment thread src/tasks/AppleAppBuilder/Templates/runtime.m Outdated
Comment thread src/tasks/AppleAppBuilder/Templates/runtime.m Outdated
Comment thread src/tasks/AppleAppBuilder/Templates/runtime.m Outdated
Comment thread src/libraries/Common/src/Interop/Interop.ICU.cs Outdated
@steveisok

Copy link
Copy Markdown
Member Author

@safern @tarekgh can you please review again?

Comment thread src/libraries/Common/src/Interop/Interop.ICU.iOS.cs Outdated

return load_icu_data (icu_data);
if (load_icu_data(icu_data) == 0) {
fprintf(stderr, "ICU BAD EXIT %d.", ret);

@tarekgh tarekgh Mar 11, 2021

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fprintf [](start = 8, length = 7)

should we do log_icu_error instead in all places writing to the stderr?

Comment thread src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems Outdated

@tarekgh tarekgh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some minor comments. LGTM otherwise.

@lambdageek lambdageek left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

monovm_ bits lgtm

Comment thread src/tasks/AppleAppBuilder/Templates/runtime.m
Comment thread src/tasks/AppleAppBuilder/Templates/runtime.m
bundle,
#ifndef INVARIANT_GLOBALIZATION
icu_dat_path,
icu_dat_path

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: trailing commas are not an error.

(and they play nicer with git history when someone adds the next array entry)

@steveisok

Copy link
Copy Markdown
Member Author

Mono windows test failures are unrelated #49569

@steveisok steveisok merged commit 1d9c402 into dotnet:main Mar 13, 2021
@steveisok steveisok deleted the ios-load-icu-managed branch March 13, 2021 15:32
@ghost ghost locked as resolved and limited conversation to collaborators Apr 12, 2021
@karelz karelz added this to the 6.0.0 milestone May 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants