Bug 6145 - Wrong DefaultValueAttribute for System.Web.UI.Control.ViewStateMode
Summary: Wrong DefaultValueAttribute for System.Web.UI.Control.ViewStateMode
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Web ()
Version: master
Hardware: PC All
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-07-16 15:50 UTC by petar.dodev
Modified: 2012-07-26 07:50 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description petar.dodev 2012-07-16 15:50:12 UTC
Description:
The DefaultValueAttribute of the property ViewStateMode is a string, while the property itself is an enum of type ViewStateMode. It's caused the addin I'm developing not to filter the properties with default values.

Steps to reproduce:
1) get the default value with the PropertyDescriptor of the property:

var defVal = propertyDescriptor.Attributes[typeof (DefaultValueAttribute)] as DefaultValueAttribute;

2) compare the value with that of an component, which ViewStateMode is Inherit:

if (propertyDescriptor.GetValue(component).Equals(defVal.Value)) {
  // do something if it's the default value
}


Actual results:
The code doesn't detect if the property has it's default value

Expected results:
Detect it.

Additional Information:
I think the solution is to change the line: 
https://github.com/mono/mono/blob/master/mcs/class/System.Web/System.Web.UI/Control.cs#L2123
[DefaultValue ("0")]
to:
[DefaultValue (ViewStateMode.Inherit)]
Comment 1 Marek Safar 2012-07-26 07:50:38 UTC
Fixed in master