[src] Remove System.nint and System.nuint from .NET. Fixes #10508.#13490
Merged
rolfbjarne merged 8 commits intodotnet:mainfrom Dec 7, 2021
Merged
[src] Remove System.nint and System.nuint from .NET. Fixes #10508.#13490rolfbjarne merged 8 commits intodotnet:mainfrom
rolfbjarne merged 8 commits intodotnet:mainfrom
Conversation
…custom System.nint/System.nuint. Unfortunately "using X = nint;" doesn't work, so we'll have to use the underlying type for nint instead in the using statement.
…e for NSNumber conversions.
…Ptr parameters in .NET.
In legacy Xamarin, the following code would create an NSNumber:
NSObject.FromObject ((nint) 123);
and this would create an NSValue:
NSObject.FromObject ((IntPtr) 123);
In .NET, these two types are the same, so we can't distinguish between them. However, we now have ObjCRuntime.NativeHandle that represents handles, and we're already returning an NSValue for that case:
NSObject.FromObject ((NativeHandle) (IntPtr) 123);
which means that we can make both of these cases return an NSNumber (for .NET):
NSObject.FromObject ((nint) 123);
NSObject.FromObject ((IntPtr) 123);
Fixes this test failure:
MonoTouchFixtures.Foundation.NSObjectTest
[FAIL] FromObject_NativeTypes : System.InvalidCastException : Unable to cast object of type 'Foundation.NSValue' to type 'Foundation.NSNumber'.
at MonoTouchFixtures.Foundation.NSObjectTest.FromObject_NativeTypes() in xamarin-macios/tests/monotouch-test/Foundation/ObjectTest.cs:line 111
which happens with this code:
var nativeint = (NSNumber) NSObject.FromObject ((nint)(-42));
Collaborator
❌ [PR Build] Tests failed on Build ❌Tests failed on Build. API & Generator diffℹ️ API Diff (from PR only) (please review changes) GitHub pagesResults can be found in the following github pages (it might take some time to publish): Test results3 tests failed, 134 tests passed.Failed tests
Pipeline on Agent XAMBOT-1101.BigSur' |
mandel-macaque
approved these changes
Dec 3, 2021
chamons
approved these changes
Dec 3, 2021
dalexsoto
approved these changes
Dec 3, 2021
Collaborator
❌ [PR Build] Tests failed on Build ❌Tests failed on Build. API diff✅ API Diff from stable View dotnet API diffView dotnet legacy API diffAPI & Generator diffℹ️ API Diff (from PR only) (please review changes) GitHub pagesResults can be found in the following github pages (it might take some time to publish): Test results2 tests failed, 135 tests passed.Failed tests
Pipeline on Agent XAMBOT-1094.BigSur' |
Member
Author
|
Test failures are unrelated
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #10508.
This PR is probably best reviewed commit-by-commit.