[Mono-bugs] [Bug 491858] Iterator implementation for generics is incompatible with MS implementation

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Fri Apr 3 11:09:34 EDT 2009


http://bugzilla.novell.com/show_bug.cgi?id=491858

User jpryor at novell.com added comment
http://bugzilla.novell.com/show_bug.cgi?id=491858#c2


Jonathan Pryor <jpryor at novell.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jpryor at novell.com




--- Comment #2 from Jonathan Pryor <jpryor at novell.com>  2009-04-03 09:09:34 MDT ---
I believe .NET is broken here, not Mono.

>From http://msdn.microsoft.com/en-us/library/78dfe2yb.aspx?ppud=4:

    Initially, the enumerator is positioned before the first element in the 
    collection. At this position, Current is undefined. Therefore, you must 
    call MoveNext to advance the enumerator to the first element of the 
    collection before reading the value of Current. 

Which is exactly what you're doing -- calling .Current *before* calling
MoveNext().  The value .Current is undefined here, so an exception is
perfectly reasonable.

Then there's the non-generic documentation:
http://msdn.microsoft.com/en-us/library/system.collections.ienumerator.aspx

    Initially, the enumerator is positioned before the first element in the 
    collection. The Reset method also brings the enumerator back to this 
    position. At this position, calling the Current property throws an 
    exception. Therefore, you must call the MoveNext method to advance the 
    enumerator to the first element of the collection before reading the value 
    of Current. 

It seems somewhat odd that the documentation implies that the non-generic
Current property should throw an exception while accessing the generic
Current property results in undefined behavior, but I believe that "undefined"
provides enough wiggle room for Mono to be conforming to the documentation.

In short, Don't Do That.

-- 
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


More information about the mono-bugs mailing list