Added Range Manipulation APIs to Collection<T> and ObservableCollection<T>#23018
Conversation
…p to ObservableCollection<T>. AddRange, InsertRange, RemoveRange and Replace Range
|
Based on https://github.com/dotnet/corefx/issues/10752#issuecomment-428312248, you are missing |
src/System.Private.CoreLib/shared/System/Collections/ObjectModel/Collection.cs
Outdated
Show resolved
Hide resolved
src/System.Private.CoreLib/shared/System/Collections/ObjectModel/Collection.cs
Outdated
Show resolved
Hide resolved
src/System.Private.CoreLib/shared/System/Collections/ObjectModel/Collection.cs
Outdated
Show resolved
Hide resolved
src/System.Private.CoreLib/shared/System/Collections/ObjectModel/Collection.cs
Outdated
Show resolved
Hide resolved
src/System.Private.CoreLib/shared/System/Collections/ObjectModel/Collection.cs
Outdated
Show resolved
Hide resolved
Thanks for pointing this out, I was going off the update at the top and missed this API. I'll get this added in the next update and include tests in the associated PR for CoreFX |
src/System.Private.CoreLib/shared/System/Collections/ObjectModel/Collection.cs
Outdated
Show resolved
Hide resolved
src/System.Private.CoreLib/shared/System/Collections/ObjectModel/Collection.cs
Outdated
Show resolved
Hide resolved
src/System.Private.CoreLib/shared/System/Collections/ObjectModel/Collection.cs
Outdated
Show resolved
Hide resolved
src/System.Private.CoreLib/shared/System/Collections/ObjectModel/Collection.cs
Show resolved
Hide resolved
src/System.Private.CoreLib/shared/System/Collections/ObjectModel/Collection.cs
Outdated
Show resolved
Hide resolved
src/System.Private.CoreLib/shared/System/Collections/ObjectModel/Collection.cs
Outdated
Show resolved
Hide resolved
src/System.Private.CoreLib/shared/System/Collections/ObjectModel/Collection.cs
Outdated
Show resolved
Hide resolved
…nt is less than 0
… because the array changes with each iteration of the for loop and will cause side-effects which may include index out of range exceptions. This needs to be index because as the array shrinks the index is always at the correct position.
…n checks that happen using the RemoveAt API. RemoveItem gives us direct access to invoke the command
…ance improvements. If the underlying `items` is using List<T> we should use it's InsertRange method since it is optimized, othersie we use InsertItem
…(index + count) > items.Count and if it is true throw ArgumentException
src/System.Private.CoreLib/shared/System/Collections/ObjectModel/Collection.cs
Outdated
Show resolved
Hide resolved
…or overflow errors
…rst then collection == null
ahsonkhan
left a comment
There was a problem hiding this comment.
Some leftover comments. Otherwise, LGTM.
src/System.Private.CoreLib/shared/System/Collections/ObjectModel/Collection.cs
Outdated
Show resolved
Hide resolved
src/System.Private.CoreLib/shared/System/Collections/ObjectModel/Collection.cs
Outdated
Show resolved
Hide resolved
safern
left a comment
There was a problem hiding this comment.
LGTM once @ahsonkhan's last comments are solved.
src/System.Private.CoreLib/shared/System/Collections/ObjectModel/Collection.cs
Show resolved
Hide resolved
…is of type List<T>
|
Thanks @ahoefling now we can move to corefx's PR once CoreCLR flows there 😄 |
|
@safern Try to hit squash & merge next time ... I know it is easy to press the wrong button by accident. |
Yeah I just realized I rebased and merge. Sorry about that, my default was "Squash and merge" I don't know how it was changed 😭 |
Added Range Manipulation APIs to Collection and ObservableCollection.
Part of : dotnet/corefx#10752 - migrated to: dotnet/runtime#18087
Part of: dotnet/corefx#35772
Added the following new API that was approved:
Looking forward to everyone's feedback on this