-
Notifications
You must be signed in to change notification settings - Fork 507
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
[AVFoundation] Add a few strongly typed enums #18022
[AVFoundation] Add a few strongly typed enums #18022
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…essed by the generator. This eliminates the need for a good chunk of manual code. Also add a few extra convenience overloads of AVAudioSession.SetCategory.
0a209ae
to
1b79bce
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rolfbjarne Just to make sure I'm following:
- By implementing strongly typed enums vs. regular enums (like before), we eliminate the need for the switch case to map the enum item to the actual value because the underlying value of strongly typed enums is the value we set it to be (in this case the AVAudioSession category/mode) as opposed to being backed by a int value in a regular enum.
- Another thing that caught my attention is that before the methods for SetActive/SetCategory were implemented but now they are not? My current understanding is that again since before we were using a regular enum, there were not appropriate methods to be called upon the regular enum values directly. But now with the strongly typed enum present, we get the appropriate data type immediately so there is no need for a buffer between the enum and calling the selector?
src/avfoundation.cs
Outdated
[Watch (5, 0), TV (12, 0), iOS (12, 0)] | ||
[MacCatalyst (13, 1)] | ||
[Field ("AVAudioSessionModeVoicePrompt")] | ||
VoiceePrompt, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VoiceePrompt, | |
VoicePrompt, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@haritha-mohan good catch, thanks! And fixed :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After Haritha's suggestion
Not quite, the generator will generate an equivalent switch case for strong enums, with extension methods to convert between NSString and the enum. You can see this in the API diff: https://vsdrop.corp.microsoft.com/file/v1/xamarin-macios/detected-changes/20230412.6/7617061-1/;/previous-api-comparison/diff/dotnet/Microsoft.iOS.Ref/ref/net7.0/Microsoft.iOS.html
These are the extension methods to convert between the AVAudioSessionCategory enum and NSString.
Not quite either: the SetActive/SetCategory methods are now generated by the generator, in the changes for src/avfoundation.cs there are new SetActive/SetCategory members that match the old ones in src/AVFoundation/AVAudioSession.cs (and use the GetConstant extension method mentioned in the previous post to convert from the enum in the managed method signature to the NSString in the native method signature). |
✅ API diff for current PR / commitLegacy Xamarin (No breaking changes).NET (No breaking changes)✅ API diff vs stableLegacy Xamarin (No breaking changes).NET (No breaking changes)ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
💻 [PR Build] Tests on macOS M1 - Mac Ventura (13.0) passed 💻✅ All tests on macOS M1 - Mac Ventura (13.0) passed. Pipeline on Agent |
💻 [CI Build] Windows Integration Tests passed 💻✅ All Windows Integration Tests passed. Pipeline on Agent |
💻 [PR Build] Tests on macOS M1 - Mac Big Sur (11.5) passed 💻✅ All tests on macOS M1 - Mac Big Sur (11.5) passed. Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
🚀 [CI Build] Test results 🚀Test results✅ All tests passed on VSTS: simulator tests. 🎉 All 225 tests passed 🎉 Tests counts✅ bcl: All 69 tests passed. Html Report (VSDrops) Download Pipeline on Agent |
Add strongly typed enums for:
This makes it possible to delete a good chunk of manual binding code.
Also add a few extra convenience overloads of AVAudioSession.SetCategory.