Open Epica3055 opened 2 months ago
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 75.05220%. Comparing base (
27d748e
) to head (2092f3f
). Report is 230 commits behind head on feature/10.0.
I haven't tested it yet. because this change is made in runtime repo while Designer is in another repo.
build the binaries and copy System.windows.forms.dll to the program files\dotnet\shared
But more importantly, how do you prove that this is not regressing any runtime scenarios?
Fixes designer/issues/2707
Root Cause
We use
_requestedHeight
to set the height of a ComboBox whenDropDownStyle
isComboBoxStyle.Simple
https://github.com/dotnet/winforms/blob/70a6a7b4a9af452160e636838f946b3f4327383c/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ComboBox/ComboBox.cs#L61-L63
Let's go through the repro steps that was described here https://github.com/microsoft/winforms-designer/issues/2707#issuecomment-799222994
The following steps also can repro this issue:
Step I : Create a Winforms .Net Core project with a ComboBox
I think this is the generated code
Step II: Close and reopen form designer First ComboBox constrictor will be invoked
https://github.com/dotnet/winforms/blob/70a6a7b4a9af452160e636838f946b3f4327383c/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ComboBox/ComboBox.cs#L116-L126
_requestedHeight
will be assigned toDefaultSimpleStyleHeight
, which is 150.https://github.com/dotnet/winforms/blob/70a6a7b4a9af452160e636838f946b3f4327383c/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ComboBox/ComboBox.cs#L47
then
comboBox1.Size = new Size(121, 23);
will be executed, which will involveSetBoundsCore
methodhttps://github.com/dotnet/winforms/blob/70a6a7b4a9af452160e636838f946b3f4327383c/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ComboBox/ComboBox.cs#L3371-L3382
then height(23) will be assigned to
_requestedHeight
.Step III: Set the DropDownStyle of comboBox as Simple
please see line 1170-1173
https://github.com/dotnet/winforms/blob/70a6a7b4a9af452160e636838f946b3f4327383c/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ComboBox/ComboBox.cs#L1135-L1177
So step 3 will trigger HandleRecreate. please see line 2435-2438, so eventually
SetBoundsCore
method will be triggered. And_requestedHeight
(23) will be assigned toHeight
https://github.com/dotnet/winforms/blob/70a6a7b4a9af452160e636838f946b3f4327383c/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ComboBox/ComboBox.cs#L2380-L2469
So the parameter height here is 23, which is supposed to be 150.
https://github.com/dotnet/winforms/blob/70a6a7b4a9af452160e636838f946b3f4327383c/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ComboBox/ComboBox.cs#L3371-L3382
Proposed changes
_requestedHeight
is assigned.Before
After
https://github.com/dotnet/winforms/assets/135201996/aaef3b5d-2ca0-4722-bbe1-f4b643eb7e1a
Test methodology