Some corrected default values for the properties of
System.Web.UI.WebControls.WebControl.
There's also a fix for a potential infinite loop in UnitConverter that
occurs when converting to/from non-string types.
Could someone review this, and if ther are no objections I'll commit it.
On a related note, I am uncomfortable with the constructor for
System.ComponentModel.DefaultValueAttribute.cs
public DefaultValueAttribute (Type type, string value)
{
try {
TypeConverter converter = TypeDescriptor.GetConverter (type);
DefaultValue = converter.ConvertFromString (null,
CultureInfo.InvariantCulture, value);
} catch { }
}
It should not be swallowing exceptions; if there are any, then the
dveloper has given the DefaultValueAttribute a bad value. However, I'm
reluctant to suggest changing this right now in case it breaks
anything.
Regards,
Michael
Index: class/System.Web/System.Web.UI.WebControls/UnitConverter.cs
===================================================================
--- class/System.Web/System.Web.UI.WebControls/UnitConverter.cs (revision 48525)
+++ class/System.Web/System.Web.UI.WebControls/UnitConverter.cs (working copy)
@@ -52,7 +52,7 @@
{
if(sourceType == typeof(string))
return true;
- return CanConvertFrom(context, sourceType);
+ return base.CanConvertFrom(context, sourceType);
}
#if NET_2_0
@@ -81,7 +81,7 @@
}
return (culture == null ? Unit.Parse(val) : Unit.Parse(val, culture));
}
- return ConvertFrom(context, culture, value);
+ return base.ConvertFrom(context, culture, value);
}
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
@@ -110,7 +110,7 @@
}
#endif
- return ConvertTo(context, culture, value, destinationType);
+ return base.ConvertTo(context, culture, value, destinationType);
}
}
}
Index: class/System.Web/System.Web.UI.WebControls/WebControl.cs
===================================================================
--- class/System.Web/System.Web.UI.WebControls/WebControl.cs (revision 48525)
+++ class/System.Web/System.Web.UI.WebControls/WebControl.cs (working copy)
@@ -118,7 +118,7 @@
#if !NET_2_0
[Bindable (true)]
#endif
- [DefaultValue (null), WebCategory ("Appearance")]
+ [DefaultValue (typeof(Color), ""), WebCategory ("Appearance")]
[TypeConverter (typeof (WebColorConverter))]
[WebSysDescription ("The background color for the WebControl.")]
public virtual Color BackColor
@@ -137,7 +137,7 @@
#if !NET_2_0
[Bindable (true)]
#endif
- [DefaultValue (null), WebCategory ("Appearance")]
+ [DefaultValue (typeof(Color), ""), WebCategory ("Appearance")]
[TypeConverter (typeof (WebColorConverter))]
[WebSysDescription ("The border color for the WebControl.")]
public virtual Color BorderColor
@@ -174,7 +174,7 @@
#if !NET_2_0
[Bindable (true)]
#endif
- [DefaultValue (null), WebCategory ("Appearance")]
+ [DefaultValue (typeof (Unit), ""), WebCategory ("Appearance")]
[WebSysDescription ("The width of the border used for the WebControl.")]
public virtual Unit BorderWidth
{
@@ -277,7 +277,7 @@
#if !NET_2_0
[Bindable (true)]
#endif
- [DefaultValue (null), WebCategory ("Appearance")]
+ [DefaultValue (typeof(Color), ""), WebCategory ("Appearance")]
[TypeConverter (typeof (WebColorConverter))]
[WebSysDescription ("The color that is used to paint the primary display of the WebControl.")]
public virtual Color ForeColor
@@ -296,7 +296,7 @@
#if !NET_2_0
[Bindable (true)]
#endif
- [DefaultValue (null), WebCategory ("Layout")]
+ [DefaultValue (typeof(Unit), ""), WebCategory ("Layout")]
[WebSysDescription ("The height of this WebControl.")]
public virtual Unit Height
{
@@ -322,7 +322,7 @@
}
}
- [DefaultValue (0), WebCategory ("Behavior")]
+ [DefaultValue (typeof (short), "0"), WebCategory ("Behavior")]
[WebSysDescription ("The order in which this WebControl gets tabbed through.")]
public virtual short TabIndex
{
@@ -366,7 +366,7 @@
#if !NET_2_0
[Bindable (true)]
#endif
- [DefaultValue (null), WebCategory ("Layout")]
+ [DefaultValue ( typeof (Unit), ""), WebCategory ("Layout")]
[WebSysDescription ("The width of this WebControl.")]
public virtual Unit Width
{
_______________________________________________
Mono-devel-list mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/mono-devel-list