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

Status : 

  Fixed<br /><br />
		This item has been fixed in the current or upcoming version of this product.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.


0
0
Sign in
to vote
ID 384059 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 11/25/2008 10:51:55 PM
Access Restriction Public

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. 

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