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

[Photos] Update bindings for Xcode 13.0 beta 1 and beta 2 #12163

Merged
merged 7 commits into from
Jul 30, 2021

Conversation

rachelkang
Copy link
Contributor

No beta 3 updates

@rachelkang rachelkang added the note-highlight Worth calling out specifically in release notes label Jul 21, 2021
@rachelkang rachelkang added this to the xcode13.0 milestone Jul 21, 2021
src/photos.cs Outdated
Comment on lines 1182 to 1188
[TV (15,0), Mac (12,0), iOS (15,0)]
[Export ("localIdentifierMappingsForCloudIdentifiers:")]
NSDictionary<PHCloudIdentifier, PHLocalIdentifierMapping> LocalIdentifierMappingsForCloudIdentifiers (PHCloudIdentifier[] cloudIdentifiers);

[TV (15,0), Mac (12,0), iOS (15,0)]
[Export ("cloudIdentifierMappingsForLocalIdentifiers:")]
NSDictionary<NSString, PHCloudIdentifierMapping> CloudIdentifierMappingsForLocalIdentifiers (string[] localIdentifiers);
Copy link
Member

Choose a reason for hiding this comment

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

You need to add MacCatalyst (15,0) else it will be using the default min version.

Comment on lines 1191 to 1192
[Export ("localIdentifiersForCloudIdentifiers:")]
string[] GetLocalIdentifiers (PHCloudIdentifier[] cloudIdentifiers);
Copy link
Member

Choose a reason for hiding this comment

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

Do we want this to be added in MacCatalyst if it is deprecated, We should add NotMacCatalyst if we are deprecating. Is it deprecated on iOS and Tv?

Copy link
Contributor

Choose a reason for hiding this comment

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

yup, it looks like this needs a [NoTV][NoiOS][NoMacCatalyst] since they are unlikely to be both added and deprecated
and if that's the case then it's generally better not to include them anyway

[Export ("localIdentifiersForCloudIdentifiers:")]
string[] GetLocalIdentifiers (PHCloudIdentifier[] cloudIdentifiers);

[Deprecated (PlatformName.MacOSX, 12, 0, message: "Use 'cloudIdentifierMappingsForCloudIdentifiers:' instead.")]
Copy link
Member

Choose a reason for hiding this comment

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

Same.

src/photos.cs Outdated
[Export ("cloudIdentifiersForLocalIdentifiers:")]
PHCloudIdentifier[] GetCloudIdentifiers (string[] localIdentifiers);

[Deprecated (PlatformName.MacOSX, 12, 0, message: "Use 'PHPhotosErrorIdentifierNotFound' instead.")]
Copy link
Member

Choose a reason for hiding this comment

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

Same

