xamarin / xamarin-macios

.NET for iOS, Mac Catalyst, macOS, and tvOS provide open-source bindings of the Apple SDKs for use with .NET managed languages such as C#
Other
2.48k stars 518 forks source link

[AVFoundation] APIs that take AVFileTypes are bound as string without type safe helper variants #15693

Open tipa opened 2 years ago

tipa commented 2 years ago

I am in the process of migrating my apps from legacy Xamarin to .NET6. Previously, I could use AVFileType.Mpeg4 to set the property OutputFileType of AVAssetExportSession. Now the AVFileType type has gone and I have to use AVFileTypes.Mpeg4.GetConstant() instead (correct?).

Wouldn't it make sense to then also change the OutputFileType (and SupportedFileTypes) property types of AVAssetExportSession to AVFileType? and AVFileType[] respectively?

This would then also better match the types documented by Apple: https://developer.apple.com/documentation/avfoundation/avassetexportsession/1387110-outputfiletype For developers it is not intuitive to use a method on an enum to get the string required.

Related issue: https://github.com/xamarin/xamarin-macios/issues/8735 https://github.com/xamarin/xamarin-macios/issues/15683

chamons commented 2 years ago

I can confirm, we have those bound as string OutputFileType today. In other cases with smart enums we so something like:

        [Export ("type")]
        NSString WeakType { get;  }

        public AVMetadataObjectType Type {
            get {
                return AVMetadataObjectTypeExtensions.GetValue (WeakType);
            }

So this is one area we can improve the bindings, though getting a name for the type safe version will be tricky.