Skip to content

Avoid serialization with in-process Clipboard use#13287

Merged
JeremyKuhne merged 2 commits intodotnet:mainfrom
JeremyKuhne:inprocclip
Apr 15, 2025
Merged

Avoid serialization with in-process Clipboard use#13287
JeremyKuhne merged 2 commits intodotnet:mainfrom
JeremyKuhne:inprocclip

Conversation

@JeremyKuhne
Copy link
Member

@JeremyKuhne JeremyKuhne commented Apr 10, 2025

When copy is not set to true, the original object is still available and we can get data directly without serializing through NRBF.

  • Updated DataFormatNames for case-insensitive format lookups.
  • Changed format equality checks in DataStore to be case-insensitive.
  • Renamed a test method in ClipboardCoreTests for clarity and added a new test for SerializableObject to ensure it does not use BinaryFormatter.
  • Introduced a generic TryGetData<T>(out T data) method in Clipboard.
  • Modified SetDataObject to use WrappingDataObject for improved data wrapping.
  • Enhanced WrappingDataObject to always consider autoConvert as true, aligning with native IDataObject behavior.
  • Updated assertions in ClipboardTests for more flexible type checking.
  • Added tests to verify the handling of serializable objects without using BinaryFormatter.
Microsoft Reviewers: Open in CodeFlow

When copy is not set to true, the original object is still available and we can get data directly without serializing through NRBF.

- Updated `DataFormatNames` for case-insensitive format lookups.
- Changed format equality checks in `DataStore` to be case-insensitive.
- Renamed a test method in `ClipboardCoreTests` for clarity and added a new test for `SerializableObject` to ensure it does not use `BinaryFormatter`.
- Introduced a generic `TryGetData<T>(out T data)` method in `Clipboard`.
- Modified `SetDataObject` to use `WrappingDataObject` for improved data wrapping.
- Enhanced `WrappingDataObject` to always consider `autoConvert` as true, aligning with native `IDataObject` behavior.
- Updated assertions in `ClipboardTests` for more flexible type checking.
- Added tests to verify the handling of serializable objects without using `BinaryFormatter`.
@JeremyKuhne JeremyKuhne requested a review from a team as a code owner April 10, 2025 20:33
@JeremyKuhne JeremyKuhne added area-Clipboard Issues related to Clipboard binaryformatter-migration Issues related to the removal of BinaryFormatter and migrations away from it and removed area-Infrastructure labels Apr 10, 2025
@codecov
Copy link

codecov bot commented Apr 10, 2025

Codecov Report

Attention: Patch coverage is 35.29412% with 11 lines in your changes missing coverage. Please review.

Project coverage is 62.19962%. Comparing base (378a836) to head (4aad59d).
Report is 20 commits behind head on main.

Additional details and impacted files
@@                 Coverage Diff                 @@
##                main      #13287         +/-   ##
===================================================
+ Coverage   62.09218%   62.19962%   +0.10744%     
===================================================
  Files           1555        1556          +1     
  Lines         159260      159382        +122     
  Branches       14849       14857          +8     
===================================================
+ Hits           98888       99135        +247     
+ Misses         59648       59495        -153     
- Partials         724         752         +28     
Flag Coverage Δ
Debug 62.19962% <35.29412%> (+0.10744%) ⬆️
integration 11.29975% <5.88235%> (+0.57631%) ⬆️
production 40.34536% <35.29412%> (+0.14370%) ⬆️
test 95.66723% <ø> (+0.00095%) ⬆️
unit 37.70068% <35.29412%> (+0.04767%) ⬆️

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.

@JeremyKuhne JeremyKuhne added the 📚 documentation Open issue here - https://github.com/dotnet/dotnet-api-docs/issues label Apr 10, 2025
Copy link
Contributor

@Tanya-Solyanik Tanya-Solyanik left a comment

Choose a reason for hiding this comment

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

Looks good, added some comments.

Copy link
Contributor

@Tanya-Solyanik Tanya-Solyanik left a comment

Choose a reason for hiding this comment

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

Looks good

@JeremyKuhne JeremyKuhne merged commit 0c35754 into dotnet:main Apr 15, 2025
8 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the 10.0 Preview4 milestone Apr 15, 2025
@JeremyKuhne JeremyKuhne deleted the inprocclip branch April 15, 2025 18:12
@github-actions github-actions bot locked and limited conversation to collaborators May 16, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-Clipboard Issues related to Clipboard binaryformatter-migration Issues related to the removal of BinaryFormatter and migrations away from it 📚 documentation Open issue here - https://github.com/dotnet/dotnet-api-docs/issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants