Skip to content

[generator] Do not zero-extend implied catalyst attributes - #15648

Merged
chamons merged 2 commits into
dotnet:mainfrom
chamons:xcode14-generator-fix
Aug 8, 2022
Merged

[generator] Do not zero-extend implied catalyst attributes#15648
chamons merged 2 commits into
dotnet:mainfrom
chamons:xcode14-generator-fix

Conversation

@chamons

@chamons chamons commented Aug 5, 2022

Copy link
Copy Markdown
Contributor
ILLINK : error MT2362: The linker step 'Registrar' failed during processing: One or more errors occurred. (The type 'Photos.PHPersistentObjectChangeDetails' (used as a return type in Photos.PHPersistentChange.ChangeDetails) is not available in MacCatalyst 16.0 (it was introduced in MacCatalyst 16.0.0). Please build with a newer MacCatalyst SDK (usually done by using the most recent version of Xcode). [/Users/donblas/Programming/xamarin-macios/tests/dotnet/MySimpleApp/MacCatalyst/MySimpleApp.csproj]
  		) (The type 'Photos.PHObjectType' (used as a parameter in Photos.PHPersistentChange.ChangeDetails) is not available in MacCatalyst 16.0 (it was introduced in MacCatalyst 16.0.0). Please build with a newer MacCatalyst SDK (usually done by using the most recent version of Xcode).
  		) (The type 'Photos.PHPersistentChangeFetchResult' (used as a return type in Photos.PHPhotoLibrary.FetchPersistentChanges) is not available in MacCatalyst 16.0 (it was introduced in MacCatalyst 16.0.0). Please build with a newer MacCatalyst SDK (usually done by using the most recent version of Xcode).
  		) (The type 'Photos.PHPersistentChangeToken' (used as a parameter in Photos.PHPhotoLibrary.FetchPersistentChanges) is not available in MacCatalyst 16.0 (it was introduced in MacCatalyst 16.0.0). Please build with a newer MacCatalyst SDK (usually done by using the most recent version of Xcode).

The details of how we fail are written up in this issue but since sharpie never outputs versions in the form of x.y.z where .z is zero we only hit this with generated attributes.

Because of this fact, we can work around it with a generator change.

This commit changes how we "imply" attributes from iOS to Catalyst. As a brief reminder, because of historical bindings we assume anything that has iOS and not a Catalyst really means "treat iOS as if it was also Catalyst".

This work is done in AddImpliedCatalyst and uses CloneFromOtherPlatform to make a copy of an attribute, because there is no easy way to say "I want a copy of this, but with this other platform". CloneFromOtherPlatform used to always call the 3 version (Major, Minor, Revision) constructor, even when the attribute being cloned only used Major.Minor.

However, this caused us to "zero extend" the version with another zero, which triggers this bug, so stop doing that. Uglier code in the generator, but it works better.

- In the [Xcode 14 Photo PR](dotnet#15608) a test is failing with this:

```
ILLINK : error MT2362: The linker step 'Registrar' failed during processing: One or more errors occurred. (The type 'Photos.PHPersistentObjectChangeDetails' (used as a return type in Photos.PHPersistentChange.ChangeDetails) is not available in MacCatalyst 16.0 (it was introduced in MacCatalyst 16.0.0). Please build with a newer MacCatalyst SDK (usually done by using the most recent version of Xcode). [/Users/donblas/Programming/xamarin-macios/tests/dotnet/MySimpleApp/MacCatalyst/MySimpleApp.csproj]
  		) (The type 'Photos.PHObjectType' (used as a parameter in Photos.PHPersistentChange.ChangeDetails) is not available in MacCatalyst 16.0 (it was introduced in MacCatalyst 16.0.0). Please build with a newer MacCatalyst SDK (usually done by using the most recent version of Xcode).
  		) (The type 'Photos.PHPersistentChangeFetchResult' (used as a return type in Photos.PHPhotoLibrary.FetchPersistentChanges) is not available in MacCatalyst 16.0 (it was introduced in MacCatalyst 16.0.0). Please build with a newer MacCatalyst SDK (usually done by using the most recent version of Xcode).
  		) (The type 'Photos.PHPersistentChangeToken' (used as a parameter in Photos.PHPhotoLibrary.FetchPersistentChanges) is not available in MacCatalyst 16.0 (it was introduced in MacCatalyst 16.0.0). Please build with a newer MacCatalyst SDK (usually done by using the most recent version of Xcode).
```

The details of how we fail are written up in [this issue](dotnet#15643) but since sharpie never outputs versions in the form of x.y.z where .z is zero we only hit this with generated attributes.

Because of this fact, we can work around it with a generator change.

This commit changes how we "imply" attributes from iOS to Catalyst. As a brief reminder, because of historical bindings we assume anything that has iOS and not a Catalyst really means "treat iOS as if it was also Catalyst".

This work is done in `AddImpliedCatalyst` and uses `CloneFromOtherPlatform` to make a copy of an attribute, because there is no easy way to say "I want a copy of this, but with this other platform". `CloneFromOtherPlatform` used to always call the 3 version (Major, Minor, Revision) constructor, even when the attribute being cloned only used Major.Minor.

However, this caused us to "zero extend" the version with another zero, which triggers this bug, so stop doing that. Uglier code in the generator, but it works better.
@chamons

chamons commented Aug 5, 2022

Copy link
Copy Markdown
Contributor Author

This needs to be cherry-picked to xcode14 after landing to unblock #15608.

@chamons chamons added the not-notes-worthy Ignore for release notes label Aug 5, 2022
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@Therzok Therzok closed this Aug 8, 2022
@Therzok Therzok reopened this Aug 8, 2022
@Therzok

Therzok commented Aug 8, 2022

Copy link
Copy Markdown
Contributor

Oooops, I think I clicked the wrong PR.

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

ðŸ”Ĩ [PR Build] Build failed ðŸ”Ĩ

Build failed for the job 'Detect API changes'

Pipeline on Agent
Hash: [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

ðŸ”Ĩ Unable to find the contents for the comment: D:\a\1\s\change-detection\results\gh-comment.md does not exist :fire

Pipeline on Agent
Hash: e05f348a4d4611b780de879dbbd8c9e1fb8d3820 [PR build]

@chamons

chamons commented Aug 8, 2022

Copy link
Copy Markdown
Contributor Author

mac_binding_project passes locally for me.

@chamons
chamons merged commit 20825e1 into dotnet:main Aug 8, 2022
@chamons

chamons commented Aug 8, 2022

Copy link
Copy Markdown
Contributor Author

/sudo backport xcode14

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

Backport Job to branch xcode14 Created! The magic is happening here

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

Hooray! Backport succeeded! Please see https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=6527798 for more details.

@chamons
chamons deleted the xcode14-generator-fix branch August 8, 2022 14:30
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants