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

[src] Augment the Native attribute to support custom conversion functions. Fixes #12111. #12488

Conversation

rolfbjarne
Copy link
Member

Augment the Native attribute for enums to support custom conversion functions between
native values and managed values for enums. This makes it possible to have different
values in managed code for an enum compared to native code.

This is necessary to support different native enum values based on the architecture,
because in a few cases Apple has different enum values between x86_64 and ARM64.
Enum values are constants in managed code, and without this support it would be impossible
to translate these correctly to native code.

The updated Native attribute supports two new fields: ConvertToNative and ConvertToManaged,
which are managed functions of a specific signature that the generator will emit
calls to whenever needed to do the appropriate conversion.

Fixes #12111.

…ions. Fixes xamarin#12111.

Augment the Native attribute for enums to support custom conversion functions between
native values and managed values for enums. This makes it possible to have different
values in managed code for an enum compared to native code.

This is necessary to support different native enum values based on the architecture,
because in a few cases Apple has different enum values between x86_64 and ARM64.
Enum values are constants in managed code, and without this support it would be impossible
to translate these correctly to native code.

The updated Native attribute supports two new fields: ConvertToNative and ConvertToManaged,
which are managed functions of a specific signature that the generator will emit
calls to whenever needed to do the appropriate conversion.

Fixes xamarin#12111.
@rolfbjarne rolfbjarne added not-notes-worthy Ignore for release notes run-dotnet-tests Run all the .NET tests labels Aug 19, 2021
@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) (please review changes)
ℹ️ Generator Diff (please review changes)

GitHub pages

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

Test results

3 tests failed, 142 tests passed.

Failed tests

  • monotouch-test/tvOS - simulator/Debug (static registrar) [dotnet]: Failed
  • Generator tests/NUnit: Failed (Execution failed with exit code 1)
  • Generator tests/.NET: Failed (Execution failed with exit code 1)

Pipeline on Agent XAMBOT-1097.BigSur'
Merge f803b21 into 048bee7

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [PR Build] Tests passed on Build. ✅

Tests passed on Build.

API diff

✅ API Diff from stable

View API diff

API & Generator diff

ℹ️ API Diff (from PR only) (please review changes)
ℹ️ Generator Diff (please review changes)

GitHub pages

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

🎉 All 144 tests passed 🎉

Pipeline on Agent XAMBOT-1104.BigSur'
Merge 29a2364 into 6f9a8eb

@rolfbjarne rolfbjarne merged commit 2d4b68b into xamarin:main Aug 20, 2021
@rolfbjarne rolfbjarne deleted the issue-12111-convert-enums-to-native-and-back-again branch August 20, 2021 13:38
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.

Some enums have different values between x64 and arm64 on macOS and Mac Catalyst
3 participants