Open logiclrd opened 6 years ago
So... I did fill in the CLA, I thought @dnfclas was supposed to replace the cla-required
label with cla-signed
? I went through the "working on behalf of my employer" flow, though, so maybe that requires manual attention...
All CLA requirements met now. Check out the statuses. We are currently migrating to new CLA system which uses status instead of labels. :)
Ahh, okay :-) Cool beans, then.
Ping!
After encountering errors doing model binding to array types, I investigated the root cause and decided to fix it. It looks like JsonNetBodyDeserializer.cs creates a separate instance of the target type from that created during deserialization, and then manually copies properties over in order to support blacklisting of properties (a Nancy feature not directly integrated with Newtonsoft.Json). As part of this, JsonNetBodyDeserializer.cs assumes that it can use
Activator.CreateInstance
on the destination type. This does not work for arrays, as they do not have a parameterless constructor. The approach I took, since the deserialization is going to require the use of aList<T>
anyway, is to leverage the existingList<T>
deserialization, and then if the destination type is actuallyT[]
, callList<T>
'sToArray
method before returning the final value.Prerequisites
Description
ToArray
, I generate dynamic method specializations to perform the call toList<T>.ToArray
, and I set up a simple cache of delegates referring to these methods.CreateObjectWithBlacklistExcluded
detects an array typeT[]
, a new methodConvertArray
is called which retrieves this converter from the cache (constructing it if necessary) and applies it to the result ofConvertCollection
onList<T>
.CreateObjectWithBlacklistExcluded
is altered so thatActivator.CreateInstance
is not called on the destination type in this circumstance.