LocalStorage
LocalStorage copied to clipboard
[Bug] Lists of tuples are not being serialized correctly
Lists of tuples are not being serialized correctly.
Steps to reproduce:
- Create new Blazor Wasm project.
- Make Blazored.LocalStorage available
- Replace everything in Home.razor with the following code
@page "/"
@using Blazored.LocalStorage
@inject ILocalStorageService _localstorage
<button @onclick="SetLocalStorage">Click me</button>
@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}"));
}
}
- Run app and click button.
- See in the console, that the second time, the values are written to the console, they are not correct.
- In the dev tools, see that "foobarbaz" contains a list of tuples but the tuples are empty.