jamesmontemagno / SettingsPlugin

Read and Write Settings Plugin for Xamarin and Windows
MIT License
324 stars 80 forks source link

Saved an IP as a string and cannot reload it as a string #149

Closed jonmpoole closed 5 years ago

jonmpoole commented 5 years ago

Failure to fill out this information will result in this issue being closed.

If you are creating an issue for a BUG please fill out this information. If you are asking a question or requesting a feature you can delete the sections below.

If you post a full stack trace in a bug it will be closed, please post it to http://gist.github.com and then post the link here.

Bug Information

Version Number of Plugin: 3.1.1 Device Tested On: Android Tablet Simulator Tested On: NA Version of VS: 2017 Version of Xamarin: 3.3.0.967583 Versions of other things you are using:

Steps to reproduce the Behavior

Save a string via settings that looks like this 127.0.0.1 and recall using GetValueOrDefault

Expected Behavior

Should load the string that was saved

Actual Behavior

Unhandled Exception:

Java.Lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String

Code snippet

    public static string EndPointIP
    {
        get => AppSettings.GetValueOrDefault(nameof(EndPointIP), "0.0.0.0");
        set => AppSettings.AddOrUpdateValue(nameof(EndPointIP), value);
    }

Screenshots

image

jamesmontemagno commented 5 years ago

It is because you saved it below in your "EndPointPort".... you have a typo there where you are using the IP.

Once you save a setting as a value you can't undo it and have to remove it.

Update your EndPointPort to use the correct nameof(EndPointPort)

jonmpoole commented 5 years ago

Good call, Coding tired is the worst kind of coding.

Thanks!

Jon Poole Creative Information Systems – A Valsoft Company Senior Engineer

From: James Montemagno notifications@github.com Sent: Tuesday, February 19, 2019 12:09 PM To: jamesmontemagno/SettingsPlugin SettingsPlugin@noreply.github.com Cc: Jon Poole jonpoole@creativeinfo.net; Author author@noreply.github.com Subject: Re: [jamesmontemagno/SettingsPlugin] Saved an IP as a string and cannot reload it as a string (#149)

It is because you saved it below in your "EndPointPort".... you have a typo there where you are using the IP.

Once you save a setting as a value you can't undo it and have to remove it.

Update your EndPointPort to use the correct nameof(EndPointPort)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/jamesmontemagno/SettingsPlugin/issues/149#issuecomment-465223208, or mute the threadhttps://github.com/notifications/unsubscribe-auth/Atd4ZFdPBMjEAr4NFKeipLOv5IFR1HTcks5vPC--gaJpZM4a-WDN.