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
ToolStripSeparator.GetPreferredSize has a suspicious always-true if check #2576
The implementation of ToolStripSeparator.GetPreferredSize is as follows:
publicoverrideSizeGetPreferredSize(SizeconstrainingSize){ToolStripparent=ParentInternal;if(parent==null){parent=Owner;}if(parent==null){returnnewSize(ToolStrip_SEPARATORTHICKNESS,ToolStrip_SEPARATORTHICKNESS);}if(parentisToolStripDropDownMenudropDownMenu){returnnewSize(parent.Width-(parent.Padding.Horizontal-dropDownMenu.ImageMargin.Width),ToolStrip_SEPARATORTHICKNESS);}else{if(parent.LayoutStyle!=ToolStripLayoutStyle.HorizontalStackWithOverflow||parent.LayoutStyle!=ToolStripLayoutStyle.VerticalStackWithOverflow){// we dont actually know what size to make it, so just keep it a stock size.constrainingSize.Width=ToolStrip_SEPARATORHEIGHT;constrainingSize.Height=ToolStrip_SEPARATORHEIGHT;}if(IsVertical){returnnewSize(ToolStrip_SEPARATORTHICKNESS,constrainingSize.Height);}else{returnnewSize(constrainingSize.Width,ToolStrip_SEPARATORTHICKNESS);}}}
Notice this case: if (parent.LayoutStyle != ToolStripLayoutStyle.HorizontalStackWithOverflow || parent.LayoutStyle != ToolStripLayoutStyle.VerticalStackWithOverflow)
This appears to always be true, as parent.LayoutStyle can't be both HorizontalStackWithOverflow and VerticalStackWithOverflow.
Should this actually be an && check rather than ||
Activity
RussKie commentedon Dec 29, 2019
Yes, it looks like a logic bug. Nicely spotted!
There are two other similar looking conditions that use

&&hughbe commentedon Dec 30, 2019
Not sure whether this would affect various use cases. Will have to investigate further looking at layouts etc
elachlan commentedon Jan 10, 2023
@dreddy-work other than the review of use cases this changes seems minor. Should I put in a PR?
dreddy-work commentedon Jan 10, 2023
I see this was the case since .NET framework 4.0 ( may be even before). Go ahead and create PR but check if LayoutSetting can be bitwise
ANDanywhere.dreddy-work commentedon Jan 10, 2023
We can validate as part of preview test pass and take it early in the previews for .NET 8.
13 remaining items