[Mono-bugs] [Bug 371559] Enum.ToString doesn't recognize negative member in Flags ( GetValue ordering)

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Mon Mar 17 04:55:57 EDT 2008


https://bugzilla.novell.com/show_bug.cgi?id=371559

User andyhume32 at yahoo.co.uk added comment
https://bugzilla.novell.com/show_bug.cgi?id=371559#c1


Andy Hume <andyhume32 at yahoo.co.uk> changed:

           What    |Removed                                         |Added
----------------------------------------------------------------------------
            Summary|Enum.ToString doesn't recognize all members when|Enum.ToString doesn't recognize negative member
                   |overlapping Flags                               |in Flags (GetValue ordering)




--- Comment #1 from Andy Hume <andyhume32 at yahoo.co.uk>  2008-03-17 02:55:57 MST ---
That'll teach me to speculate!  Of course FormatFlags uses the array in reverse
order so that's fine.

In writing another test case I found that the problem only occures when the
member is 'negative'.  So the actual difference is that MSFT's Enum.GetValues
orders the members as unsigned even when the underlying type is int.  See the
following.  Perhaps that's what's being implied by "binary values" in that
Enum.GetValues MSDN quote above.

Mono:
[[
Bb    = FFFF0000
Dd    = FFFFFFFF
Cc    = 00000000
Aa    = 00000005
Ff    = 00000064
Ee    = 7FFFFFFF
]]

MSFT:
[[
Cc    = 00000000
Aa    = 00000005
Ff    = 00000064
Ee    = 7FFFFFFF
Bb    = FFFF0000
Dd    = FFFFFFFF
]]

Code:
[[
using System;

enum OrderingEnumNoFlags
{
  Aa = 5,
  Bb = unchecked((int)0xFFFF0000),
  Cc = 0,
  Dd = -1,
  Ee = 0x7FFFFFFF,
  Ff = 100
}

[Flags]
enum OrderingEnumFlags
{
  Aa = 5,
  Bb = unchecked((int)0xFFFF0000),
  Cc = 0,
  Dd = -1,
  Ee = 0x7FFFFFFF,
  Ff = 100
}


class EnumGetValuesSignedOrderTest
{
    static void Main()
    {
        DumpAllEnumMembers(typeof(OrderingEnumNoFlags));
        //DumpAllEnumMembers(typeof(OrderingEnumFlags));
    }

    static void DumpAllEnumMembers(Type enumType)
    {
        Console.WriteLine("* {0}", enumType.Name);
        foreach(object cur in Enum.GetValues(enumType)){
            Console.WriteLine("{0,-5} = {0:X}", cur);
        }
    }
}
]]


-- 
Configure bugmail: https://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