Repository navigation
[release/10.0] Add opt-in native clipboard text fallback for WPF - #15370
Conversation
Compose managed clipboard sources with a captured native text reader while preserving custom payload identity. Keep WinForms clipboard behavior unchanged and add regression coverage. Co-authored-by: Copilot <[email protected]> Copilot-Session: 918733ee-3532-46a0-92bb-728aaa5bb200
There was a problem hiding this comment.
🟡 Changes recommended
The composed clipboard path can fail valid legacy text reads, bypass application overloads, and mishandle format-name casing, while the new fallback path lacks direct test coverage.
4 open issues
What changed in this PR
Adds an internal, opt-in native clipboard text fallback to support the WPF text-conversion regression fix while keeping WinForms opted out.
Changes:
- Introduces a default-disabled policy for native Text, UnicodeText, and OEMText fallback.
- Combines managed-first retrieval with a captured native clipboard reader.
- Adds six WinForms regression cases covering flushed and unflushed text behavior.
| File | Description |
|---|---|
| src/test/unit/System.Windows.Forms/System/Windows/Forms/ClipboardTextConversionTests.cs | Adds text-conversion regression cases. |
| src/System.Windows.Forms/System/Windows/Forms/OLE/WinFormsOleServices.cs | Explicitly disables fallback for WinForms. |
| src/System.Windows.Forms/System/Windows/Forms/OLE/DataObject.cs | Adds construction from a composed clipboard view. |
| src/System.Private.Windows.Core/tests/System.Private.Windows.Core.Tests/System/Private/Windows/Ole/TestDataObject.cs | Implements the composition factory for test objects. |
| src/System.Private.Windows.Core/src/System/Private/Windows/Ole/IOleServices.cs | Defines the default-disabled fallback policy. |
| src/System.Private.Windows.Core/src/System/Private/Windows/Ole/IDataObjectInternal.cs | Adds the managed/native composition factory contract. |
| src/System.Private.Windows.Core/src/System/Private/Windows/Ole/Composition.cs | Adds managed-first legacy and typed text fallback. |
| src/System.Private.Windows.Core/src/System/Private/Windows/Ole/ClipboardCore.cs | Creates composed clipboard results for opted-in consumers. |
Review effort: Balanced
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## release/10.0 #15370 +/- ##
======================================================
+ Coverage 77.10831% 77.17660% +0.06828%
======================================================
Files 3275 3278 +3
Lines 645221 645377 +156
Branches 47716 47737 +21
======================================================
+ Hits 497519 498080 +561
+ Misses 144023 143606 -417
- Partials 3679 3691 +12
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
Route legacy-only plain-text requests through the captured native typed reader without invoking legacy getters. Add opt-in fallback tests covering .NET 9-compatible casing and dispatch, captured-reader retention, and managed payload behavior. Co-authored-by: Copilot <[email protected]> Copilot-Session: 918733ee-3532-46a0-92bb-728aaa5bb200
There was a problem hiding this comment.
🔵 Needs a closer look
Mock-based tests cannot establish native text synthesis or captured OLE-proxy lifetime after clipboard replacement, so Windows integration validation with the matching WPF/package pair is needed.
No open issues 🎉
4 resolved since last review
Review effort: Balanced
|
Approved over email. |

Fixes dotnet/wpf#11968 in conjunction with the corresponding WPF changes.
Proposed changes
Text,UnicodeText, andOEMText. For sources that don't support typed reads, typed text reads go straight to the native reader.GetDataandGetDataPresentcalls to the overloads withautoConvert: true, matching .NET 9. This also applies to non-text formats, but native fallback is still limited to plain text.Customer Impact
Regression?
Risk
Test methodology
Microsoft Reviewers: Open in CodeFlow