Bug 15283 - Binding a objective-c method with a block doesn't compile anymore in Xamarin.iOS 7.0.1.4 but was working in 6.4.5.0
Summary: Binding a objective-c method with a block doesn't compile anymore in Xamarin....
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: 7.0.0.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2013-10-08 13:19 UTC by Alexandre Pepin
Modified: 2013-10-10 17:57 UTC (History)
4 users (show)

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


Attachments
Sample project that reproduces the problem (3.36 KB, application/zip)
2013-10-08 13:19 UTC, Alexandre Pepin
Details


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:
Status:
RESOLVED FIXED

Description Alexandre Pepin 2013-10-08 13:19:16 UTC
Created attachment 5092 [details]
Sample project that reproduces the problem

When compiling the attached project, I get the following error : 

"<path>/BindingTests/obj/Debug/ios/ObjCRuntime/Trampolines.g.cs(12,12): Error CS0029: Cannot implicitly convert type `System.IntPtr' to `MonoTouch.Foundation.NSObject' (CS0029) (BindingTests)"

It was working under Xamarin.iOS 6.4.5.0 but doesn't work anymore under Xamarin.iOS 7.0.1.4. The project compile if I changed the returned type of "MyBlockToBind" to void or if the parameter of "MyBlockToBind" isn't an array...
Comment 1 Sebastien Pouliot 2013-10-08 15:23:34 UTC
That's likely related to the introduction, in 7.0, of the new [BlockCallback] attribute [1]. What does the native side definition looks like?

http://docs.xamarin.com/guides/ios/advanced_topics/binding_objective-c/binding_types_reference_guide#BlockCallback
Comment 2 Alexandre Pepin 2013-10-08 15:54:53 UTC
Objective-c : 
typedef id (^MyBlockToBind)(NSArray* keys);
- (void) testMethodBlock: (MyBlockToBind)myBlockToBind;

I still get the same compilation error when i add the [BlockCallback] attribute : 
void TestMethod ([BlockCallback] MyBlockToBind myBlockToBind);
Comment 3 Rolf Bjarne Kvinge [MSFT] 2013-10-10 17:57:33 UTC
Fixed.

maccore/master: d5e84e9306cc50fd1f65b55e8c21c4ec949f43b4
monotouch/master: a7f4ee72ea8423f69530c9a72d83859e9a18cea8