Home Dashboard Directory Help
Search

OrderedDictionary enumerator doesn't throw InvalidOperationException after collection was changed by Alexander Sofronov


Status: 

Closed
 as Fixed Help for as Fixed


0
0
Sign in
to vote
Type: Bug
ID: 384059
Opened: 11/25/2008 10:51:55 PM
Access Restriction: Public
0
Workaround(s)
view
0
User(s) can reproduce this bug

Description

OrderedDictionary enumerator doesn't track the changes in the collection, so if I create an enumerator for OrderedDictionary, modify the collection and use the enumerator, InvalidOperationException is not thrown.

MSDN states the following about IEnumerator interface:
An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and the next call to MoveNext or Reset throws an InvalidOperationException.

Details
Sign in to post a comment.
Posted by Microsoft on 4/17/2009 at 4:59 PM
Hi Alexander,
Thanks for reporting this issue! You're correct that OrderedDictionary's enumerator currently doesn't throw an InvalidOperationException if the collection is modified while enumerating and because of this, the OrderedDictionary enumerator doesn't comply with the IEnumerator contract.

The fix will be available in the next major release of the framework.

Thanks again!
Kim Hamilton
Base Class Libraries
Posted by Microsoft on 11/26/2008 at 5:10 PM
Thanks for your feedback. We are escalating this bug to the product unit who works on that specific feature area. The team will review this issue and make a decision on whether they will fix it or not for the next release.

Thank you,
Visual Studio Product Team
Sign in to post a workaround.