Blazored / LocalStorage

A library to provide access to local storage in Blazor applications
https://blazored.github.io/LocalStorage/
MIT License
1.25k stars 117 forks source link

[Bug] Lists of tuples are not being serialized correctly #236

Open PhilippJR opened 10 months ago

PhilippJR commented 10 months ago

Lists of tuples are not being serialized correctly.

Steps to reproduce:

  1. Create new Blazor Wasm project.
  2. Make Blazored.LocalStorage available
  3. Replace everything in Home.razor with the following code
    
    @page "/"
    @using Blazored.LocalStorage
    @inject ILocalStorageService _localstorage

<button @onclick="SetLocalStorage">Click me @code { private async Task SetLocalStorage() { var entries = new List<(string, int)> { ("foo", 1), ("bar", 2), ("baz", 3) }; entries.ForEach(item => Console.WriteLine($"{item.Item1}: {item.Item2}")); await _localstorage.SetItemAsync("foobarbaz", entries);

    entries = await _localstorage.GetItemAsync<List<(string, int)>>("foobarbaz");
    entries.ForEach(item => Console.WriteLine($"{item.Item1}: {item.Item2}"));
}

}



4. Run app and click button.
5. See in the console, that the second time, the values are written to the console, they are not correct.
6. In the dev tools, see that "foobarbaz" contains a list of tuples but the tuples are empty.