-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Added cross-platform Get-Clipboard and Set-Clipboard #10340
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
Conversation
src/Microsoft.PowerShell.Commands.Management/commands/management/GetClipboardCommand.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.PowerShell.Commands.Management/commands/management/GetClipboardCommand.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.PowerShell.Commands.Management/commands/management/GetClipboardCommand.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.PowerShell.Commands.Management/commands/management/GetClipboardCommand.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.PowerShell.Commands.Management/commands/management/GetClipboardCommand.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.PowerShell.Commands.Management/commands/management/SetClipboardCommand.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.PowerShell.Commands.Management/commands/management/SetClipboardCommand.cs
Outdated
Show resolved
Hide resolved
|
Not sure why XUnit tests are failing as it doesn't seem the changes here should have that effect so still investigating but repros locally. |
|
The remaining Codacy issues are by-design as I don't want to |
|
@PowerShell/powershell-committee there is a request to remove dependency on WinForms and call the win32 apis directly. WinForms automatically gave us support for FileDropList, Audio, and Image formats (the latter two simply return a .NET object that has metadata about the content). The first one allowed copying files from Explorer and outputting their file paths, but required specifying that explicitly: Get-ClipBoard -Format FileDropList. I would propose that we simplify this and have consistency across platforms by only supporting text. This would also remove the |
|
@PowerShell/powershell-committee reviewed this, since the code exists for the PInvokes and we prefer consistency across different platforms, we agreed to remove dependency on WinForms and wait for feedback if any customer needs |
|
2725fe4 to
3c7bfa7
Compare
|
Remaining Codacy issues are by-design |
|
Please fix CodeFactor issues. |
src/Microsoft.PowerShell.Commands.Management/commands/management/Clipboard.cs
Outdated
Show resolved
Hide resolved
|
@PoshChan please retry static |
|
@SteveL-MSFT, successfully started retry of |
| @@ -0,0 +1,386 @@ | |||
| // Copyright (c) Microsoft Corporation. All rights reserved. | |||
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.
| // Copyright (c) Microsoft Corporation. All rights reserved. | |
| // Copyright (c) Microsoft Corporation. |
| @@ -0,0 +1,45 @@ | |||
| # Copyright (c) Microsoft Corporation. All rights reserved. | |||
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.
| # Copyright (c) Microsoft Corporation. All rights reserved. | |
| # Copyright (c) Microsoft Corporation. |
|
🎉 Handy links: |
PR Summary
Re-enabled the existing Clipboard code for Windows which relies on the Clipboard class from WinForms. For Linux, it requires
xclipand macOSpbcopyandpbpaste. Had to#ifdefout a bunch of code that only works on Windows for copy/pasting non-text types. On Linux/macOS, decided to retain the parameters even if not supported to provide a more detailed error message.Had to modify typegen as one of the types in Winforms being used has no HashAlgorithm so typegen threw. Instead, it skips assemblies where no HashAlgorithm is used which appears to only be an Accessibility assembly associated with WinForms.
To support win-arm builds, creating new WINFORMS def in csproj and uses clip.exe to set the clipboard, but no cmdline tool on win-arm to get contents of clipboard so had to disable all tests on win-arm since it depends on getting content out.
To support PSXunit tests, default to Microsoft.NET.Sdk if SDKToUse is not explicitly defined.
PR Context
Fix #4307
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.