Some events in Collection<T> are triggered to early
Issue #42
resolved
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)
-
repo owner -
reporter We need at some places to listen to those events manually and rely on the count value which is always the old count.
-
repo owner Okay, thanks for the info. I will consider to change it.
-
repo owner - changed status to resolved
Alright, changed it, so that the count is updated before the events are triggered.
-
repo owner - removed milestone
Removing milestone: 1.0.9 (automated comment)
- Log in to comment
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.