rpgmaker / NetJSON

Faster than Any Binary? Benchmark: http://theburningmonk.com/2014/08/json-serializers-benchmarks-updated-2/
MIT License
225 stars 29 forks source link

Deserialisation of Guid[] fails #209

Closed ghost closed 5 years ago

ghost commented 5 years ago

Deserialising a collection/array of Guids results in System.FormatException: 'Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).'.

Failing test as follows:

private static readonly NetJSONSettings Settings = new NetJSONSettings{ DateFormat = NetJSONDateFormat.ISO, TimeZoneFormat = NetJSONTimeZoneFormat.Utc };
[TestMethod]
public void HandlesGuids()
{
    var value = Guid.NewGuid();
    var serialised = NetJSON.NetJSON.Serialize(value, Settings);
    var deserialised = NetJSON.NetJSON.Deserialize<Guid>(serialised, Settings);
    Assert.AreEqual(value, deserialised);

    var values = new [] { Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid() };
    serialised = NetJSON.NetJSON.Serialize(values, Settings);
    var deserialisedArray = NetJSON.NetJSON.Deserialize<IEnumerable<Guid>>(serialised, Settings); // Fails
}

And stack trace:

   at System.Guid.GuidResult.SetFailure(ParseFailureKind failure, String failureMessageID, Object failureMessageFormatArgument, String failureArgumentName, Exception innerException)
   at System.Guid.TryParseGuidWithNoStyle(ReadOnlySpan`1 guidString, GuidResult& result)
   at System.Guid.TryParseGuid(ReadOnlySpan`1 guidString, GuidStyles flags, GuidResult& result)
   at System.Guid..ctor(String g)
   at CreateListIEnumerableGuid(Char* , Int32& , NetJSONSettings )
   at ReadIEnumerableGuid(String , NetJSONSettings )
rpgmaker commented 5 years ago

Thanks for the find. I will look into it

rpgmaker commented 5 years ago

Sorry been busy with other things that came up. I will look at it soon and get back to you.

rpgmaker commented 5 years ago

I am back now. I will take a look at all the items you submitted this weekend. Thanks

rpgmaker commented 5 years ago

Please test and let me know. Thanks