Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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
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 for Bug 34016 on
Developer Community or GitHub if you have new
information to add and do not yet see a matching new report.
If the latest results still closely match this report, you can use the
In special cases on GitHub you might also want the comments:
GitHub Markdown with public comments
Created attachment 12917 [details]
Simple test case
In Xamarin.Mac, when handling view events, you are not supposed to mix using delegate classes with using C# delegate events. An InvalidOperationException helps to prevent this. For example, if I do the following, I will get an exception on the last line:
var tv = new NSTableView ();
tv.Delegate = new NSTableViewDelegate();
var cgrv = tv.CoreGetRowView;
This is good. It prevents the NSTableView.Delegate we set from getting messed with.
However, the exception fails to get thrown if I am working with the subclass NSOutlineView:
var ov = new NSOutlineView ();
ov.Delegate = new NSOutlineViewDelegate();
var cgrv = ov.CoreGetRowView;
// Now ov.Delegate shows as null
Accessing the getter of the C# delegate event property causes the underlying delegate class to be replaced. It's especially confusing because it's replaced with an NSTableViewDelegate, and therefore can only be accessed by downcasting the NSOutlineView to an NSTableView. NSOutlineView.Delegate returns null.
We came across this while working on the inspector, which inspects property values for selected view. View event handling would break simply by accessing the getters on these C# delegate event properties.
Test case attached.