-
Notifications
You must be signed in to change notification settings - Fork 983
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use List<T> instead of ICollection in BehaviorDataObject #10278
Conversation
@@ -1478,8 +1478,7 @@ protected override void OnDragEnter(DragEventArgs de) | |||
object[] dragComps; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dragComps
can now be IComponent[]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't look that simple... OleDragDropHandler.GetDraggingObjects
return an object[]
. I think it can be refactored to return an IComponent[]
, but that's more involved. I'm not sure I should add it to this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at it again, it might be possible, but I'm not comfortable with making such a change. That would lead to assumptions that I'm not sure would hold all the time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it depends if the team ever decided to implement another Component interface.
As apart of this change maybe refactor this? winforms/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TableLayoutPanelDesigner.cs Lines 967 to 977 in cc1a968
Something like: private Control ExtractControlFromDragEvent(DragEventArgs de) =>
(de.Data as DropSourceBehavior.BehaviorDataObject)?.DragComponents.FirstOrDefault() as Control; |
Nice catch, I hadn't noticed this one. |
I agree, follow up PR to make this change quicker to review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
|
Finish work started in #8673
Related: #8140
Now that
DropSourceBehavior
is passed aList<IComponent>
in its constructor, we can updateBehaviorDataObject
to do the same instead of usingICollection
Proposed changes
BehaviorDataObject.DragComponents
to be aList<IComponent>
and update code accordinglyBehaviorDataObject
refacto while we're touching this code, but in a separate commitMicrosoft Reviewers: Open in CodeFlow