Expose IReadOnlyList<T> instead of IEnumerable<T> for PolyLine.Vertices
This change allows external methods to index or operate on the vertices
without consuming additional memory by using ToList() or ToArray() or enumerating the entire collection
multiple times. This change still ensures that the internal list is immutable.
I don't think this is a breaking changes because IReadOnlyList<T> implements IEnumerable<T>, so anything that relies on IEnumerable<T> will still work.
This is implemented by using ReadOnlyCollection<T> internally instead of List<T>.
I think the same change would be appropriate for Polygon2D too but I'm not sure if there was a specific reason for using a custom implementation of ImmutableList<T> instead of ReadOnlyCollection<T>.
Expose
IReadOnlyList<T>
instead ofIEnumerable<T>
forPolyLine.Vertices
This change allows external methods to index or operate on the vertices without consuming additional memory by using
ToList()
orToArray()
or enumerating the entire collection multiple times. This change still ensures that the internal list is immutable.I don't think this is a breaking changes because
IReadOnlyList<T>
implementsIEnumerable<T>
, so anything that relies onIEnumerable<T>
will still work.This is implemented by using
ReadOnlyCollection<T>
internally instead ofList<T>
.I think the same change would be appropriate for
Polygon2D
too but I'm not sure if there was a specific reason for using a custom implementation ofImmutableList<T>
instead ofReadOnlyCollection<T>
.