-
Notifications
You must be signed in to change notification settings - Fork 1k
Add shortCut copy paste In DemoConsole #13644
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
base: main
Are you sure you want to change the base?
Add shortCut copy paste In DemoConsole #13644
Conversation
b644b3a
to
75532ce
Compare
75532ce
to
c798cbc
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #13644 +/- ##
===================================================
+ Coverage 76.57432% 76.60777% +0.03345%
===================================================
Files 3252 3253 +1
Lines 640942 640965 +23
Branches 47437 47432 -5
===================================================
+ Hits 490797 491029 +232
+ Misses 146602 146280 -322
- Partials 3543 3656 +113
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
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.
Pull Request Overview
This PR refactors the form designer’s copy/paste commands to stop using BinaryFormatter
serialization and instead keep a reference to the selected components for direct duplication.
- Introduces a private
_toBeCopiedComponents
field to store copied items. - Replaces clipboard‐based serialization in
OnMenuCopy
/OnMenuPaste
withDesignerUtils.CopyDragObjects
. - Simplifies status checks and removes obsolete
BinaryFormatter
code.
Comments suppressed due to low confidence (1)
src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/CommandSet.cs:1844
- [nitpick] The loop index variable
i
is quite generic; consider renaming it toindex
to improve readability and make its purpose clearer.
int i = 0;
} | ||
|
||
cmd.Enabled = enable; | ||
cmd.Enabled = _toBeCopiedComponents is not null; |
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.
This enables the Paste command even when there are no components to paste. Change the check to _toBeCopiedComponents?.Count > 0
so the command is only enabled when items are available.
cmd.Enabled = _toBeCopiedComponents is not null; | |
cmd.Enabled = _toBeCopiedComponents?.Count > 0; |
Copilot uses AI. Check for mistakes.
src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/CommandSet.cs
Show resolved
Hide resolved
Please add Root Cause in the Description |
Fixes #10466
Root cause
Copy and paste now works in DemoConsole in netframework481 but not in net10. that's because the serializer here does not work in net10, it was deprecated long time ago.
https://github.com/dotnet/winforms/blob/b0b0e101cb69db4b70f7e3559e30406b210b1f1d/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/CommandSet.cs#L1409C1-L1415C74
Proposed changes
selectionComponents
when CopyCommand is triggered.Screenshots
Before
N/A
After
Microsoft Reviewers: Open in CodeFlow