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
Conditional order of precedence bug in ScrollableControl.SetDisplayRectLocation #1955
It is easy to break SetDisplayRectLocation_InvokeWithoutHandle_Success test by adding an Debug.Assert(IsHandleCreated, "Handle is not created") in the condition.
So it is a 🐛
Looking further at the code I'm wondering - would a child control have its handle created if its parent control doesn't have a handle? Is it a valid scenario?
If not, we can optimise SetDisplayRectLocation method to fast exit if IsHandleCreated isn't created:
would a child control have its handle created if its parent control doesn't have a handle? Is it a valid scenario?
In Desktop Framework this apparently was possible and there is code to deal with that, so I'd assume this is still possible in Core.
Basically, if some user code forces the child window handle to be created it will be created hidden and parented to a "parking window". Later when the real parent is actually created the child will be moved over. I don't know if the comment (or my interpretation thereof) is correct but thats how I read it.
However, considering that a child would be parented to the parking window, I don't know how critical it is to call its UpdateBounds in the first place, maybe its safe to skip when the parent is not created.
Activity
hughbe commentedon Sep 23, 2019
Weird. This should be caught in https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1408.md
RussKie commentedon Sep 24, 2019
@sharwell any thoughts?
sharwell commentedon Sep 24, 2019
@RussKie SA1408 should report this, yes. Is the rule disabled?
sharwell commentedon Sep 24, 2019
winforms/eng/Shipping.ruleset
Line 99 in 8ecc2b4
I believe you can also get this behavior from a built-in rule:
RussKie commentedon Sep 24, 2019
Thank you Sam.
Any other rules we should enable?
sharwell commentedon Sep 25, 2019
@RussKie That's entirely up to the individual project. If you have any questions about the applicability of specific rules I'm happy to help 👍
RussKie commentedon Sep 26, 2019
It is easy to break
SetDisplayRectLocation_InvokeWithoutHandle_Successtest by adding anDebug.Assert(IsHandleCreated, "Handle is not created")in the condition.So it is a 🐛
hughbe commentedon Sep 26, 2019
Aye.. I can fix this once #1920 is merged
RussKie commentedon Sep 26, 2019
I'm looking at all violations of SA1408, so leave this with me.
RussKie commentedon Sep 26, 2019
Looking further at the code I'm wondering - would a child control have its handle created if its parent control doesn't have a handle? Is it a valid scenario?
If not, we can optimise
SetDisplayRectLocationmethod to fast exit ifIsHandleCreatedisn't created:winforms/src/System.Windows.Forms/src/System/Windows/Forms/ScrollableControl.cs
Lines 786 to 808 in 3f56480
@JeremyKuhne @Tanya-Solyanik @dreddy-work what do you think?
weltkante commentedon Sep 26, 2019
In Desktop Framework this apparently was possible and there is code to deal with that, so I'd assume this is still possible in Core.
Basically, if some user code forces the child window handle to be created it will be created hidden and parented to a "parking window". Later when the real parent is actually created the child will be moved over. I don't know if the comment (or my interpretation thereof) is correct but thats how I read it.
However, considering that a child would be parented to the parking window, I don't know how critical it is to call its
UpdateBoundsin the first place, maybe its safe to skip when the parent is not created.RussKie commentedon Sep 27, 2019
Thank you Tobias.
fix `ScrollableControl.SetDisplayRectLocation` incorrect order of pre…