-
Notifications
You must be signed in to change notification settings - Fork 507
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[AppKit] Add nullability to the manual code. #17182
[AppKit] Add nullability to the manual code. #17182
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…e/xamarin-macios into nullability-enabled-appkit
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
{ | ||
ActionDispatcher ctarget = target as ActionDispatcher; | ||
if (ctarget == null) | ||
var ctarget = target as ActionDispatcher; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not?
if (target is ActionDispatcher ctarget) {
ctarget.Activated -= handler;
}
@@ -40,25 +42,25 @@ internal class ActionDispatcher : NSObject | |||
const string dkey = "__monomac_internal_ActionDispatcher_doubleActivated:"; | |||
public static Selector Action = new Selector (skey); | |||
public static Selector DoubleAction = new Selector (dkey); | |||
public EventHandler Activated; | |||
public EventHandler DoubleActivated; | |||
public EventHandler? Activated; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In previous places I've worked, we liked to set up EventHandler
members like this:
public EventHandler Activated = (s, e) => { };
This lets you turn the OnActivated
into a one-liner:
[Preserve, Export (skey)]
public void OnActivated (NSObject sender) => Activated (sender, EventArgs.Empty);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That uses more memory, because you'd always create an EventHandler
instance, even if nobody adds an event handler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was the main reason I did not use that. @stephen-hawley I did see you using that code, I though about it but considered th emem usage and the fact that it is an ActionDispatcher.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How big is an empty EventHandler
instance compared to the extra code for null
checks - just checked, the answer appears to be 'slightly larger', where the output .dll is 512 bytes larger if you add 1 handler and 512 bytes if you add 8 handlers. Thanks, MacOS file system, you're the best.
src/AppKit/NSAccessibility.cs
Outdated
throw new ArgumentNullException ("role"); | ||
|
||
IntPtr subroleHandle; | ||
if (subrole == null) | ||
if (subrole is null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: this can be simplified to:
var subroleHandle = subrole.GetHandle ();
Co-authored-by: Rolf Bjarne Kvinge <[email protected]>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
40a8662
to
58592fc
Compare
✅ API diff for current PR / commitLegacy Xamarin (No breaking changes)
NET (empty diffs)
✅ API diff vs stableLegacy Xamarin (No breaking changes).NET (No breaking changes)✅ Generator diffGenerator diff is empty Pipeline on Agent |
💻 [PR Build] Tests on macOS M1 - Mac Big Sur (11.5) passed 💻✅ All tests on macOS M1 - Mac Big Sur (11.5) passed. Pipeline on Agent |
🚀 [CI Build] Test results 🚀Test results✅ All tests passed on VSTS: simulator tests. 🎉 All 225 tests passed 🎉 Tests counts✅ bcl: All 69 tests passed. Html Report (VSDrops) Download Pipeline on Agent |
No description provided.