@@ -356,7 +358,9 @@ public enum PHProjectSectionType : long {
[Native]
[ErrorDomain ("PHLivePhotoEditingErrorDomain")]
public enum PHLivePhotoEditingError : long {
[Deprecated (PlatformName.MacOSX, 10, 15, message: "Use 'InternalError' instead.")]
Copy link
Contributor

Choose a reason for hiding this comment

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

the suggested alternative is inside a different enum, which might be hard to use. Sadly not much we can do about it :(

However we should name that enum Use 'PHPhotosError.InternalError' instead.

Unknown,
[Deprecated (PlatformName.MacOSX, 10, 15, message: "Use 'UserCancelled' instead.")]
Copy link
Contributor

Choose a reason for hiding this comment

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

same, prefix value with PHPhotosError.

UserCancelled = 3072,
LibraryVolumeOffline = 3114,
RelinquishingLibraryBundleToWriter = 3142,
SwitchingSystemPhotoLibrary = 3143,
[TV (14,0), Mac (11,0), iOS (14,0)]
Copy link
Contributor

Choose a reason for hiding this comment

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

It's a special case but we do not annotate error codes with OS versions.

Why ? They are are output-only and, as enum values, they do not have to exists to be used. E.g.

var error = CallApi ();
switch (error)
case PHPhotosError. NetworkAccessRequired:
    // it does not make sense to add a version check here
    // and we don't want compiler/tooling warnings for them if we don't 
    Console.WriteLine ("Network Access Required");
    break;
// ... more cases ...
default:
    Console.WriteLine ($"Error {error}");
    break;
}

It's also a bunch of (not really useful) metadata to include inside platform assemblies.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that makes sense, thank you! removing now

src/photos.cs Outdated
@@ -146,9 +146,14 @@ interface PHAsset {
[Export ("playbackStyle", ArgumentSemantic.Assign)]
PHAssetPlaybackStyle PlaybackStyle { get; }

[Deprecated (PlatformName.MacOSX, 12, 0, message: "Use 'PHPhotosErrorIdentifierNotFound' instead.")]
Copy link
Contributor

Choose a reason for hiding this comment

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

missing dot . -> PHPhotosError.IdentifierNotFound

src/photos.cs Outdated

[TV (15,0), Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
[Field ("PHLocalIdentifiersErrorKey")]
NSString PHLocalIdentifiersErrorKey { get; }
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure if it's the best place for that key
but it's not named correctly, IOW you do not want to use PHPhotoLibrary.PHLocalIdentifiersErrorKey
minimally remove PH prefix
also check if other constants exists - there might be a better place for this one (or not)

Copy link
Member

Choose a reason for hiding this comment

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

WE already did that :) That key is only for when the indentifer is not matched and we noticed that the only Object with methods for identifiers is this class, so it would be something like:

PHPhotoLibrary.LocalIdentifierMappingsForCloudIdentifiers(.., out var error);
// access the error info
error.UserInfo[PHPhotoLibrary.LocalIdentifiersErrorKey]

Yet, I did not know that @rachelkang was going to add those two methods as a Category in a diff object, I would have added them in the library and not in PHPhotoLibrary_CloudIdentifiers. If we want a diff class for the category, lets move the key there, else lets move the category methods to PHPhotoLibrary. My preference is PHPhotoLibrary but I'm happy either way.

Copy link
Contributor

Choose a reason for hiding this comment

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

sounds good - but the

remove PH prefix
remains :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed the prefix!

Let me know if I should definitively move the key to PHPhotoLibrary_CloudIdentifiers or move the category methods to PHPhotoLibrary. Moving neither for now, although I think it would make sense to move the key to PHPhotoLibrary_CloudIdentifiers where the category methods are. I put the category methods there because the older versions of them (deprecated) also live there

Comment on lines 1191 to 1192
[Export ("localIdentifiersForCloudIdentifiers:")]
string[] GetLocalIdentifiers (PHCloudIdentifier[] cloudIdentifiers);
Copy link
Contributor

Choose a reason for hiding this comment

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

yup, it looks like this needs a [NoTV][NoiOS][NoMacCatalyst] since they are unlikely to be both added and deprecated
and if that's the case then it's generally better not to include them anyway

src/photos.cs Outdated
[NoiOS][NoTV]
[Unavailable (PlatformName.MacCatalyst)]
[TV (15,0)]
[iOS (15,0)]
[Advice ("This API is not available when using UIKit on macOS.")]
Copy link
Contributor

Choose a reason for hiding this comment

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

that needs to be removed as you already removed the [Unavailable (PlatformName.MacCatalyst)]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The [Advice]? Doesn't that apply to macOS?

Copy link
Member

Choose a reason for hiding this comment

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

"UIKit on macOS" => Mac Catalyst (it's an old name).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah, good to know! thanks!

src/photos.cs Outdated
[Category]
[Unavailable (PlatformName.MacCatalyst)]
[Advice ("This API is not available when using UIKit on macOS.")]
Copy link
Contributor

Choose a reason for hiding this comment

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

that needs to be removed as you already removed the [Unavailable (PlatformName.MacCatalyst)]

src/photos.cs Outdated
[Advice ("This API is not available when using UIKit on macOS.")]
[BaseType (typeof (NSObject))]
[DisableDefaultCtor]
interface PHCloudIdentifier : NSSecureCoding {

[Deprecated (PlatformName.MacOSX, 12, 0, message: "Use 'PHPhotosErrorIdentifierNotFound' instead.")]
Copy link
Contributor

Choose a reason for hiding this comment

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

missing dot .

src/Photos/Enums.cs Show resolved Hide resolved
src/photos.cs Show resolved Hide resolved
src/photos.cs Outdated
[NoiOS][NoTV]
[Unavailable (PlatformName.MacCatalyst)]
[TV (15,0)]
[iOS (15,0)]
[Advice ("This API is not available when using UIKit on macOS.")]
Copy link
Member

Choose a reason for hiding this comment

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

"UIKit on macOS" => Mac Catalyst (it's an old name).

Invalid = -1,
#endif
InternalError = -1,
Copy link
Contributor

Choose a reason for hiding this comment

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

Will having 2 enums with the value -1 cause issues?

Copy link
Member

Choose a reason for hiding this comment

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

Nope, it's totally valid to have multiple enum fields with the same numerical value.

Copy link
Member

Choose a reason for hiding this comment

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

Oh wait, the [Deprecated] attribute goes inside the #if as well.

src/photos.cs Outdated
@@ -1423,4 +1445,28 @@ interface PHCloudIdentifier : NSSecureCoding {
[Export ("initWithStringValue:")]
IntPtr Constructor (string stringValue);
}

[TV (15,0), Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
[BaseType (typeof(NSObject))]
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
[BaseType (typeof(NSObject))]
[BaseType (typeof (NSObject))]

small

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed! having seen both spacing styles all over (even in this file), I'm curious if this is the actual stylistic guideline we should stick with?

src/photos.cs Outdated
}

[TV (15,0), Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
[BaseType (typeof(NSObject))]
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
[BaseType (typeof(NSObject))]
[BaseType (typeof (NSObject))]

small also

src/photos.cs Outdated
[NoTV][NoiOS]
[Field ("PHLocalIdentifierNotFound")]
NSString LocalIdentifierNotFound { get; }

[TV (15, 0), Mac (12, 0), iOS (15, 0), MacCatalyst (15,0)]
Copy link
Contributor

Choose a reason for hiding this comment

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

Extra extra small but maybe try to be consistent with the spacing in the attribute versions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nice catch, thanks!

Invalid = -1,
#endif
InternalError = -1,
Copy link
Member

Choose a reason for hiding this comment

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

Oh wait, the [Deprecated] attribute goes inside the #if as well.

@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

2 tests failed, 87 tests passed.

Failed tests

  • monotouch-test/Mac Catalyst/Debug [dotnet]: Failed (Tests run: 2629 Passed: 2491 Inconclusive: 35 Failed: 2 Ignored: 136)
  • link sdk/Mac Catalyst/Debug [dotnet]: Failed (Tests run: 129 Passed: 105 Inconclusive: 6 Failed: 1 Ignored: 23)

Pipeline on Agent XAMBOT-1104.BigSur'
Merge addedb1 into 23d3fa5

src/photos.cs Outdated
[BaseType (typeof (PHPhotoLibrary))]
interface PHPhotoLibrary_CloudIdentifiers {

[Mac (12,0)]
[Export ("localIdentifierMappingsForCloudIdentifiers:")]
NSDictionary<PHCloudIdentifier, PHLocalIdentifierMapping> LocalIdentifierMappingsForCloudIdentifiers (PHCloudIdentifier[] cloudIdentifiers);
Copy link
Contributor

Choose a reason for hiding this comment

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

-> GetLocalIdentifierMappings

  • prefix with Get so there's a verb/action in the method name
  • remove ForCloudIdentifiers suffix, it's the parameter

src/photos.cs Outdated

[Mac (12,0)]
[Export ("cloudIdentifierMappingsForLocalIdentifiers:")]
NSDictionary<NSString, PHCloudIdentifierMapping> CloudIdentifierMappingsForLocalIdentifiers (string[] localIdentifiers);
Copy link
Contributor

Choose a reason for hiding this comment

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

-> GetCloudIdentifierMappings for the same reasons as above

src/photos.cs Outdated
[BaseType (typeof (NSObject))]
[DisableDefaultCtor]
interface PHCloudIdentifier : NSSecureCoding {

[Deprecated (PlatformName.MacOSX, 12, 0, message: "Use 'PHPhotosError.IdentifierNotFound' instead.")]
[NoTV, NoiOS]
Copy link
Contributor

Choose a reason for hiding this comment

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

you can add [NoMacCatalyst] like the cases above

src/photos.cs Show resolved Hide resolved
src/Photos/Enums.cs Show resolved Hide resolved
@@ -182,6 +182,8 @@ public enum PHAssetCollectionSubtype : long {
SmartAlbumLongExposures = 215,
[iOS (13,0)][TV(13,0)][Mac (10,15)]
SmartAlbumUnableToUpload = 216,
[iOS (15,0), TV (15,0), Mac (12,0)]
Copy link
Contributor

Choose a reason for hiding this comment

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

looks like it should also have [MacCatalyst (15,0)]

@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

2 tests failed, 87 tests passed.

Failed tests

  • monotouch-test/Mac Catalyst/Debug [dotnet]: Failed (Tests run: 2629 Passed: 2485 Inconclusive: 35 Failed: 3 Ignored: 141)
  • monotouch-test/tvOS - simulator/Debug (LinkSdk): Failed

Pipeline on Agent XAMBOT-1097.BigSur'
Merge c7f8c25 into 28bb8bc

@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

12 tests failed, 77 tests passed.

Failed tests

  • xammac tests/Mac Modern/Debug: Failed (Test run failed.
    Tests run: 2463 Passed: 2407 Inconclusive: 10 Failed: 1 Ignored: 55)
  • xammac tests/Mac Modern/Release: Failed (Test run failed.
    Tests run: 2460 Passed: 2403 Inconclusive: 10 Failed: 1 Ignored: 56)
  • xammac tests/Mac Modern/Release (all optimizations): Failed (Test run failed.
    Tests run: 2460 Passed: 2402 Inconclusive: 10 Failed: 1 Ignored: 57)
  • xcframework-test/Mac Catalyst/Debug: TimedOut (Execution timed out after 1200 seconds.
    No test log file was produced)
  • monotouch-test/iOS Unified 64-bits - simulator/Debug: Failed
  • monotouch-test/iOS Unified 64-bits - simulator/Debug (LinkSdk): Failed
  • monotouch-test/iOS Unified 64-bits - simulator/Debug (static registrar): Failed
  • monotouch-test/iOS Unified 64-bits - simulator/Release (all optimizations): Failed
  • monotouch-test/tvOS - simulator/Debug: Failed
  • monotouch-test/tvOS - simulator/Debug (LinkSdk): Failed
  • monotouch-test/tvOS - simulator/Debug (static registrar): Failed
  • monotouch-test/tvOS - simulator/Release (all optimizations): Failed

Pipeline on Agent XAMBOT-1100.BigSur'
Merge a516b77 into 3336910

@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 89 tests passed 🎉

Pipeline on Agent XAMBOT-1099.BigSur'
Merge c4ad54e into 448cc6e

@mandel-macaque mandel-macaque merged commit af2fea2 into xamarin:main Jul 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
note-highlight Worth calling out specifically in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants