Bug 15268 - [NSAttributedString attributedStringWithAttachment] is incorrectly bound
Summary: [NSAttributedString attributedStringWithAttachment] is incorrectly bound
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 7.0.0.x
Hardware: PC Mac OS
: Normal normal
Target Milestone: 7.2.1
Assignee: Sebastien Pouliot
Depends on:
Reported: 2013-10-08 09:54 UTC by Tom Gilder
Modified: 2014-03-20 09:52 UTC (History)
5 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 Tom Gilder 2013-10-08 09:54:23 UTC
attributedStringWithAttachment is bound as an extension method on an instance of NSAttributedString...

public static MonoTouch.Foundation.NSAttributedString FromTextAttachment (this MonoTouch.Foundation.NSAttributedString This, NSTextAttachment attachment)

...but it should be a static method on NSAttributedString, as it's a class method in Objective-C.
Comment 1 Sebastien Pouliot 2013-10-08 10:30:11 UTC
It's a category method (NSAttributedStringAttachmentConveniences) but, unlike most, it's a static method. I'll look if we can provide better bindings.
Comment 2 Sebastien Pouliot 2013-10-08 10:49:47 UTC
That's an uncommon situation, good catch!

Beside this case I only see another such case: PrepareInterstitialAds on UIViewController.
Comment 3 Sebastien Pouliot 2013-10-08 11:57:56 UTC
It's not optimal (and not the final fix) but you do not need to create an (unneeded) `NSAttributedString` instance to use the static extension method, i.e.

NSAttributedString as1 = null;
var as2 = as1.FromTextAttachment (new NSTextAttachment (...));

still it's a workaround and I agree the right syntax should be:

var as2 = NSAttributedString.FromTextAttachment (new NSTextAttachment (...));
Comment 5 Miguel de Icaza [MSFT] 2013-10-16 11:48:55 UTC
In this particular case, let us just add the proper signature to NSString and not the category as it makes no difference.

We need to both move this, and provide an Obsolete method for the current instance method.
Comment 6 Sebastien Pouliot 2013-12-16 21:40:51 UTC
Fixed in master 34eec5045f728c23e6139a36167b697d7a438415
Comment 7 Sadik Ali 2014-03-20 09:52:53 UTC
I have checked this issue on below environments:

All Mac
XS 4.2.4 (build 32)
Xamarin.iOS: (Business Edition)

Build Information
Release ID: 402040032
Git revision: a160c35dac9ab9fd32eeadaa171216316d5a5133
Xamarin addins: a779416ceabd54981ce812771a4061c942e8b872

I have checked with the below code and build successfully:

NSAttributedString as1 = null;
var as2 = as1.FromTextAttachment (new NSTextAttachment ());

Screen cast: http://screencast.com/t/PeM50CsSia

Also I goto assembly and checked FromTextAttachment method and noticed this is static method on NSAttributedString.

Please review and let me know if anything additional that I need to verify.