[5.1.1 MyGet] Failed to deserialize empty array

We are currently receiving the following exception while trying to Deserialize a Json containing an empty int array:

    System.Runtime.Serialization.SerializationException: Failed to set property 'areeAnaliticheId' with '[]' ---> System.FormatException: Input string was not in a correct format.
       in ServiceStack.Text.SignedInteger`1.ParseInt64(ReadOnlySpan`1 value)
   in ServiceStack.Text.DefaultMemory.ParseInt32(ReadOnlySpan`1 value)
   in ServiceStack.Text.Common.DeserializeListWithElements`1.ParseIntList(ReadOnlySpan`1 value)
   in ServiceStack.Text.Common.DeserializeTypeRefJson.StringToType(ReadOnlySpan`1 strType, TypeConfig typeConfig, EmptyCtorDelegate ctorFn, KeyValuePair`2[] typeAccessors)
   --- Fine della traccia dello stack dell'eccezione interna ---
   in ServiceStack.Text.Common.DeserializeTypeRefJson.StringToType(ReadOnlySpan`1 strType, TypeConfig typeConfig, EmptyCtorDelegate ctorFn, KeyValuePair`2[] typeAccessors)
   in ServiceStack.Text.Common.DeserializeType`1.StringToTypeContext.DeserializeJson(ReadOnlySpan`1 value)
   in ServiceStack.Text.Json.JsonReader`1.Parse(ReadOnlySpan`1 value)
   in ServiceStack.Text.Json.JsonReader`1.Parse(String value)
   in ServiceStack.Text.JsonSerializer.DeserializeFromString[T](String value)
   in LabReboot.ServiceInterface.Services.DashboardPreferitiService.<Get>d__2.MoveNext() in C:\Git\LabReboot\LabReboot\LabReboot.ServiceInterface\Services\DashboardPreferitiService.cs:riga 44
--- Fine traccia dello stack da posizione precedente dove è stata generata l'eccezione ---
   in System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   in System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   in ServiceStack.Host.ServiceRunner`1.<ExecuteAsync>d__13.MoveNext()

The Json contains a property areeAnaliticheId with the value []. This works on 5.1.0.

I’m unable to repro this issue:

public class EmptyCollections
{
    public string[] Strings { get; set; }
    public int[] Ints { get; set; }
}

[Test]
public void Can_deserialize_empty_array()
{
    Assert.That("[]".FromJson<string[]>(), Is.EquivalentTo(new string[0]));
    Assert.That("[]".FromJson<int[]>(), Is.EquivalentTo(new int[0]));
    
    Assert.That("{\"Strings\":[]}".FromJson<EmptyCollections>().Strings, Is.EquivalentTo(new string[0]));
    Assert.That("{\"Ints\":[]}".FromJson<EmptyCollections>().Ints, Is.EquivalentTo(new int[0]));
}

Please provide a stand-alone repro I can run. If this test fails for you, you have an old version and will need to clear your NuGet cache to install the latest version.

Actually, it works if my DTO uses int[], while it crashes when i change it to List<int> or IEnumerable<int> or basically any type different from array.

Can you verify that? List<int> works with no issues in 5.1.0.

EDIT: I had cleared all nuget cache as usual when working with MyGet releases.

Should now be resolved with this commit. This change is available from v5.1.1 that’s now on MyGet.