Skip to content

GetItem doesn't restore properties with a private setter #43

@tleylan

Description

@tleylan

I tested int and string properties. The values in setTest exist in local storage but the default values are assigned to var getTest. If I make the setter public it works.

var setTest = new Test();
setTest.SetValues(2, "changed");

Console.WriteLine($"setTest: {setTest.IntValue} {setTest.StringValue}");
await LocalStorage.SetItemAsync("test", setTest);

var getTest = await LocalStorage.GetItemAsync("test");
Console.WriteLine($"getTest: {getTest.IntValue} {getTest.StringValue}");

public class Test
{
public Int32 IntValue { get; private set; } = 1;
public String StringValue { get; private set; } = "default";

    public void SetValues(Int32 intValue, String stringValue)
    {
        IntValue = intValue;
        StringValue = stringValue;
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions