Bug in the PropertyDescriptorEnumerator

  • Thread starter Thread starter Dominique
  • Start date Start date
D

Dominique

Hi,

I found a bug in PropertyDescriptorEnumerator and I don't
know were to report it, so I do it here hoping that
someone from Microsoft will read it.

This C# statement

foreach(IDictionaryEntry entry in entries)

(with entries being an PropertyDescriptorCollection)
always miss the first entry in my collection so I changed
it to

IDictionaryEnumerator iter = entries.GetEnumerator();

while(iter.MoveNext())
{

and i noticed in the debugger that iter.Current was on
the first item after GetEnumerator but moved to the
second after the first to MoveNext.

Then I opened Reflector and looked at the code of
PropertyDescriptorEnumerator and noticed that index was
initialized with 0 (actually index is not initialized).
This is not right, index should be initialize to -1.

For now I will use

foreach(object key in collection.Keys)

which works as expected, and hopefully this will be fix
in the .NET Framework 2.0
 
foreach(IDictionaryEntry entry in entries)
(with entries being an PropertyDescriptorCollection)

entries is actually the IDictionary of a
PropertyDescriptorCollection
 
Back
Top