You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Clipboard behaves different between net8 and net9 #12665
Did it work in any of the earlier releases of .NET Core or .NET 5+?
It does work on net8.0
Issue description
The Clipboard method ContainsText returns false when a string is placed on the clipboard using SetDataObject. In previous versions of the runtime this method would return true.
Steps to reproduce
The following code returns true on net8.0 and returns false on net9.0
Clipboard.SetDataObject("TEXT");
var containsText = Clipboard.ContainsText();
@LeafShi1 could your team take an initial look? My initial thought is perhaps we had accidentally changed something in Clipboard.ContainsText between .NET 8/9 - perhaps some sort of typo.
The codepath for Clipboard.ContainsText should eventually call IDataObject.GetDataPresent, which should go to our DataStore.GetDataPresent. where it should check to see if the format is there - though it is possible on .NET 8 that this goes to a different implementation we have of IDataObject.GetDataPresent. We should compare what the difference is between the codepath for .NET 8/9
I proceeded to do binary search on the issue and arrived at the same conclusion as @Epica3055 : The faulty commit is 64528f3e176738f7e621ed6959c4593b24db9453(Convert Rest of Ole to Cswin32 (#10651))
Calling Clipboard.GetDataObject().GetDataPresent(DataFormats.UnicodeText, autoConvert: true) instead of Clipboard.ContainsText() should work as a workaround while further investigation is done.
Activity
lonitra commentedon Dec 20, 2024
@LeafShi1 could your team take an initial look? My initial thought is perhaps we had accidentally changed something in
Clipboard.ContainsTextbetween .NET 8/9 - perhaps some sort of typo.The codepath for
Clipboard.ContainsTextshould eventually callIDataObject.GetDataPresent, which should go to our DataStore.GetDataPresent. where it should check to see if the format is there - though it is possible on .NET 8 that this goes to a different implementation we have ofIDataObject.GetDataPresent. We should compare what the difference is between the codepath for .NET 8/9Epica3055 commentedon Jan 3, 2025
@lonitra
I think this issue might be caused by pr_10651
Before the pr
issues_12665_01.mp4
After the pr
issues_12665_02.mp4
ricardobossan commentedon Jan 3, 2025
I proceeded to do binary search on the issue and arrived at the same conclusion as @Epica3055 : The faulty commit is
64528f3e176738f7e621ed6959c4593b24db9453(Convert Rest of Ole to Cswin32 (#10651))lonitra commentedon Jan 6, 2025
Calling
Clipboard.GetDataObject().GetDataPresent(DataFormats.UnicodeText, autoConvert: true)instead ofClipboard.ContainsText()should work as a workaround while further investigation is done.Tanya-Solyanik commentedon Jan 8, 2025
@ricardobossan - please add a unit test for this issue and create a PR with this test disabled, we'll enable when the fix is ready.
ricardobossan commentedon Jan 9, 2025
@Tanya-Solyanik This is already been addressed by @lonitra on #12738 , class ClipboardTests.cs.
lonitra commentedon Jan 14, 2025
Fix will be available in 9.0.2 release
Philip-Wang01 commentedon Jan 16, 2025
Verified the issue with 9.0.0 + private dlls built from release/9.0 branch, the issue has been fixed.
Syareel-Sukeri commentedon Jan 16, 2025
Verified the issue with latest .NET SDK 10.0.100-alpha.1.25065.19 build, the issue has been fixed as below screenshot:
Nora-Zhou01 commentedon Jan 23, 2025
Verified with .NET SDK 9.0.2 test pass build, the issue has been fixed same as above test results.
Liv-Goh commentedon Feb 12, 2025
Verified with .NET SDK 10.0 P1 test pass build, it was fixed as above testing result.