You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Debug] IndexOutOfRangeException when extension data doesn't have two generic parameters #33011
From @alanisaac in #32952 (comment). This issue exists only in debug mode. The fix could look like this. We'll need tests for dictionary types with 0, 1, and 3 generic parameters.
I've added additional collection classes and tests for these cases.
When trying to test for these cases I noticed that classes that implement IDictionary<TKey, TValue> but do not have two generic type parameters end up throwing IndexOutOfRangeException on de-serialization when marked with [JsonExtensionData]. Should this also be a NotSupportedException instead?
For example, by using the StringToGenericIDictionaryWrapper<TValue> class already in this test project, the following simple test will reproduce the IndexOutOfRangeException:
[Fact]
public static void DeserializeIntoSingleGenericDictionary()
{
JsonSerializer.Deserialize<ClassWithExtensionPropertyStringToGeneric>("{\"hello\":\"world\"}");
}
private class ClassWithExtensionPropertyStringToGeneric
{
[JsonExtensionData]
public StringToGenericIDictionaryWrapper<object> MyOverflow { get; set; }
}
Activity
layomia commentedon Mar 2, 2020
Closed in #33014.