You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Breaking change]: Removed the DefaultValueAttribute from properties that need dynamically calculated default values. #33954
We are removing DefaultValueAttribute from control properties that are dependent on the default font height.
Version
.NET 8 Preview 2
Previous behavior
Default values were hardcoded according to an assumed application wide font.
New behavior
Design time default values are calculated at the start up based on the current font metrics.
Type of breaking change
Binary incompatible: Existing binaries may encounter a breaking change in behavior, such as failure to load or execute, and if so, require recompilation.
Source incompatible: When recompiled using the new SDK or component or to target the new runtime, existing source code may require source changes to compile successfully.
Behavioral change: Existing binaries may behave differently at run time.
Reason for change
This attribute is designed to define constant default values used by the WinForms designer. In the past this DefaultValueAttribute had been used to specify defaults on certain properties that depend on the current font height. When we set a new default font in .NET Core 3.1, we had not updated the attribute values accordingly. Moreover, we now have an API to modify application font. Thus, it makes sense to use dynamic default values instead of the constant ones. Designer provides alternative methods to specify dynamic default values. However, for properties decorated with this attribute, designer would not attempt the alternatives and would use the constant default value instead. The alternative method preserves design time functionality provided by this attribute.
Recommended action
DefaultValueAttribute is intended for internal use in design time scenarios in. It should be avoided in other scenarios.
Activity