Skip to content

Clipboard behaves different between net8 and net9 #12665

Closed

Description

@InlineAsm

.NET version

net9.0-windows

Did it work in .NET Framework?

Yes

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();

Activity

  1. added
    untriaged
    on Dec 20, 2024
  2. added
    💥 regression-release
    and removed
    untriaged
    on Dec 20, 2024
  3. self-assigned this
    on Dec 20, 2024
  4. lonitra commented on Dec 20, 2024

    @lonitra
    Member

    @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

  5. Epica3055 commented on Jan 3, 2025

    @Epica3055
    Member

    @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
  6. ricardobossan commented on Jan 3, 2025

    @ricardobossan
    Member

    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))

    Image

  7. lonitra commented on Jan 6, 2025

    @lonitra
    Member

    Calling Clipboard.GetDataObject().GetDataPresent(DataFormats.UnicodeText, autoConvert: true) instead of Clipboard.ContainsText() should work as a workaround while further investigation is done.

  8. Tanya-Solyanik commented on Jan 8, 2025

    @Tanya-Solyanik
    Contributor

    @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.

  9. added
    🚧 work in progress
    on Jan 9, 2025
  10. ricardobossan commented on Jan 9, 2025

    @ricardobossan
    Member

    @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.

    @Tanya-Solyanik This is already been addressed by @lonitra on #12738 , class ClipboardTests.cs.

  11. lonitra commented on Jan 14, 2025

    @lonitra
    Member

    Fix will be available in 9.0.2 release

  12. Philip-Wang01 commented on Jan 16, 2025

    @Philip-Wang01
    Contributor

    Verified the issue with 9.0.0 + private dlls built from release/9.0 branch, the issue has been fixed.

    Image

  13. Syareel-Sukeri commented on Jan 16, 2025

    @Syareel-Sukeri
    Contributor

    Verified the issue with latest .NET SDK 10.0.100-alpha.1.25065.19 build, the issue has been fixed as below screenshot:

    Image

  14. added this to the 10.0 Preview1 milestone on Jan 16, 2025
  15. Nora-Zhou01 commented on Jan 23, 2025

    @Nora-Zhou01
    Contributor

    Verified with .NET SDK 9.0.2 test pass build, the issue has been fixed same as above test results.

  16. Liv-Goh commented on Feb 12, 2025

    @Liv-Goh
    Contributor

    Verified with .NET SDK 10.0 P1 test pass build, it was fixed as above testing result.

  17. locked and limited conversation to collaborators on Mar 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

💥 regression-release🚧 work in progress

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions