[Mono-list] Bug in Mono's String.CompareOrdinal

Rhys Weatherley rweather@zip.com.au
Sun, 12 Jan 2003 09:36:30 +1000

Came across this one while trying to figure out why pnet-compiled switch 
statements using strings didn't work with mono's runtime.  It is related to 
some Qt# interoperability issues.

The following program gives -1 under Mono, even though 'a' is greater than 'A' 
from an ordinal point of view (0x0061 > 0x0041).  Pnet gives 1, and MS gives 
32 (any positive value is acceptable as an answer).

The reason why this breaks interoperability is because pnet uses 
"String.CompareOrdinal" to build a binary search tree for switch statements 
that use string arguments rather than use cascading ifs on intern'ed strings 
like csc and mcs.

I tested this with Mono 0.17.

using System;

class Test
    public static void Main()
        Console.WriteLine("Answer should be positive: {0}",
                          String.CompareOrdinal("a", "A"));