This commit is contained in:
forest93 2018-03-09 20:24:23 +08:00
parent 969b8b86a6
commit 53ab54d7b1
1 changed files with 3 additions and 1 deletions

View File

@ -1272,7 +1272,9 @@ namespace SimpleJson
internal virtual ReflectionUtils.ConstructorDelegate ContructorDelegateFactory(Type key)
{
return ReflectionUtils.GetContructor(key, key.IsArray ? ArrayConstructorParameterTypes : EmptyTypes);
// We need List<T>(int) constructor so that DeserializeObject method will work for generating IList-declared values
var needsCapacityArgument = key.IsArray || key.IsConstructedGenericType && key.GetGenericTypeDefinition() == typeof(List<>);
return ReflectionUtils.GetContructor(key, needsCapacityArgument ? ArrayConstructorParameterTypes : EmptyTypes);
}
internal virtual IDictionary<string, ReflectionUtils.GetDelegate> GetterValueFactory(Type type)