Skip to content

Added cross-platform Get-Clipboard and Set-Clipboard - #10340

Merged
Travis Plunk (TravisEz13) merged 29 commits into
PowerShell:masterfrom
SteveL-MSFT:clipboard-cmdlets
Nov 4, 2019
Merged

Travis Plunk (TravisEz13) merged 29 commits into
PowerShell:masterfrom
SteveL-MSFT:clipboard-cmdlets

Conversation

@SteveL-MSFT

@SteveL-MSFT Steve Lee (SteveL-MSFT) commented Aug 10, 2019 •

Copy link
Copy Markdown
Member

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

Comment thread build.psm1 Resolved
Comment thread build.psm1 Resolved
Comment thread build.psm1 Resolved
Comment thread build.psm1 Resolved
Comment thread build.psm1 Resolved
Comment thread build.psm1 Resolved
Comment thread build.psm1 Resolved
Comment thread build.psm1 Resolved
Comment thread build.psm1 Resolved
@SteveL-MSFT

Copy link
Copy Markdown
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.

Comment thread build.psm1 Resolved
Comment thread build.psm1 Resolved
Comment thread build.psm1 Resolved
Comment thread build.psm1 Resolved
Comment thread build.psm1 Resolved
Comment thread build.psm1 Resolved
Comment thread build.psm1 Resolved
@SteveL-MSFT

Copy link
Copy Markdown
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

Comment thread assets/files.wxs Resolved
Comment thread assets/files.wxs Resolved
@SteveL-MSFT

Copy link
Copy Markdown
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 Steve Lee (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

Sean Wheeler (sdwheeler) commented Oct 30, 2019 •

Copy link
Copy Markdown
Contributor

Steve Lee (@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
Copy Markdown
Member Author

Remaining Codacy issues are by-design

@iSazonov

Copy link
Copy Markdown
Collaborator

Please fix CodeFactor issues.

Comment thread assets/files.wxs Resolved
@SteveL-MSFT

Copy link
Copy Markdown
Member Author

PoshChan-Bot (@PoshChan) please retry static

@PoshChan

Copy link
Copy Markdown
Collaborator

Steve Lee (@SteveL-MSFT), successfully started retry of PowerShell-CI-static-analysis

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

Copy link
Copy Markdown
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
Copy Markdown
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
Travis Plunk (TravisEz13) merged commit b74a26b into PowerShell:master Nov 4, 2019
@SteveL-MSFT
Steve Lee (SteveL-MSFT) deleted the clipboard-cmdlets branch November 4, 2019 19:49
@PaulHigin Paul Higinbotham (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
@ghost

Copy link
Copy Markdown

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

Handy links:

Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
…10340)


Co-Authored-By: Ilya <darpa@yandex.ru>



Co-Authored-By: Ilya <darpa@yandex.ru>
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