Skip to content

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Epica3055
Copy link
Member

@Epica3055 Epica3055 commented Jun 24, 2025

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

  • We don't serialize CodeDomSerializationStore anymore. Copy the selectionComponents when CopyCommand is triggered.

Screenshots

Before

N/A

After

PR_13644_01

Microsoft Reviewers: Open in CodeFlow

@Epica3055 Epica3055 requested a review from a team as a code owner June 24, 2025 07:32
@Epica3055 Epica3055 force-pushed the AddShortCutCopyPasteInDemoConsole branch from b644b3a to 75532ce Compare June 24, 2025 08:43
@Epica3055 Epica3055 force-pushed the AddShortCutCopyPasteInDemoConsole branch from 75532ce to c798cbc Compare June 24, 2025 09:00
Copy link

codecov bot commented Jun 24, 2025

Codecov Report

Attention: Patch coverage is 6.66667% with 14 lines in your changes missing coverage. Please review.

Project coverage is 76.60777%. Comparing base (1c091ca) to head (c798cbc).
Report is 24 commits behind head on main.

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     
Flag Coverage Δ
Debug 76.60777% <6.66667%> (+0.03345%) ⬆️
integration 18.97179% <6.66667%> (+0.49589%) ⬆️
production 51.06257% <6.66667%> (+0.06550%) ⬆️
test 97.41186% <ø> (+0.00048%) ⬆️
unit 48.44734% <0.00000%> (+0.03625%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@LeafShi1 LeafShi1 requested a review from Copilot June 25, 2025 01:12
Copy link
Contributor

@Copilot Copilot AI left a 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 with DesignerUtils.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 to index to improve readability and make its purpose clearer.
                    int i = 0;

}

cmd.Enabled = enable;
cmd.Enabled = _toBeCopiedComponents is not null;
Copy link
Preview

Copilot AI Jun 25, 2025

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.

Suggested change
cmd.Enabled = _toBeCopiedComponents is not null;
cmd.Enabled = _toBeCopiedComponents?.Count > 0;

Copilot uses AI. Check for mistakes.

@LeafShi1
Copy link
Member

Please add Root Cause in the Description

ricardobossan
ricardobossan previously approved these changes Jul 4, 2025
@ricardobossan ricardobossan dismissed their stale review July 4, 2025 00:47

By mistake

@LeafShi1 LeafShi1 added the waiting-on-team This work item needs to be discussed with team or is waiting on team action in order to proceed label Jul 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-NRT waiting-on-team This work item needs to be discussed with team or is waiting on team action in order to proceed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DemoConsole application does not support keyboard operations and shortcuts
3 participants