Bug 36835 - PasteboardItem appears to not work correctly
Summary: PasteboardItem appears to not work correctly
Alias: None
Product: Xamarin.Mac
Classification: Desktop
Component: Other ()
Version: Master
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Chris Hamons
Depends on:
Reported: 2015-12-10 17:17 UTC by Cody Beyer (MSFT)
Modified: 2015-12-16 02:50 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Cody Beyer (MSFT) 2015-12-10 17:17:03 UTC
### Description

Using a copy/paste sample app, PasteboardItem does not carry metadata string to clipboard

### Sample


### Steps to Reproduce

1. Download sample
2. Select an Image (I like City)
3. Click Copy
4. Open TextEdit.app
5. Paste

### Expected Results

ImageInfo string data should be pasted

### Actual Results

Nothing is pasted

### Versions

=== Xamarin Studio ===

Version 5.10.2 (build 26)
Installation UUID: 96bb0955-3810-4164-be25-5fccce1b0014
	Mono 4.2.1 (explicit/39edf24)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 402010124

=== Xamarin.Profiler ===

Not Installed

=== Xamarin.Android ===

Version: (Business Edition)
Android SDK: /Users/codybeyer/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		4.0.3 (API level 15)
		4.4   (API level 19)
		6.0   (API level 23)

SDK Tools Version: 24.4.1
SDK Platform Tools Version: 23.0.1
SDK Build Tools Version: 23.0.1

Java SDK: /usr
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

=== Xamarin Android Player ===

Version: 0.6.5
Location: /Applications/Xamarin Android Player.app

=== Apple Developer Tools ===

Xcode 7.2 (9548)
Build 7C68

=== Xamarin.iOS ===

Version: (Business Edition)
Hash: 97af501
Branch: master
Build date: 2015-12-04 18:59:51-0500

=== Xamarin.Mac ===

Version: (Business Edition)

=== Build Information ===

Release ID: 510020026
Git revision: 33a8642aa88f9119949cce312b9186308d8ca76c
Build date: 2015-12-07 17:21:45-05
Xamarin addins: af8ffe5b187898ec2f2f0c78de1bd01ae39b2008
Build lane: monodevelop-lion-cycle6

=== Operating System ===

Mac OS X 10.11.2
Darwin Codys-MacBook-Pro.local 15.2.0 Darwin Kernel Version 15.2.0
    Fri Nov 13 19:56:56 PST 2015
    root:xnu-3248.20.55~2/RELEASE_X86_64 x86_64
Comment 1 Chris Hamons 2015-12-11 22:27:09 UTC
So it is difficult to determine, due to the lack of a reproduce example, or any real steps, but I believe the problem described here is the fact that the NSPasteboardItemDataProvider is not working as expected.

If that is the case, it appears to be due to the fact that we hard code "public.text" but NSPasteboardTypeString is now returning "public.utf8-plain-text".

The fact that we don't expose those contacts is now filed under: 

Swapping the writableTypes array in ImageDocument.cs and the case in ImageInfoDataProvider in the sample and it appears to work.

If this is not the issue described, please reopen with an example showing what API in question you don't believe is acting correctly.
Comment 2 Yvonne Du 2015-12-16 01:33:54 UTC
Thanks Chris. Changing to "public.utf8-plain-text" solves the problem.

Chris, is it OK to you to expose objects like NSPasteboardTypeString? I do not want to hard code these strings in product.
Comment 3 Chris Hamons 2015-12-16 02:50:48 UTC
That's what the second bug I filed (https://bugzilla.xamarin.com/show_bug.cgi?id=36926) was tracking. That will be fixed in Cycle 7. Until then, you can use this to retrieve it manually:

NSString s = ObjCRuntime.Dlfcn.GetStringConstant (ObjCRuntime.Dlfcn.dlopen ("/System/Library/Frameworks/AppKit.framework/AppKit", 0), "NSPasteboardTypeString");