[Mono-bugs] [Bug 340917] New: ColorTranslator: ToHtml and FromHtml aren't 100% inverse

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Sun Nov 11 10:04:32 EST 2007


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

           Summary: ColorTranslator: ToHtml and FromHtml aren't 100% inverse
           Product: Mono: Class Libraries
           Version: 1.2
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Sys.Drawing.
        AssignedTo: mono-bugs at ximian.com
        ReportedBy: daniel at hofmannmail.ath.cx
         QAContact: mono-bugs at ximian.com
          Found By: ---


Created an attachment (id=182936)
 --> (https://bugzilla.novell.com/attachment.cgi?id=182936)
compile with "-r:System.Drawing"

On rev98406 I'm constantly getting an exception from the statement

ColorTranslator.FromHtml(ColorTranslator.ToHtml(Color.LightGray));

Unhandled Exception: System.Exception: Invalid color name 'LightGrey'. --->
System.FormatException: Invalid color name 'LightGrey'. --->
System.ArgumentException: The requested value 'LightGrey' was not found --->
System.FormatException: Input string was not in the correct format
  at System.Int32.Parse (System.String s, NumberStyles style, IFormatProvider
fp) [0x00016] in /home/dani/src/mono/mcs/class/corlib/System/Int32.cs:599 
  at System.Int32.Parse (System.String s, IFormatProvider fp) [0x00000] in
/home/dani/src/mono/mcs/class/corlib/System/Int32.cs:208 
  at System.Convert.ToInt32 (System.String value, IFormatProvider provider)
[0x00008] in /home/dani/src/mono/mcs/class/corlib/System/Convert.cs:1269 
  at System.String.System.IConvertible.ToInt32 (IFormatProvider provider)
[0x00000] in /home/dani/src/mono/mcs/class/corlib/System/String.cs:1874 
  at System.Convert.ToType (System.Object value, System.Type conversionType,
IFormatProvider provider) [0x00139] in
/home/dani/src/mono/mcs/class/corlib/System/Convert.cs:2891 
  at System.Convert.ChangeType (System.Object value, TypeCode typeCode)
[0x00031] in /home/dani/src/mono/mcs/class/corlib/System/Convert.cs:2496 
  at System.Enum.Parse (System.Type enumType, System.String value, Boolean
ignoreCase) [0x00129] in
/home/dani/src/mono/mcs/class/corlib/System/Enum.cs:370 --- End of inner
exception stack trace ---

  at System.Enum.Parse (System.Type enumType, System.String value, Boolean
ignoreCase) [0x00144] in
/home/dani/src/mono/mcs/class/corlib/System/Enum.cs:372 
  at System.Drawing.ColorConverter.StaticConvertFromString
(ITypeDescriptorContext context, System.String s,
System.Globalization.CultureInfo culture) [0x00037] in
/home/dani/src/mono/mcs/class/System.Drawing/System.Drawing/ColorConverter.cs:77
--- End of inner exception stack trace ---
--- End of inner exception stack trace ---

  at System.Drawing.ColorConverter.StaticConvertFromString
(ITypeDescriptorContext context, System.String s,
System.Globalization.CultureInfo culture) [0x0006a] in
/home/dani/src/mono/mcs/class/System.Drawing/System.Drawing/ColorConverter.cs:82 
  at System.Drawing.ColorConverter.ConvertFrom (ITypeDescriptorContext context,
System.Globalization.CultureInfo culture, System.Object value) [0x00017] in
/home/dani/src/mono/mcs/class/System.Drawing/System.Drawing/ColorConverter.cs:171 
  at System.ComponentModel.TypeConverter.ConvertFrom (System.Object o)
[0x00000] in
/home/dani/src/mono/mcs/class/System/System.ComponentModel/TypeConverter.cs:70 
  at System.ComponentModel.TypeConverter.ConvertFromString (System.String text)
[0x00000] in
/home/dani/src/mono/mcs/class/System/System.ComponentModel/TypeConverter.cs:94 
  at System.Drawing.ColorTranslator.FromHtml (System.String htmlColor)
[0x000a7] in
/home/dani/src/mono/mcs/class/System.Drawing/System.Drawing/ColorTranslator.cs:63 
  at GreyHTML.Main () [0x00000] in /tmp/GreyHTML.cs:8


Most probably it's FromHTML's fault, which seems to literally compare the
string with the enum entries and therefore not considering, that
Color.LightGray has been mapped to "LightGrey" (according to html)

The funny thing about it is, that the Problem doesn't exist for Color.Gray and
Color.DarkGray, because here Html uses the american-english spelling which
matches the enum field names.


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