Therzok / MonoDevelop.Analyzers

Set of analyzers that can be used when working on MonoDevelop (and its dependencies)
MIT License
2 stars 2 forks source link

Detect anyone attempting to use the XamMac events on NSWindow #25

Open iainx opened 5 years ago

iainx commented 5 years ago

If you use XamMac's c# event handlers, XamMac will replace the delegate with its own. If you had a delegate already set, you can say bye-bye to it. This is especially dangerous when doing it with Gtk windows because everything breaks.

An analyser to throw an error when people try to use these events would be very helpful at preventing hard to trace bugs. Could it be limited to people attempting to replace it if the NSWindow class is GdkQuartzWindow?

Therzok commented 5 years ago

We can't really detect if the NSWindow is a GdkWindow. We can signal a warning for using EventHandlers.

One gross trick we can use, is if the NSWindow comes from specific methods (like GtkWorkarounds) or if the Gdk/Gtk namespace is imported.