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

[.NET/CoreFoundation] Use [UnmanagedCallersOnly] instead of [MonoPInvokeCallback] for the CGPDFDictionaryApplyFunction function. #12956

Merged

Conversation

rolfbjarne
Copy link
Member

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.

…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.
@rolfbjarne rolfbjarne added not-notes-worthy Ignore for release notes run-dotnet-tests Run all the .NET tests labels Oct 7, 2021
// 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);
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Member

@mandel-macaque mandel-macaque left a 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.. :(

@vs-mobiletools-engineering-service2
Copy link
Collaborator

❌ [PR Build] Tests failed on Build ❌

Tests failed on Build.

API diff

✅ API Diff from stable

View API diff

API & Generator diff

API Diff (from PR only) (no change)
Generator Diff (only version changes)

GitHub pages

Results can be found in the following github pages (it might take some time to publish):

Test results

1 tests failed, 135 tests passed.

Failed tests

  • link sdk/Mac Catalyst [dotnet]/Debug [dotnet]: TimedOut (Execution timed out after 1200 seconds.
    No test log file was produced)

Pipeline on Agent XAMBOT-1104.BigSur'
Merge dfe53e6 into b9de02c

@rolfbjarne
Copy link
Member Author

Test failure is unrelated (https://github.com/xamarin/maccore/issues/2414).

@rolfbjarne rolfbjarne merged commit 7a46df3 into xamarin:main Oct 8, 2021
@rolfbjarne rolfbjarne deleted the dotnet-unmanagedcallers-cgpdfdictionary branch October 8, 2021 05:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
not-notes-worthy Ignore for release notes run-dotnet-tests Run all the .NET tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants