Bug in the PropertyDescriptorEnumerator

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
 
D

Dominique

foreach(IDictionaryEntry entry in entries)
(with entries being an PropertyDescriptorCollection)

entries is actually the IDictionary of a
PropertyDescriptorCollection
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top