8000 Added cross-platform Get-Clipboard and Set-Clipboard by SteveL-MSFT · Pull Request #10340 · PowerShell/PowerShell · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@SteveL-MSFT
Copy link
Member
@SteveL-MSFT SteveL-MSFT commented Aug 10, 2019

PR Summary

Re-enabled the existing Clipboard code for Windows which relies on the Clipboard class from WinForms. For Linux, it requires xclip and macOS pbcopy and pbpaste. Had to #ifdef out 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

@SteveL-MSFT
Copy link
Member Author

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.

@SteveL-MSFT
Copy link
Member Author

The remaining Codacy issues are by-design as I don't want to #if out those members and code referring to them making it harder to read

@SteveL-MSFT
Copy link
Member Author

@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 -Format and -Raw params which would no longer be needed.

@SteveL-MSFT
Copy link
Member Author

@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 -Format

@SteveL-MSFT SteveL-MSFT added Committee-Reviewed PS-Committee has reviewed this and made a decision and removed Review - Committee The PR/Issue needs a review from the PowerShell Committee labels Oct 30, 2019
@sdwheeler
Copy link
Collaborator
sdwheeler commented Oct 30, 2019

@SteveL-MSFT

The Get-Clipboard cmdlet gets the current Windows clipboard entry.
The Set-Clipboard cmdlet sets the current Windows clipboard entry.

@SteveL-MSFT
Copy link
Member Author

Remaining Codacy issues are by-design

@iSazonov
Copy link
Collaborator
iSazonov commented Nov 2, 2019

Please fix CodeFactor issues.

@SteveL-MSFT
Copy link
Member Author

@PoshChan please retry static

@PoshChan
Copy link
Collaborator
PoshChan commented Nov 4, 2019

@SteveL-MSFT, successfully started retry of PowerShell-CI-static-analysis

@@ -0,0 +1,386 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation.

@@ -0,0 +1,45 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Copyright (c) Microsoft Corporation. All rights reserved.
# Copyright (c) Microsoft Corporation.

@TravisEz13 TravisEz13 merged commit b74a26b into PowerShell:master Nov 4, 2019
@SteveL-MSFT SteveL-MSFT deleted the clipboard-cmdlets branch November 4, 2019 19:49
@PaulHigin PaulHigin added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label Nov 19, 2019
@PaulHigin PaulHigin added this to the 7.0.0-preview.6 milestone Nov 19, 2019
@ghost
Copy link
ghost commented Nov 21, 2019

🎉v7.0.0-preview.6 has been released which incorporates this pull request.:tada:

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log Committee-Reviewed PS-Committee has reviewed this and made a decision

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Set-Clipboard in PowerShell Core on Windows Results in Throwing CommandNotFoundException

7 participants

0