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

[gameplaykit] Add nullability to (generated and manual) bindings #14615

Merged
merged 15 commits into from
Apr 28, 2022

Conversation

tj-devel709
Copy link
Contributor

This PR aims to bring nullability changes to GameplayKit.
Following the steps here:

  1. I am adding nullable enable to all manual files that are not "API_SOURCES" in src/frameworks.sources and making the required nullability changes
  2. Changing all throw new ArgumentNullException ("object")); to ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (object)); for size saving optimization as well to mark that this framework contains nullability changes
  3. Changing any == null or != null to is null and is not null

@tj-devel709 tj-devel709 added the not-notes-worthy Ignore for release notes label Apr 1, 2022
@tj-devel709 tj-devel709 added this to the Future milestone Apr 1, 2022
@@ -18,7 +20,7 @@ public partial class GKBehavior {
}

public NSNumber this [GKGoal goal] {
get { return ObjectForKeyedSubscript (goal); }
get { return ObjectForKeyedSubscript (goal)!; }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From here: https://developer.apple.com/documentation/gameplaykit/gkbehavior/1388723-objectforkeyedsubscript?language=objc

Return Value The weight to be applied to the goal’s influence on an agent’s speed and direction, or 0.0 if the goal is not in the behavior.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need the !? I'm looking at the bindings and we have:

NSNumber ObjectForKeyedSubscript (GKBehavior behavior);

There is no nullable value, is there?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mandel-macaque were you looking at this one inside GKCompositeBehavior https://github.com/xamarin/xamarin-macios/blob/main/src/gameplaykit.cs#L336?
This one refers to the ObjectForKeyedSubscript inside GKBehavior https://github.com/xamarin/xamarin-macios/blob/main/src/gameplaykit.cs#L227 which has a nullable return

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You pasted the documentation, as per the docs: "or 0.0 if the goal is not in the behavior." so it will always return a NSNumber and if the behaviour is not there, it will be 0.0. So, the indexer seems to be wrong:

  1. The binding says we get a nullable, the docs say otherwise, we should add a test for that.
  2. If we return a 0.0 in an indexer is wrong. Indexers should throw an exception if the GKBejaviour is not present.

We should get the value, check the result and decide if we have a null or not and throw and except and remove the ! which is wrong and makes no sense. The binding is wrong and therefore the nullability.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note for future TJ:
The tests show the return value is indeed null when the goal is not in the behavior, add that if this value returns null, throw an ArgumentOutOfRangeException, and file a radar with Apple that the APIs behavior is different than their implementation

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note for future TJ:
The tests show the return value is indeed null when the goal is not in the behavior, add that if this value returns null, throw an ArgumentOutOfRangeException, and file a radar with Apple that the APIs behavior is different than their implementation

@@ -18,7 +20,7 @@ public partial class GKBehavior {
}

public NSNumber this [GKGoal goal] {
get { return ObjectForKeyedSubscript (goal); }
get { return ObjectForKeyedSubscript (goal)!; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need the !? I'm looking at the bindings and we have:

NSNumber ObjectForKeyedSubscript (GKBehavior behavior);

There is no nullable value, is there?

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ Tests on macOS Mac Catalina (10.15) passed ✅

Tests passed

All tests on macOS Mac Catalina (10.15) passed.

Pipeline on Agent
Merge 69eeeee into 180b561

@vs-mobiletools-engineering-service2
Copy link
Collaborator

❌ Tests on macOS M1 - Mac Big Sur (11.5) failed ❌

Tests timed out

Pipeline on Agent
Merge 69eeeee into 180b561

@vs-mobiletools-engineering-service2

This comment has been minimized.

Copy link
Member

@dalexsoto dalexsoto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After Manuel's 👍

@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

🔥 Tests failed catastrophically on VSTS: simulator tests iOS (no summary found). 🔥

Result file D:\a\1\s\Reports\TestSummary-simulator\TestSummary.md not found.

Pipeline on Agent
Merge 249735d into 8ef3850

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ Tests on macOS Mac Catalina (10.15) passed ✅

Tests passed

All tests on macOS Mac Catalina (10.15) passed.

Pipeline on Agent
Merge 249735d into 8ef3850

@vs-mobiletools-engineering-service2
Copy link
Collaborator

❌ Tests on macOS M1 - Mac Big Sur (11.5) failed ❌

Tests timed out

Pipeline on Agent
Merge 249735d into 8ef3850

@mandel-macaque
Copy link
Member

The errors are because the branch is behinds main and is using the main yaml. merging should fix the issue.

@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

✅ Tests on macOS Mac Catalina (10.15) passed ✅

Tests passed

All tests on macOS Mac Catalina (10.15) passed.

Pipeline on Agent
Merge c26823c into 8b8cf07

@vs-mobiletools-engineering-service2
Copy link
Collaborator

❌ Tests on macOS M1 - Mac Big Sur (11.5) failed ❌

Failed tests are:

  • introspection
  • linksdk
  • xammac_tests
  • monotouch-test

Pipeline on Agent
Merge c26823c into 8b8cf07

@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

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

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

📚 [PR Build] Artifacts 📚

Packages generated

View packages

Pipeline on Agent XAMBOT-1105.Monterey'
Hash: 711b26f7e2f703dbb83a9d469b97ce1d01cd2271

@vs-mobiletools-engineering-service2
Copy link
Collaborator

📋 [PR Build] API Diff 📋

API Current PR diff

✅ API Diff (from PR only) (no change)

View API diff
View dotnet API diff
View dotnet legacy API diff
View dotnet iOS-MacCatalayst API diff

API diff

✅ API Diff from stable

View API diff
View dotnet API diff
View dotnet legacy API diff
View dotnet iOS-MacCatalayst API diff

Generator diff

Generator Diff (no change)

Pipeline on Agent XAMBOT-1107.Monterey'
Hash: 711b26f7e2f703dbb83a9d469b97ce1d01cd2271

@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: 711b26f7e2f703dbb83a9d469b97ce1d01cd2271

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [PR Build] Tests on macOS Mac Catalina (10.15) passed 💻

All tests on macOS Mac Catalina (10.15) passed.

Pipeline on Agent
Hash: 711b26f7e2f703dbb83a9d469b97ce1d01cd2271

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build] Tests passed on VSTS: simulator tests iOS. ✅

Tests passed on VSTS: simulator tests iOS.

🎉 All 148 tests passed 🎉

Pipeline on Agent XAMBOT-1107.Monterey'
Merge 711b26f into ffcfabd

@tj-devel709 tj-devel709 merged commit 717b141 into xamarin:main Apr 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
not-notes-worthy Ignore for release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants