Open ahmedsaidzahran opened 5 years ago
The error you mentioned occurred in older versions. However, it should be resolved in v2.0.0-beta-2. I'm really interested in getting to the bottom of this and make sure it's not a regression issue.
@ahmedsaidzahran Do you have additional info, or a code sample, that helps me reproduce the problem?
@hanssens and @ahmedsaidzahran, The issue is related to using(){}. The storage object is not destroyed so it is overrated by the new object that was created in an inner method that responsible for storing the value. you will find below my examples for the issue and my solution.
Issue Ex:
using (var storage = new LocalStorage())
{
if(storage.Exists(Strings.Token))
{
return storage.Get(Strings.Token).ToString();
}
else
{
GenerateToken().Wait();
return storage.Get(Strings.Token).ToString();
}
}
Soultion:
var storage = new LocalStorage();
if (storage.Exists(Strings.Token))
{
return storage.Get(Strings.Token).ToString();
}
else
{
GenerateToken().Wait();
return storage.Get(Strings.Token).ToString();
}
@hanssens, I suggest we could convert the Storage property to be static.
I can't reproduce the problem you mention. Is there any way you @ahmedsaidzahran or @MuhammadAbdelsalam can provide me with an example?
Something like for example this Clear() test would be great as a reusable example.
JsonReaderException: Additional text encountered after finished reading JSON content: c. Path '', line 1, position 2.
using (var storage = new LocalStorage())
it worked fine but when used .Clear() it crashed, also I used the new release v2.0.0-beta-2 but nothing