[Mono-bugs] [Bug 521750] New: SortedList: IComparer.Compare arguments are reversed

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Mon Jul 13 17:57:37 EDT 2009


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


           Summary: SortedList: IComparer.Compare arguments are reversed
    Classification: Mono
           Product: Mono: Class Libraries
           Version: SVN
          Platform: i386
        OS/Version: Ubuntu
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: System
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: kevin at kevinfitzgerald.net
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


Created an attachment (id=304829)
 --> (http://bugzilla.novell.com/attachment.cgi?id=304829)
Patch to fix the SortedList problem

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.6)
Gecko/2009011913 Firefox/3.0.6 (.NET CLR 3.5.30729)

The arguments in the IComparer.Compare() call in the internal Find method of
the SortedList class are reversed. 

In its current state, the comparison works for maybe 98% of the applications
that use the SortedList object.

This reversal is only noticeable when used by custom IComparer classes, which
depend on the order of the parameters.

Attached is a patch for the fix. I have also written a set of unit tests which
pass on both Microsoft's platform as well as Mono on Linux.

Reproducible: Always

Steps to Reproduce:
See the attached test case below
Actual Results:  
Below is a snippet from the results of the unit test pre-patch. The main thing
to note is the first "Comparing" line. Notice how part='Whole' and
whole='Part'.

-------------------------------------
 ***** SortedListTest.ComparatorPartWholeCheck ***** 
Comparing part='Whole', whole='Part'

.. continued, see the attached results files below...
-------------------------------------

Expected Results:  
Below is a snippet from the results of the unit test post-patch. 

--------------------------------------
 ***** SortedListTest.ComparatorPartWholeCheck ***** 
Comparing part='Part', whole='Whole'

.. continued, see the attached results files below...
-------------------------------------

Fixing this issue may affect or break code that was written that works against
the current implementation. Anyone who figured that read the documentation
wrong and simply reversed the usage of the arguments in their own custom
IComparer objects may have unexpected results with this fix.

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


More information about the mono-bugs mailing list