Bug 28486 - notification selectors have 0 arguments
Summary: notification selectors have 0 arguments
Status: VERIFIED ANSWERED
Alias: None
Product: Xamarin.Mac
Classification: Desktop
Component: Library (Xamarin.Mac.dll) ()
Version: 1.12.0
Hardware: Macintosh Mac OS
: High normal
Target Milestone: 2.0.x
Assignee: Chris Hamons
URL:
Depends on:
Blocks:
 
Reported: 2015-03-27 05:44 UTC by Radu
Modified: 2015-04-21 06:52 UTC (History)
3 users (show)

Tags:
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:
Status:
VERIFIED ANSWERED

Description Radu 2015-03-27 05:44:52 UTC
My app has successfully used the following code:

public override void AwakeFromNib (){
  //....
  ganttChartView.EnclosingScrollView.ContentView.PostsBoundsChangedNotifications = true;
  NSNotificationCenter.DefaultCenter.AddObserver (this, new Selector ("boundsDidChangeNotification"), NSView.BoundsChangedNotification, ganttChartView.EnclosingScrollView.ContentView);
}

[Export ("boundsDidChangeNotification")]
public void BoundsDidChangeNotification (NSObject o){
  ...
}

Since 1.12 this doesn't work anymore. It results in System.AggregateException being thrown in the Main class at runtime. You can trace that and conclude that it is due to the parameter in the selector. Somehow, since 1.12 the selector must have no parameter. The workaround is to use some alternative version of the AddObserver  method.

Don't you think that this change is quite unexpected?
Comment 1 Timothy Risi 2015-03-27 12:56:54 UTC
Radu,

It looks like the Export statement needs a colon at the end to indicate the parameter.  Our new registrar got more picky some syntax issues like that where the old one didn't have an issue with it.  I changed it to:

[Export ("boundsDidChangeNotification:")]
public void BoundsDidChangeNotification (NSObject o)

and was able to run the app successfully without getting the AggregateException.
Comment 2 Mohit Kheterpal 2015-04-21 06:52:49 UTC
As per comment 1, this issue is answered by Timothy Risi. So I am closing this issue by marking it as Verified.