Bug 38891 - Turning linker on causes exceptions when stringifying DateTime objects when using certain culture settings
Summary: Turning linker on causes exceptions when stringifying DateTime objects when u...
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: XI 9.4 (iOS 9.2)
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2016-02-18 21:44 UTC by Randall Schmidt
Modified: 2016-02-19 02:20 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Reproduction case (12.28 KB, application/zip)
2016-02-18 21:44 UTC, Randall Schmidt

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Randall Schmidt 2016-02-18 21:44:52 UTC
Created attachment 15092 [details]
Reproduction case

With the linker turned to an option other than "Don't Link" and the culture set to "ar-SA" (Arabic, Saudi Arabia), calling ToString() on a DateTime object or trying to format one causes an exception:

System.ArgumentOutOfRangeException: Not a valid calendar for the given culture.

To reproduce, build the attached reproduction case and deploy. Tap the "Change CurrentCulture to ar-SA" button and then tap one or both of the other two buttons to see exceptions.

Then change the linker options to "Don't Link" and try again. Then, behavior is as expected, there are no exceptions.
Comment 1 Brendan Zagaeski (Xamarin Team, assistant) 2016-02-19 00:56:25 UTC
In this instance, this is the correct intended behavior of the linker to allow minimizing the size of the app by omitting internationalizations that are not used. The developer must use the project options to select the desired internationalizations to include.

See: https://developer.xamarin.com/guides/ios/advanced_topics/localization_and_internationalization/encodings/

## Fix

### Xamarin Studio

Enable "Project Options -> iOS Build -> Internationalization [heading] -> mideast [checkbox]"

### Visual Studio

Enable "Project Properties -> iOS Build -> Advanced [tab] -> Internationalization [heading] -> mideast [checkbox]"

(As a caution, in the current version of Xamarin for Visual Studio you will need to watch out for Bug 29323 which can unfortunately cause this setting to get unchecked "automatically.")

(I verified briefly that this properly solved the problem in the attached test case from Comment 0. I tested both Xamarin Studio on Mac and Visual Studio on Windows using the current Stable versions of Xamarin.)
Comment 2 Randall Schmidt 2016-02-19 02:20:28 UTC
Thanks for the info, Brendan.