Skip to content
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

Merged

Conversation

mandel-macaque
Copy link
Member

No description provided.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

src/AppKit/NSAccessibility.cs Outdated Show resolved Hide resolved
src/AppKit/NSAccessibility.cs Outdated Show resolved Hide resolved
src/AppKit/NSAccessibility.cs Outdated Show resolved Hide resolved
src/AppKit/NSAccessibility.cs Outdated Show resolved Hide resolved
src/AppKit/NSAccessibility.cs Outdated Show resolved Hide resolved
src/AppKit/NSView.cs Outdated Show resolved Hide resolved
src/AppKit/NSView.cs Outdated Show resolved Hide resolved
src/AppKit/NSView.cs Outdated Show resolved Hide resolved
src/AppKit/NSView.cs Outdated Show resolved Hide resolved
src/AppKit/NSCollectionViewDelegate.cs Outdated Show resolved Hide resolved
@github-actions
Copy link
Contributor

⚠️ Your code has been reformatted. ⚠️

If this is not desired, add the actions-disable-autoformat label, and revert the reformatting commit.

If files unrelated to your change were modified, try reverting the reformatting commit + merging with the target branch (and push those changes).

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

{
ActionDispatcher ctarget = target as ActionDispatcher;
if (ctarget == null)
var ctarget = target as ActionDispatcher;
Copy link
Contributor

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;
Copy link
Contributor

@stephen-hawley stephen-hawley Jan 12, 2023

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);

Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Contributor

@stephen-hawley stephen-hawley Jan 12, 2023

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.

throw new ArgumentNullException ("role");

IntPtr subroleHandle;
if (subrole == null)
if (subrole is null)
Copy link
Member

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 ();

src/AppKit/NSAccessibility.cs Outdated Show resolved Hide resolved
src/AppKit/NSAccessibility.cs Outdated Show resolved Hide resolved
Co-authored-by: Rolf Bjarne Kvinge <[email protected]>
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ API diff for current PR / commit

Legacy Xamarin (No breaking changes)
  • iOS (no change detected)
  • tvOS (no change detected)
  • watchOS (no change detected)
  • macOS (no change detected)
NET (empty diffs)
  • iOS: (empty diff detected)
  • tvOS: (empty diff detected)
  • MacCatalyst: (empty diff detected)
  • macOS: (empty diff detected)

✅ API diff vs stable

Legacy Xamarin (No breaking changes)
.NET (No breaking changes)
Legacy Xamarin (stable) vs .NET

✅ Generator diff

Generator diff is empty

Pipeline on Agent
Hash: 58e60ca5e1a92189f44a513652ccad646ea37c01 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [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
Hash: 58e60ca5e1a92189f44a513652ccad646ea37c01 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

📚 [PR Build] Artifacts 📚

Packages generated

View packages

Pipeline on Agent XAMBOT-1106.Monterey'
Hash: 58e60ca5e1a92189f44a513652ccad646ea37c01 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

🚀 [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
✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests: All 1 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 7 tests passed. Html Report (VSDrops) Download
✅ framework: All 8 tests passed. Html Report (VSDrops) Download
✅ generator: All 2 tests passed. Html Report (VSDrops) Download
✅ interdependent_binding_projects: All 7 tests passed. Html Report (VSDrops) Download
✅ install_source: All 1 tests passed. Html Report (VSDrops) Download
✅ introspection: All 8 tests passed. Html Report (VSDrops) Download
✅ linker: All 65 tests passed. Html Report (VSDrops) Download
✅ mac_binding_project: All 1 tests passed. Html Report (VSDrops) Download
✅ mmp: All 2 tests passed. Html Report (VSDrops) Download
✅ mononative: All 12 tests passed. Html Report (VSDrops) Download
✅ monotouch: All 25 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ mtouch: All 1 tests passed. Html Report (VSDrops) Download
✅ xammac: All 3 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 8 tests passed. Html Report (VSDrops) Download
✅ xtro: All 2 tests passed. Html Report (VSDrops) Download

Pipeline on Agent
Hash: 58e60ca5e1a92189f44a513652ccad646ea37c01 [PR build]

@mandel-macaque mandel-macaque merged commit 8be73c7 into xamarin:main Jan 24, 2023
@mandel-macaque mandel-macaque deleted the nullability-enabled-appkit branch January 24, 2023 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants