Description
I ported usage of Xam.Plugin.Settings to Xamarin.Essentials.Preferences in the Evolve 2016 app.
For the most part, the new Preferences class is exactly backwards compatible when loading existing data stored (good job!).
However, we are missing an overload for DateTime, for example I had to do:
public DateTime LastFavoriteTime
{
get { return new DateTime(Preferences.Get(LastFavoriteTimeKey, DateTime.UtcNow.Ticks)); }
set { Preferences.Set(LastFavoriteTimeKey, value.Ticks); }
}
It might not be clear for a developer to use a long, I first attempted string and got the following on Android:
Java.Lang.ClassCastException: java.lang.Long cannot be cast to java.lang.String
It might also be worth writing some tests that change the data types and see what the current behavior is?
Steps to Reproduce
- Port an app from using
Xam.Plugin.Settings to Xamarin.Essentials.Preferences, with existing saved settings
- Try to
Get/Set DateTime values
Expected Behavior
There should be an overload for DateTime.
Actual Behavior
Code to convert to/from a long is required.
Basic Information
- Version with issue: 0.0.1.79-preview
Reproduction Link
Commit here.