Does anybody know why the NetDataContractSerializer might add "nil" entries in a serialized collection?
For example,
<Jobs z:Id="17">
<_items z:Id="18" z:Size="4">
<JobRecord z:Id="19">
<Name z:Id="20">Job1</Name>
</JobRecord>
<JobRecord i:nil="true" />
<JobRecord i:nil="true" />
<JobRecord i:nil="true" />
</_items>
<_size>1</_size>
<_version>2</_version>
</Jobs>
Notice the three extra "JobRecord" entries and the additional element saying "hey, I know there are four nodes here, but only one of them means anything."
It seems like an odd behavior. Okay, so I could see that the NDCS peers deeply into the object graph and might be twiddling with a backing array that has a size that is greater than the number of items being serialized (think of the backing array for a List).
Is that what's going on here? Is it an artifact of the class the constructor creates to handle yield return
(which is the source of the JobRecord)?