Blazored / LocalStorage

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

Net 8.0 iOS System.Text.Json.Serialization.JsonConverter System.ArgumentOutOfRangeException [Bug] #228

Open Meoqan opened 11 months ago

Meoqan commented 11 months ago

Describe the bug while testing my app under Net 8.0 on iOS, LocalStorage seems to break the serializer for some reason. If i delete the data in the browser storage, the app loads the data from the api then everything works fine.

LocalStorage works with Windows and MacOSX browsers on Net 8.0. No Issue with LocalStorage on Net 7.0 with iOS.

To Reproduce Steps to reproduce the behavior: Migrate a app with LocalStorage to Net 8.0 and test it on iOS Save or load Json/object data to LocalStorage with a Base64 Image (the image breaks) Try to load Json data from a WebAPI with >174kb size (not LocalStorage, small data works fine)

the following error message appears: System.ArgumentOutOfRangeException: Arg_ArgumentOutOfRangeException at System.Text.Json.Serialization.JsonConverter1 [[BlazorApp.JsonClass.Article[], BlazorApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].ReadCore(Utf8JsonReader& , JsonSerializerOptions , ReadStack& ) at System.Text.Json.Serialization.Metadata.JsonTypeInfo1.<DeserializeAsync>d__1 [[BlazorApp.JsonClass.Article[], BlazorApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext() at System.Text.Json.Serialization.JsonConverter1 [[BlazorApp.JsonClass.Article[], BlazorApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].ReadCore(Utf8JsonReader& , JsonSerializerOptions , ReadStack& ) at System.Net.Http.Json.HttpClientJsonExtensions.<<FromJsonAsyncCore>g__Core|12_0>d2 [[BlazorApp.JsonClass.Article[], BlazorApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.Text.Json.JsonSerializerOptions, System.Text.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51]].MoveNext() at System.Text.Json.Serialization.JsonConverter1 [[BlazorApp.JsonClass.Article[], BlazorApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].ReadCore(Utf8JsonReader& , JsonSerializerOptions , ReadStack& ) at BlazorApp.JsonClass.Article.GetList(HttpClient Http, String OrganizationName, String ContextName) at System.Text.Json.Serialization.JsonConverter1 [[BlazorApp.JsonClass.Article[], BlazorApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].ReadCore(Utf8JsonReader& , JsonSerializerOptions , ReadStack& ) at BlazorApp.Module.Context.IndexComponent.OnParametersSetAsync()

Hosting Model:

Additional context I use the WriteIndented option builder.Services.AddBlazoredLocalStorage(config => config.JsonSerializerOptions.WriteIndented = false);

jacksonsfaria commented 11 months ago

Net 8 error for me.

"ConstructorContainsNullParameterNames, System.Collections.Generic.KeyValuePair2[System.String,System.Collections.Generic.IEnumerable1[System.String]]"