[release/9.0] Only Unwrap If Given IDataObject#12745
Merged
lonitra merged 1 commit intodotnet:release/9.0from Jan 14, 2025
Merged
[release/9.0] Only Unwrap If Given IDataObject#12745lonitra merged 1 commit intodotnet:release/9.0from
lonitra merged 1 commit intodotnet:release/9.0from
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## release/9.0 #12745 +/- ##
=====================================================
- Coverage 74.83635% 74.83126% -0.00509%
=====================================================
Files 3022 3022
Lines 630322 630413 +91
Branches 46798 46798
=====================================================
+ Hits 471710 471746 +36
- Misses 155224 155277 +53
- Partials 3388 3390 +2
Flags with carried forward coverage won't be shown. Click here to find out more. |
Tanya-Solyanik
approved these changes
Jan 10, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #12738
Customer Impact
When users set an object that is not an IDataObject onto our Clipboard using the SetDataObject API, calls to our clipboard APIs with
autoConvert = false(either directly or indirectly) will no longer recognize equivalent clipboard formats as it had done in .NET 8, producing unintended behavior change.This regressed because in .NET 9, we had switched to leveraging cswin32 and ComWrappers for our OLE interop. During this we discovered that switching from built-in COM to ComWrappers took away the ability to automatically cast native pointers back to their original managed object when round tripping through native code. In order to remedy this, we updated to wrap the data when setting it onto the clipboard and unwrap manually on clipboard retrieval before returning it in order to get the original data.
While doing this, however, we had missed the fact that the native IDataObject interface doesn't have the concept of explicit
autoConvert. Meaning that when calling our Clipboard APIs withautoConvert = false, it will effectively be ignored and produce same results asautoConvert = true, recognizing equivalent clipboard formats if we're calling to a native IDataObject interface. In .NET 9, since we always unwrap the object retrieved from the clipboard to get our completely managed DataObject, we lost this behavior for types that don't already derive from managed IDataObject.Testing
Run on regression test suite and added unit tests covering scenario.
Risk
Low. The fix is that when we wrap types that don't already derive from the managed IDataObject, we won't unwrap to the wrapping DataObject we created so that calls go through the native IDataObject interface, restoring behavior we had in .NET 8.
Microsoft Reviewers: Open in CodeFlow