Opened 2 years ago

Closed 22 months ago

#2575 closed defect (done)

ObservableList's AddRange enumerates multiple times

Reported by: abeham Owned by: abeham
Priority: medium Milestone: HeuristicLab 3.3.14
Component: Collections Version: 3.3.13
Keywords: Cc:


It enumerates it a total of three times which may produce three different collections.

    public void AddRange(IEnumerable<T> collection) {
      int capacity = list.Capacity;
      int index = list.Count;
      list.AddRange(collection); // HERE
      List<IndexedItem<T>> items = new List<IndexedItem<T>>();
      foreach (T item in collection) { // HERE
        items.Add(new IndexedItem<T>(index, item));
      if (items.Count > 0) {
        OnItemsAdded(collection); // HERE
        if (list.Capacity != capacity)

Change History (4)

comment:1 Changed 2 years ago by abeham

  • Owner set to abeham
  • Status changed from new to accepted

r13597: fixed multiple enumeration of collection in ObservableCollection and ObservableList

comment:2 Changed 2 years ago by abeham

  • Owner changed from abeham to mkommend
  • Status changed from accepted to reviewing

comment:3 Changed 2 years ago by mkommend

  • Owner changed from mkommend to abeham
  • Status changed from reviewing to readytorelease

Reviewed r13597.

comment:4 Changed 22 months ago by mkommend

  • Resolution set to done
  • Status changed from readytorelease to closed

r13886: Merged r13597 into stable.

Note: See TracTickets for help on using tickets.