winforms icon indicating copy to clipboard operation
winforms copied to clipboard

Add RCW for IDataObject

Open kant2002 opened this issue 2 years ago • 21 comments

Fixes #7518

Microsoft Reviewers: Open in CodeFlow

kant2002 avatar Jul 31 '22 07:07 kant2002

Or better, I should just finish https://github.com/dotnet/winforms/pull/7087

kant2002 avatar Jul 31 '22 13:07 kant2002

Thank you. However, the biggest qestion here is how we test this? And ensure we haven't missed anything else...

Or better, I should just finish #7087

We're in RC1 and the runway is too small for any significant changes, and risks are too great

RussKie avatar Aug 01 '22 01:08 RussKie

I can help test this, possibly. It needs to be an end to end test like the drag & drop tests in UIIntegration, but the drag operation needs to start from Explorer. My problem is I don't know how to automate the mouse drag & drop operation from Explorer yet.

If I knew how to get the coordinates of a file located on the screen, I could write the test.

willibrandon avatar Aug 01 '22 05:08 willibrandon

I thin we need something more complicated then UIIntegration. Maybe some "test running" which will run EXE files and then perform interaction over the OS. Maybe we can automate interaction using https://github.com/Microsoft/WinAppDriver . Probably that way we will test and Accessibility itself albeit indirectly.

kant2002 avatar Aug 01 '22 06:08 kant2002

Basically less risky change would be undo these 2 changes in this file https://github.com/dotnet/winforms/pull/6976/files#diff-efdc83ac4513276157401c19a46f9c20f7c2aa84d9b9eb1cd19f37aca86420d5R33 Also we should add tests, so this issue will never appears on our radar.

kant2002 avatar Aug 01 '22 07:08 kant2002

I can help test this, possibly. It needs to be an end to end test like the drag & drop tests in UIIntegration, but the drag operation needs to start from Explorer. My problem is I don't know how to automate the mouse drag & drop operation from Explorer yet.

It's possible to open an new instance of Explorer and select a file in it, e.g. cmd /c "explorer /select,<full path to file>". More docs are available at https://ss64.com/nt/explorer.html. The question is how we can find the screen coordinates of that file... ~WinAppDriver appears to able to do this somehow: https://github.com/microsoft/WinAppDriver/blob/9c561a52ace7b57bb375bc752389731a68dbcc53/Samples/C%23/NotepadTest/ScenarioPopupDialog.cs#L81.~

Files in Windows Explorer are displayed in a ListView control, so each file/folder is just a listview item. Accessibility tools (e.g., Narrator, etc.) can work it out, so we should be able too. image

Perhaps this could help https://docs.microsoft.com/windows/win32/winauto/uiauto-clientportal and https://docs.microsoft.com/windows/win32/api/uiautomationclient/nf-uiautomationclient-iuiautomation-getfocusedelement

Pinging @vladimir-krestov for ideas.

RussKie avatar Aug 02 '22 02:08 RussKie

It's possible to open an new instance of Explorer and select a file in it, e.g. cmd /c "explorer /select,". More docs are available at https://ss64.com/nt/explorer.html.

Thank you.

I'm still trying to answer the question of how we can reliably find the screen coordinates of that file, but for the record, I can reproduce the issue in a UIIntegration test if I hard code the Explorer screen coordinates and drag to the application.

NotImplementedException

willibrandon avatar Aug 02 '22 06:08 willibrandon

A manual test that already exists and reproduces this issue is in WinformsControlsTest.DragDrop.

willibrandon avatar Aug 02 '22 06:08 willibrandon

I will test these changes.

willibrandon avatar Aug 02 '22 06:08 willibrandon

Basically less risky change would be undo these 2 changes in this file https://github.com/dotnet/winforms/pull/6976/files#diff-efdc83ac4513276157401c19a46f9c20f7c2aa84d9b9eb1cd19f37aca86420d5R33 Also we should add tests, so this issue will never appears on our radar.

@kant2002 the team has chatted and we think it's probably for the best that we do as you suggest here for .NET 7, and we take the completed fix in .NET 8 with the additional testing. Does that work for you?

merriemcgaw avatar Aug 03 '22 00:08 merriemcgaw

Yes. I think so too. I think smallest thing to undo would be just 2 lines but if you think whole PR should be undone I'm fine. We should have stable WinForms a priority

kant2002 avatar Aug 03 '22 01:08 kant2002

Yes. I think so too. I think smallest thing to undo would be just 2 lines but if you think whole PR should be undone I'm fine. We should have stable WinForms a priority

if we do not have any other known scenario regressed and this reported scenario is fixed by undoing those two lines, we should stick to those lines in this and monitor for any new reports. Meanwhile, I will ask our test team to run some drag/drop scenarios to see if there are any pri0 scenarios that need to be addressed?

dreddy-work avatar Aug 03 '22 04:08 dreddy-work

@kant2002 tested this PR using 2 sample projects, the issue still repro. Please take a look, thanks. One project is from https://github.com/c-ohle/RationalNumerics with targeting the latest .Net 7.0 drag-drop Another is the one we created about drag-dropping image on pictureBox in Winforms from file explorer: WinFormsApp14.zip drag-drop_NotFixed

Olina-Zhang avatar Aug 04 '22 02:08 Olina-Zhang

@kant2002 , did you get a chance to look latest comments here?

dreddy-work avatar Aug 11 '22 00:08 dreddy-work

Basically less risky change would be undo these 2 changes in this file #6976 (files)

Would you be able to action this? The window for RC1 is closing fast.

RussKie avatar Aug 11 '22 04:08 RussKie

If only undo, I can do that.

kant2002 avatar Aug 11 '22 05:08 kant2002

@kant2002 , would it be possible to make the requested changes here before coming Monday?

dreddy-work avatar Aug 12 '22 17:08 dreddy-work

@RussKie - I now know how to write the automated test, dragging from Explorer, using IUIAutomation::GetFocusedElement and IUIAutomationElement::GetClickablePoint. Your help has been invaluable.

willibrandon avatar Aug 28 '22 19:08 willibrandon

@RussKie Igor Velikorossov FTE - I now know how to write the automated test, dragging from Explorer, using IUIAutomation::GetFocusedElement and IUIAutomationElement::GetClickablePoint. Your help has been invaluable.

You're giving me too much credit. I randomly blurbed something and you did all the work :) And now I'm eager to learn how to do that, you'll have to show us a test.

RussKie avatar Aug 31 '22 02:08 RussKie

You're giving me too much credit. I randomly blurbed something and you did all the work :) And now I'm eager to learn how to do that, you'll have to show us a test.

I mean all of your help so far, you are like a code whisperer.

I'm unsure how to proceed with the test, should I create a separate issue?

willibrandon avatar Aug 31 '22 02:08 willibrandon

I'm unsure how to proceed with the test, should I create a separate issue?

Yes please.

RussKie avatar Aug 31 '22 02:08 RussKie

The current status of this "draft" PR has persisted for over 180 days, making it highly probable that it is no longer aligned with the latest codebase. Our repository is set up to automatically close draft PRs that have become outdated, and it requests the author to revisit and reopen them if they deem it necessary, thereby bringing them to the team's attention.

ghost avatar Sep 30 '23 03:09 ghost