Bug 37116

Summary: [iOS] Application.Current.Properties does not persist on iOS with Forms
Product: iOS Reporter: Dominic N [MSFT] <dominic>
Component: BCL Class LibrariesAssignee: marcos.henrich
Status: VERIFIED FIXED    
Severity: normal CC: bradley.umbaugh, brendan.zagaeski, chrisntr, gouri.kumari, kumpera, masafa, mono-bugs+monotouch, nnadig, parmendrak
Priority: Normal    
Version: XI 9.4 (iOS 9.2)   
Target Milestone: (C7)   
Hardware: PC   
OS: Mac OS   
See Also: https://bugzilla.xamarin.com/show_bug.cgi?id=28657
Tags: c7regression Is this bug a regression?: ---
Last known good build:

Description Dominic N [MSFT] 2015-12-17 05:31:38 UTC
### Overview

It seems like using the Properties Dictionary to set application properties does not persist, even when using SavePropertiesAsync()

Have tried this with Xamarin.Forms 1.4 and 2.0 series - it seems the breakage is dependent on the version of Xamarin.iOS installed on the machine as such:

Good: XI 9.0.1.29
Bad: XI 9.2.1.54, XI 9.4.0.0


### Steps to Reproduce

1. Download sample app from private comment
2. Run sample app on iOS device
3. Log in using credentials provided in private comment
4. Return to the home screen of the device
5. Double click home to open the app switcher
6. Close the test app by swiping up
7. Relaunch app from iPhone home screen


### Actual Results

Log in status within app does not persist in XI 9.2.1.54 and above


### Expected Results

Log in status within app persists (no need to sign in again)


### Additional Information

=== Xamarin Studio ===

Version 5.10.1 (build 6)
Installation UUID: ee07b9c8-41e3-496f-a1ab-e8a3ed3db20f
Runtime:
	Mono 4.2.1 (explicit/6dd2d0d)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 402010102

=== Xamarin.Profiler ===

Version: 0.22.0.0
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Apple Developer Tools ===

Xcode 7.2 (9536.2)
Build 7C46t

=== Xamarin.iOS ===

Version: 9.4.0.0 (Business Edition)
Hash: 7322991
Branch: master
Build date: 2015-12-08 16:20:29-0500

=== Xamarin.Android ===

Version: 6.0.0.34 (Business Edition)
Android SDK: /Users/dominicnahous/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		2.3   (API level 10)
		4.0.3 (API level 15)
		4.1   (API level 16)
		4.2   (API level 17)
		4.4   (API level 19)
		5.0   (API level 21)
		5.1   (API level 22)
		6.0   (API level 23)

SDK Tools Version: 24.4.1
SDK Platform Tools Version: 23.1
SDK Build Tools Version: 23.0.0

Java SDK: /usr
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

=== Xamarin Android Player ===

Version: 0.6.5
Location: /Applications/Xamarin Android Player.app

=== Xamarin.Mac ===

Version: 2.4.0.109 (Business Edition)

=== Build Information ===

Release ID: 510010006
Git revision: 0b60eecdb531933734519c13257d16a780274aab
Build date: 2015-12-04 20:28:20-05
Xamarin addins: 9876fd7c9837977178411ec7375b4352c0a0d6af
Build lane: monodevelop-lion-cycle6-baseline

=== Operating System ===

Mac OS X 10.10.5
Darwin Dominics-MacBook-Pro.local 14.5.0 Darwin Kernel Version 14.5.0
    Wed Jul 29 02:26:53 PDT 2015
    root:xnu-2782.40.9~1/RELEASE_X86_64 x86_64
Comment 3 Rolf Bjarne Kvinge [MSFT] 2016-02-08 13:09:14 UTC
@Marek, can you have a look at this? It is probably something that happened when we started importing the reference sources.

Simpler test case:

		IDictionary<string, object> dict = new Dictionary<string, object> ();
		dict.Add ("test", new List<string> () { "test entry" });
		try {
			var dcs = new DataContractSerializer (typeof(Dictionary<string, object>));
			dcs.WriteObject (new MemoryStream (), dict);
		} catch (Exception e) {
			Console.WriteLine ("Could not serialize properties: " + e.Message);
		}

prints:

Could not serialize properties: Type 'System.Collections.Generic.List`1[[System.String, mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]' with data contract name 'ArrayOfstring:http://schemas.microsoft.com/2003/10/Serialization/Arrays' is not expected. Add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.

Setting target to C7 since this is a regression.
Comment 4 Rodrigo Kumpera 2016-02-08 16:21:09 UTC
Hey Marcos,

Could you take a look at this serialization regression?
Comment 5 marcos.henrich 2016-02-29 19:41:35 UTC
This issue is fixed by the following pull request:
https://github.com/mono/mono/pull/2698

Once the pull request is reviewed/approved I will add this to mono-4.4.0-branch.
Comment 6 marcos.henrich 2016-03-30 17:44:24 UTC
Fixed in master ff49850dfc18f5991246a203184fa1e0b8a7c7ab
https://github.com/mono/mono/commit/ff49850dfc18f5991246a203184fa1e0b8a7c7ab

Created pull request for mono-4.4.0 (cycle 7)
https://github.com/mono/mono/pull/2813
Comment 7 GouriKumari 2016-04-11 16:57:31 UTC
Based on comment #3, I am marking this bug as a regression in C7.

@kumpera : Can this pull request be included with mono 4.4.0? 
@sebastien @rolf: Should we bump mono to include this fix?
Comment 8 Rodrigo Kumpera 2016-04-11 19:52:40 UTC
Let's include it on C7.

Marcos, anything else here or do we need to keep it open?
Comment 9 marcos.henrich 2016-04-12 16:36:06 UTC
I was only waiting for 360 logic to confirm on trello that this was fixed.

Fixed on mono-4.4.0-branch
https://github.com/mono/mono/commit/10dcc60ae1834aeb99c4afdcd17e4588feb797d1

@Gouri,@Sebastien, yes, this will require a mono bump.
Comment 10 Parmendra Kumar 2016-04-13 19:02:11 UTC
I have checked this issue with xamarin.ios-9.8.0.237 and its working fine.

ApplicationOutput: https://gist.github.com/Parmendrak/6bd320c6f5720d7f3e0434f645fa7b3d

Environment Info: https://gist.github.com/Parmendrak/9389120a71928bb6fb7229c35d04cac4
Comment 11 Parmendra Kumar 2016-04-14 11:34:33 UTC
I have checked this issue with latest C7 build: xamarin.ios-9.8.0.253_5f3bb0db4b9650bdf5e151c5632f4f09e7a19907 and its working fine.

Screencast: http://www.screencast.com/t/Bh8Y0OTJ

Environment Info: https://gist.github.com/Parmendrak/8cdcfa3906b4e3ba5863d221a8758448