I discovered this while using ObvervableList.AddRange(IEnumerable<T> items), which uses CloneCollection to turn the IEnumerable into a known-length collection as efficiently as possible.
In CloneCollection there is a bug inside the filling loop when it calls TryEnsureCapacity(ref array, i) on the array being filled.
HereTryEnsureCapacity() allocates a larger array without copying the old array items into the new one. As a result, the previous array contents are lost and are null in the final result.
Workaround: it works if I call ToArray() on my IEnumerable so that it will call ObservableList.AddRange(T[] items) instead.
I discovered this while using
ObvervableList.AddRange(IEnumerable<T> items)
, which usesCloneCollection
to turn theIEnumerable
into a known-length collection as efficiently as possible.In
CloneCollection
there is a bug inside the filling loop when it callsTryEnsureCapacity(ref array, i)
on the array being filled.Here
TryEnsureCapacity()
allocates a larger array without copying the old array items into the new one. As a result, the previous array contents are lost and are null in the final result.Workaround: it works if I call
ToArray()
on myIEnumerable
so that it will callObservableList.AddRange(T[] items)
instead.