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

[CoreGraphics] Adjust CGPDFOperatorTable to not use a generic Action delegate. #11560

Merged

Commits on May 14, 2021

  1. [CoreGraphics] Adjust CGPDFOperatorTable to not use a generic Action …

    …delegate.
    
    * CoreCLR doesn't support generic Action delegates in reverse (P/Invokes), so
      we need to find a different solution.
    * The native CGPDFOperatorTable callback API is not very friendly to us,
      because we can't pass it callback-specific data, which means that the
      managed caller must conform to the FullAOT requirement of the managed
      callback (must be a static function; must have a MonoPInvokeCallback
      attribute).
    * We can leverage the new function pointer syntax in C# 9 to make these
      requirements enforced by the C# compiler (unmanaged function pointer +
      UnmanagedCallersOnly attribute). The resulting API is still clunky to use,
      but I don't see any way around that.
    
    Fixes this monotouch-test failure with CoreCLR:
    
        [FAIL] Tamarin : System.Runtime.InteropServices.MarshalDirectiveException : Cannot marshal 'parameter #3': Non-blittable generic types cannot be marshaled.
                   at CoreGraphics.CGPDFOperatorTable.CGPDFOperatorTableSetCallback(IntPtr table, String name, Action`2 callback)
                   at CoreGraphics.CGPDFOperatorTable.SetCallback(String name, Action`2 callback)
                   at MonoTouchFixtures.CoreGraphics.PDFScannerTest.Tamarin() in xamarin-macios/tests/monotouch-test/CoreGraphics/PDFScannerTest.cs:line 102
    
    Ref: dotnet/runtime#32963
    rolfbjarne committed May 14, 2021
    Configuration menu
    Copy the full SHA
    74d2220 View commit details
    Browse the repository at this point in the history