Generate trampoline and registrar tests that tests if a return type requires objc_msgSend or objc_msgSend_stret.
Now it's much easier to test new return types (a single line of code), which
avoids a _lot_ of copy-pasting, and makes sure all the different variations
are tested properly.
These new tests found several bugs, which are fixed in subsequent commits.
* [tests] Remove Classic SDK tests.
* Remove XI/Classic support.
This also means we can remove support for the legacy registrars.
* [monotouch-test] Remove legacy registrar tests.
* [tests/mtouch] Remove Classic tests (and legacy registrar logic).
* [tests/scripted] Fix tests to reference Xamarin.iOS.dll.
The current API use `string`, not `NSString` is added as a step forward.
The `NSString` is more correct but it does not ease discoverability (e.g.
code completion) so an enum-based overload is added (as the preferred API).
https://bugzilla.xamarin.com/show_bug.cgi?id=32535
https://bugzilla.xamarin.com/show_bug.cgi?id=37175
NSUrlSession's Create*Task methods may return an object of the wrong
type (NSUrlSessionTask instead of NSUrl[Data|Download|Upload]SessionTask),
so we need to bypass our type check when creating the managed object,
otherwise we end up throwing InvalidCastExceptions randomly. We will
return the type that is declared on the headers so if the native side
returns a cat and headers says it barks we'll we make it bark :).
https://bugzilla.xamarin.com/show_bug.cgi?id=44322
AVAssetDownloadUrlSession.CreateSession according to headers it
should return an AVAssetDownloadUrlSession but it is returning
an apple internal type NSURLBackgroundSession so with our
current bindings it throws an InvalidCastException, adding
ForcedTypeAttribute will create the managed type wihout
the actual typecheck. Added test verifing that the API
no longer throws.
It turns out `MTLHeapDescriptor` does not exists on the simulator.
```Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_MTLHeapDescriptor", referenced from:
objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture x86_64```
A `[DisableDefaultCtor]` was used (by mistake / lack of documentation)
and this was hiding the issue (on our bots).
However on device introspection was not happy:
iOSApiSelectorTest
[FAIL] Selector not found for Metal.MTLHeapDescriptor : cpuCacheMode
[FAIL] Selector not found for Metal.MTLHeapDescriptor : setCpuCacheMode:
[FAIL] Selector not found for Metal.MTLHeapDescriptor : size
[FAIL] Selector not found for Metal.MTLHeapDescriptor : setSize:
[FAIL] Selector not found for Metal.MTLHeapDescriptor : storageMode
[FAIL] Selector not found for Metal.MTLHeapDescriptor : setStorageMode:
[FAIL] iOSApiSelectorTest.ApiSelectorTest.InstanceMethods : 6 errors found in 18339 instance selector validated
Note that these are the properties, not the `init` that's mentioned here.
So first `init` is possible, on devices, from Xcode:
MTLHeapDescriptor *hd = [[MTLHeapDescriptor alloc] init];
NSLog (@"%@", [hd description]);
gives
<MTLHeapDescriptorInternal: 0x17401da50>
{
cpuCacheMode = MTLCPUCacheModeDefaultCache;
size = 0;
storageMode = MTLStorageModePrivate;
}
so we need to remove our `[DisableDefaultCtor]`.
That does not fix the selectors above... but note the *Internal type
returned, they are forwarded and that's generally something that
respondToSelector (that introspection uses) does not cover.
But, to be sure, we add unit tests showing all the properties are
working like expected :-)
* [healthkit] Change binding for HKDetailedCdaErrors
* Hide [Fields]
* Easier access to the information from NSError
* Unit test (mostly to make sure of the returned type)
* [healthkit] Remove HKDetailedCDAValidationErrorKey from watchOS profile
It's used from an NSError returned from an API that is not available in
watchOS.
Fixes the following test failures:
[FAIL] BlockSignatureTest.WithoutUserDelegateTypeAttribute : System.ExecutionEngineException : Attempting to JIT compile method '(wrapper native-to-managed) MonoTouchFixtures.ObjCRuntime.BlockSignatureTest:<WithoutUserDelegateTypeAttribute>m__0 (intptr,intptr)' while running with --aot-only. See http://docs.xamarin.com/ios/about/limitations for more information.
at (wrapper managed-to-native) System.Runtime.InteropServices.Marshal:GetFunctionPointerForDelegateInternal (System.Delegate)
at System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate (System.Delegate d) [0x00011] in /work/maccore/xcode8/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/corlib/System.Runtime.InteropServices/Marshal.cs:1714
at ObjCRuntime.BlockLiteral.SetupBlock (System.Delegate trampoline, System.Delegate userDelegate) [0x0000b] in /work/maccore/xcode8/xamarin-macios/src/ObjCRuntime/Blocks.cs:92
at MonoTouchFixtures.ObjCRuntime.BlockSignatureTest.WithoutUserDelegateTypeAttribute () [0x00049] in /work/maccore/xcode8/xamarin-macios/tests/monotouch-test/ObjCRuntime/RegistrarTest.cs:2585
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00038] in /work/maccore/xcode8/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:309
[FAIL] BlockSignatureTest.WithUserDelegateTypeAttribute : System.ExecutionEngineException : Attempting to JIT compile method '(wrapper native-to-managed) MonoTouchFixtures.ObjCRuntime.BlockSignatureTest:<WithUserDelegateTypeAttribute>m__2 (intptr,intptr)' while running with --aot-only. See http://docs.xamarin.com/ios/about/limitations for more information.
at (wrapper managed-to-native) System.Runtime.InteropServices.Marshal:GetFunctionPointerForDelegateInternal (System.Delegate)
at System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate (System.Delegate d) [0x00011] in /work/maccore/xcode8/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/corlib/System.Runtime.InteropServices/Marshal.cs:1714
at ObjCRuntime.BlockLiteral.SetupBlock (System.Delegate trampoline, System.Delegate userDelegate) [0x0000b] in /work/maccore/xcode8/xamarin-macios/src/ObjCRuntime/Blocks.cs:92
at MonoTouchFixtures.ObjCRuntime.BlockSignatureTest.WithUserDelegateTypeAttribute () [0x00049] in /work/maccore/xcode8/xamarin-macios/tests/monotouch-test/ObjCRuntime/RegistrarTest.cs:2596
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00038] in /work/maccore/xcode8/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:309
Enabling CloudKit on watchOS required to remove some default .ctor that
watchOS does not _support_.
This commit fix this by either
* replacing the default .ctor with something that works across all
platforms (best); or
* removing the default .ctor only on watchOS;
The commit also mark as abstract three existing types for watchOS (and
for XAMCORE_4_0) that were found reviewing the bindings.
Runtime
- Added support for Vector2d, Vector3d and Vector4d SIMD types
- Added support for GKBox, GKQuad and GKTriangle SIMD types
GameplayKit
- Apple introduced GKQuadTreeNode and GKQuadTree in Xcode 7.1 and
removed those types in a later Xcode (7.2?) but we kept them around.
Now apple introduced again both types but renamed them to GKQuadtreeNode
and GKQuadtree (lowercase t), this is a breaking change and since we do
care about binary compat we are just changing the registration name and
keeping the same managed name deprecating old methods and introducing
the new ones.
- Added tests for new SIMD types
Xcode8 SDK changed untyped enums (always 32 bits) into NSInteger. In this
case we can continue with the existing API (and ignore them in xtro)
reference:
https://bugzilla.xamarin.com/show_bug.cgi?id=42682
The P/Invoke callback method that's called by native code
has a simpler function signature than what the user delegate
has.
Example P/Invoke callback signature:
static unsafe void Invoke (IntPtr block, IntPtr obj)
which ends up calling this delegate:
System.Action<NSDictionary>
The NSDictionary parameter has been simplifed to just IntPtr.
The problem is that we need to encode the block signature according
to the signature of the user delegate (Apple uses the signature
in some cases, and fails/aborts if the signature doesn't match
what the code expects).
So add more metadata to make it possible to find the signature
of the user delegate at runtime.
The generator generates code like this:
block_scheduledCompletion.SetupBlock (Trampolines.SDActionArity1V2.Handler, scheduledCompletion);
where SDActionArity1V2.Handler is defined as this:
static internal readonly DActionArity1V2 Handler = Invoke;
this means we can get the type of `Trampolines.SDActionArity1V2.Handler` at runtime
(which would be `DActionArity1V2` in this case), so put a new attribute (`UserDelegateTypeAttribute`)
at that type:
[UnmanagedFunctionPointerAttribute (CallingConvention.Cdecl)]
[UserDelegateType (typeof (global::System.Action<NSDictionary>))]
internal delegate void DActionArity1V2 (IntPtr block, IntPtr obj);
Then at runtime we check if the target delegate's type has this attribute,
and then we use the type specified by this new attribute instead when
computing the ObjC signature of the block.
https://bugzilla.xamarin.com/show_bug.cgi?id=43592
A problem, that exists with the current API, is that several constants
are hidden but many are needed in some dictionaries - and not all of
them can be turned into _classic_ StrongDictionary.
This initial PR does not solve all the (old) problems, but it does offer
some useful overloads that makes the API usable for basic usages and
expose the NSDictionary-based API.
This is a static selector that needs to be overridden, which is not the
usual pattern in C#. We re-define it using [New] on subclasses.
Unit tests added for all NSDimension subclasses.
reference:
https://bugzilla.xamarin.com/show_bug.cgi?id=43444
Apple removed CGColorConverter even if it was publicly exposed in iOS 9.3,
not that I recall any API that consumed it...
It was replaced by a new, very close, type named CGColorConversionInfo and
the existing code and tests were updated to the new API.
So for `CGColorConverter` we're
* iOS: Obsoleted + code removal
* tvOS: Obsoleted + code removal
* watchOS: the API can be removed as it was not exposed in a stable release
* macOS: it was not enabled (did not work)
* [tests] Adjust ApiCMAttachmentTest so it knows how to create the new CGColorConversionInfo type