Skip to content
This repository has been archived by the owner on Sep 13, 2022. It is now read-only.

Collection<T> and ObservableCollection<T> do not support ranges #1091

Closed
ChaseFlorell opened this issue Feb 27, 2019 · 6 comments · Fixed by #1175
Closed

Collection<T> and ObservableCollection<T> do not support ranges #1091

ChaseFlorell opened this issue Feb 27, 2019 · 6 comments · Fixed by #1175
Labels
netstandard-api This tracks requests for standardizing APIs.

Comments

@ChaseFlorell
Copy link

This is taken directly from https://github.com/dotnet/corefx/issues/10752 [by @robertmclaws]

This API change is already approved in .netcore (tentatively scheduled for 3.0), and I think it's equally as important to be available in .netstandard

    // Adds a range to the end of the collection.
    // Raises CollectionChanged (NotifyCollectionChangedAction.Add)
    public void AddRange(IEnumerable<T> collection) => InsertItemsRange(0, collection);

    // Inserts a range
    // Raises CollectionChanged (NotifyCollectionChangedAction.Add)
    public void InsertRange(int index, IEnumerable<T> collection) => InsertItemsRange(index, collection);

    // Removes a range.
    // Raises CollectionChanged (NotifyCollectionChangedAction.Remove)
    public void RemoveRange(int index, int count) => RemoveItemsRange(index, count);

    // Will allow to replace a range with fewer, equal, or more items.
    // Raises CollectionChanged (NotifyCollectionChangedAction.Replace)
    public void ReplaceRange(int index, int count, IEnumerable<T> collection)
    {
         RemoveItemsRange(index, count);
         InsertItemsRange(index, collection);
    }

    #region virtual methods
    protected virtual void InsertItemsRange(int index, IEnumerable<T> collection);
    protected virtual void RemoveItemsRange(int index, int count);
    #endregion

Please see the linked issue for the full discussion.

I'm assuming it would land here and the appropriate shims would be created, however I don't know enough about netstandard to actually draw up the PR.

@jamesmontemagno
Copy link
Member

I'm so into this! @terrajobst please please please please

@SkyeHoefling
Copy link

I just created an issue on the mono project so we get it added there as well. mono/mono#13265

@terrajobst
Copy link
Member

If this makes it into. NET Core soon, we can add it here.

@terrajobst terrajobst added the netstandard-api This tracks requests for standardizing APIs. label Mar 8, 2019
@terrajobst terrajobst added this to the .NET Standard 2.1 milestone Mar 8, 2019
@SkyeHoefling
Copy link

@terrajobst the .NET Core PR dotnet/corefx#35772 has been merged which was the last remaining outstanding work to get this feature into .NET Core.

What do we need to do to get this into .NET Strandard

terrajobst added a commit to terrajobst/standard that referenced this issue May 2, 2019
terrajobst added a commit to terrajobst/standard that referenced this issue May 2, 2019
@terrajobst
Copy link
Member

terrajobst commented May 2, 2019

What do we need to do to get this into .NET Strandard

Nothing. I just submitted the PR. Members are by default included in the next version of the standard.

@SkyeHoefling
Copy link

Such great news! Thanks @terrajobst

terrajobst added a commit to terrajobst/standard that referenced this issue May 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
netstandard-api This tracks requests for standardizing APIs.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants