Some events in Collection<T> are triggered to early

Issue #42 resolved
Rainer Bernhardt created an issue

In the Collection<T> class, some (or all) events about the collection update are called before "this.UpdateCount();" is executed.

Is saw no sideeffect moving this line above the events.

example:

public void Insert(int index, T item)
        {
            this.items.Insert(index, item);
            this.OnItemInserted(item, index);
            this.UpdateCount();
        }

To

public void Insert(int index, T item)
        {
            this.items.Insert(index, item);
            this.UpdateCount();
            this.OnItemInserted(item, index);

        }

Comments (5)

  1. Christian Oeing repo owner

    Hi Rainer! Is there any bug that occurs because UpdateCount is called after e.g. OnItemInserted? If not I wouldn't change it as it seems correct in both ways.

  2. Rainer Bernhardt reporter

    We need at some places to listen to those events manually and rely on the count value which is always the old count.

  3. Log in to comment