[Mono-bugs] [Bug 410693] New: Color: equals (and equality operator) not correct for MS deserialized known color

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Sat Jul 19 14:33:56 EDT 2008


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


           Summary: Color: equals (and equality operator) not correct for MS
                    deserialized known color
           Product: Mono: Class Libraries
           Version: SVN
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Sys.Drawing.
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: gert.driesen at pandora.be
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


In case of a known color deserialized from MS, the value field is lazy
initialized in the A/R/G/B properties. However, when checking equality before
accessing any of these properties the result is not correct.

To reproduce, compile and run the following code:

using System;
using System.Drawing;
using System.IO;
using System.Reflection;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;

class Program
{
        static int Main ()
        {
                Color c;
                MemoryStream ms = new MemoryStream ();
                BinaryFormatter formatter = new BinaryFormatter ();

                ms.Write (_serializedV11, 0, _serializedV11.Length);
                ms.Position = 0;

                c = (Color) formatter.Deserialize (ms);
                if (c != Color.Green) {
                        Console.WriteLine (c + " != " + Color.Green);
                        return 1;
                }

                return 0;
        }

        static byte [] _serializedV11 = {
                0x00, 0x01, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x01,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x02, 0x00,
                0x00, 0x00, 0x54, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e,
                0x44, 0x72, 0x61, 0x77, 0x69, 0x6e, 0x67, 0x2c, 0x20, 0x56,
                0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x3d, 0x31, 0x2e, 0x30,
                0x2e, 0x35, 0x30, 0x30, 0x30, 0x2e, 0x30, 0x2c, 0x20, 0x43,
                0x75, 0x6c, 0x74, 0x75, 0x72, 0x65, 0x3d, 0x6e, 0x65, 0x75,
                0x74, 0x72, 0x61, 0x6c, 0x2c, 0x20, 0x50, 0x75, 0x62, 0x6c,
                0x69, 0x63, 0x4b, 0x65, 0x79, 0x54, 0x6f, 0x6b, 0x65, 0x6e,
                0x3d, 0x62, 0x30, 0x33, 0x66, 0x35, 0x66, 0x37, 0x66, 0x31,
                0x31, 0x64, 0x35, 0x30, 0x61, 0x33, 0x61, 0x05, 0x01, 0x00,
                0x00, 0x00, 0x14, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e,
                0x44, 0x72, 0x61, 0x77, 0x69, 0x6e, 0x67, 0x2e, 0x43, 0x6f,
                0x6c, 0x6f, 0x72, 0x04, 0x00, 0x00, 0x00, 0x05, 0x76, 0x61,
                0x6c, 0x75, 0x65, 0x0a, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x43,
                0x6f, 0x6c, 0x6f, 0x72, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65,
                0x04, 0x6e, 0x61, 0x6d, 0x65, 0x00, 0x00, 0x00, 0x01, 0x09,
                0x07, 0x07, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x4f, 0x00, 0x01, 0x00, 0x0a, 0x0b };
}

Expected result:

No output on console, and exit code 0.

Actual result:

Color [Green] != Color [Green]
and exit code 1


-- 
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