Bug 28657 - Application.Current.Properties does not save List<T> values between app sessions
Summary: Application.Current.Properties does not save List<T> values between app sessions
Status: RESOLVED INVALID
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms (show other bugs)
Version: 1.4.1
Hardware: PC Mac OS
: High critical
Target Milestone: ---
Assignee: Jason Smith [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2015-04-01 14:57 UTC by John Miller [MSFT]
Modified: 2016-02-09 02:59 UTC (History)
10 users (show)

See Also:
Tags: all functional AC
Is this bug a regression?: ---
Last known good build:


Attachments
Test Sample (4.66 MB, application/zip)
2015-04-03 11:25 UTC, Abhishek
Details

Description John Miller [MSFT] 2015-04-01 14:57:52 UTC
**Overview:**

   Saving application properties with a value of List<T> do not save between app sessions. 

**Steps to Reproduce:**

   1. Create a Forms 1.4.1 portable solution
   2. Use this code in the Application subclass

protected override void OnStart ()
{
   if (!Current.Properties.ContainsKey ("obj")) {
       var test = new List<string>() { "test" };
       Current.Properties.Add("obj", test);

       SavePropertiesAsync ();
   }
    else
        Debug.WriteLine("Found");
}

**Actual Results:**

   When launching the app, it will always enter the if statement and save a new property. 

**Expected Results:**

   It should only save a new property once. On subsequent launches it should output a Debug statement "Found". 

**Build Date & Platform:**

   XF 1.4.1

**Additional Information:**

   Saving a primitive type like int or string works fine. It becomes an issue when using a collection like List<T>.
Comment 1 Abhishek 2015-04-03 11:25:20 UTC
Created attachment 10621 [details]
Test Sample

I have tried this issue and able to reproduce the reported behavior at my end.

1. Create an Xamarin.Forms Application.
2. Copy the above code and use it in application subclass. Add Debug.WriteLine("Hello");  in the If condition to check the behavior.
3. Run the application in Device/Simulator.
4. It will Print Hello in the application output. 
5. Stop the application. Deploy the same application on the Device /Simulator .Again it will print Hello in the application Output. 
6. If we use primitive  date type like"int"its work fine and display the hello in the application output once .
7.Again if I deploy the same application it will not enter the if condition and it will print  found on the application output.

Screencast:http://www.screencast.com/t/FXmAAlCqP
IOS Device Log:https://gist.github.com/Abhishekk360/69c5607f86606c8c193e
IDE Log:https://gist.github.com/Abhishekk360/4c29a84f9acee020d3c3

Environment Info:

Xamarin.Forms: 1.4.2.6353-pre2,1.4.1.6349

=== Xamarin Studio ===

Version 5.8.2 (build 7)
Installation UUID: 93e693b0-b53d-40f4-b29c-b61ff5cbe892
Runtime:
	Mono 3.12.1 ((detached/0849ec7)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312010003

=== Apple Developer Tools ===

Xcode 6.2 (6776)
Build 6C131e

=== Xamarin.iOS ===

Version: 8.8.2.5 (Business Edition)
Hash: 1722273
Branch: 
Build date: 2015-04-01 13:07:55-0400

=== Xamarin.Android ===

Version: 4.20.1.0 (Business Edition)
Android SDK: /Users/xamarin23/Desktop/android-sdk-macosx
	Supported Android versions:
		2.1    (API level 7)
		2.2    (API level 8)
		2.3    (API level 10)
		3.1    (API level 12)
		4.0    (API level 14)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
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: Unknown version
Location: /Applications/Xamarin Android Player.app

=== Xamarin.Mac ===

Version: 1.12.0.14 (Business Edition)

=== Build Information ===

Release ID: 508020007
Git revision: 067ed06873402cf780f8a0899bb332c2a1c0af22
Build date: 2015-03-27 14:17:13-04
Xamarin addins: 02510c4990dee3475c282b3182d588975a63ff07

=== Operating System ===

Mac OS X 10.10.0
Darwin 800BC.local 14.0.0 Darwin Kernel Version 14.0.0
    Fri Sep 19 00:26:44 PDT 2014
    root:xnu-2782.1.97~2/RELEASE_X86_64 x86_64
Comment 4 Jason Smith [MSFT] 2016-02-09 02:59:11 UTC
This is expected behavior, properties can only serialize out primitive types.

Note You need to log in before you can comment on or make changes to this bug.