CALayerDelegate was an informal protocol in earlier versions
of iOS, but elevated to protocol in iOS 10 [1]. Unfortunately this causes
problems with the static registrar, since it needs to know if a protocol
is informal or not to generate the right code, but there's no way
with the current set of attributes we have to express the fact that
CALayerDelegate was an informal protocol until iOS 10, so the static
registrar don't know to treat it correctly when building with earlier
SDKs.
This is the error that results when using CALayerDelegate with an earlier SDK:
/work/monotouch-samples/ZoomingPdfViewer/obj/iPhone/Debug/mtouch-cache/registrar.m:1336:51: error: no type or protocol named 'CALayerDelegate'
@interface ZoomingPdfViewer_TiledPdfView : UIView<CALayerDelegate> {
^
So we temporarily revert the change to make CALayerDelegate formal,
until we have enough metadata for the static registrar to do the
right thing (which is filed as bug #43780 [2])
[1] https://github.com/xamarin/xamarin-macios/commit/0178aa04
[2] https://bugzilla.xamarin.com/show_bug.cgi?id=43780https://bugzilla.xamarin.com/show_bug.cgi?id=43585
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
Also fix warnings printed while executing:
> CoreText performance note: Client called CTFontCreateWithName() using name "Arial" and got font with PostScript name "ArialMT". For best performance, only use PostScript names when calling this API.
> CoreText performance note: Set a breakpoint on CTFontLogSuboptimalRequest to debug.
It's marked as iOS only
> HK_CLASS_AVAILABLE_IOS_ONLY(10_0)
even if some other API, marked as available on watchOS 3, are exposing
the type. Those API are now removed from the watch platform assembly.
From Apple:
You want to use this API on watchOS that we explicitly decided to restrict this to iOS only.
Thank you for your feedback. Engineering has determined that this issue behaves as intended.
reference:
* radar #27865614
* https://trello.com/c/4soJeYEr