-
Notifications
You must be signed in to change notification settings - Fork 514
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
[.NET/CoreFoundation] Use [UnmanagedCallersOnly] instead of [MonoPInvokeCallback] for the CGPDFDictionaryApplyFunction function. #12956
Conversation
…okeCallback] for the CGPDFDictionaryApplyFunction function. I had to change the first argument from 'string' to 'IntPtr', because 'string' isn't blittable. In order to diverge the code paths as little as possible, I also made this change for the legacy Xamarin version. Ref xamarin#10470.
// CGPDFDictionaryApplierFunction | ||
delegate void ApplierFunction (/* const char* */ string key, /* CGPDFObjectRef */ IntPtr value, /* void* */ IntPtr info); | ||
delegate void ApplierFunction (/* const char* */ IntPtr key, /* CGPDFObjectRef */ IntPtr value, /* void* */ IntPtr info); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be left as string and add in a [MarhsalAs(UnmanagedType. LPUTF8Str)]
to the string parameter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, because parameters and the return type for methods decorated with [UnmanagedCallersOnly]
must be blittable, and string isn't blittable (and the MarshalAs attribute doesn't change that fact).
Now technically this delegate could be left with the string argument, because it's only used in legacy Xamarin (and not where we apply the [UnmanagedCallersOnly]
attribute), but that would mean we'd have different implementations of the ApplyBridge
function between the legacy and .NET - one with a string argument and one with an IntPtr argument. I opted for changing the parameter type in legacy Xamarin to be able to share more code with .NET.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thats an annoying change.. :(
❌ [PR Build] Tests failed on Build ❌Tests failed on Build. API diff✅ API Diff from stable View API diffAPI & Generator diff✅ API Diff (from PR only) (no change) GitHub pagesResults can be found in the following github pages (it might take some time to publish): Test results1 tests failed, 135 tests passed.Failed tests
Pipeline on Agent XAMBOT-1104.BigSur' |
Test failure is unrelated (https://github.com/xamarin/maccore/issues/2414). |
I had to change the first argument from 'string' to 'IntPtr', because 'string'
isn't blittable. In order to diverge the code paths as little as possible, I
also made this change for the legacy Xamarin version.
Ref #10470.