[AVFoundation] Fix signature for LoadTrack*/LoadTracks* methods. Fixes #25606#25653
[AVFoundation] Fix signature for LoadTrack*/LoadTracks* methods. Fixes #25606#25653rolfbjarne wants to merge 10 commits into
Conversation
…ixes #25606. Fix the completion handler parameter types for LoadTrack/LoadTracksWithMediaType/ LoadTracksWithMediaCharacteristic methods in: - AVAsset (AVCompositionTrack -> AVAssetTrack) - AVMutableMovie (AVMovieTrack -> AVMutableMovieTrack) - AVFragmentedMovie (AVMutableCompositionTrack -> AVFragmentedMovieTrack) - AVComposition (AVMutableCompositionTrack -> AVCompositionTrack) Fixes #25606. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…d signatures. Tests cover the new correctly-typed callback overloads for: - AVAsset.LoadTrack2, LoadTrackWithMediaCharacteristics, LoadTracksWithMediaType - AVMovie.LoadTrack, LoadTracksWithMediaType, LoadTracksWithMediaCharacteristic - AVMutableMovie.LoadTrack2, LoadTracksWithMediaType, LoadTracksWithMediaCharacteristic - AVComposition.LoadTrack, LoadTracksWithMediaType, LoadTracksWithMediaCharacteristic Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
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 was marked as outdated.
This comment was marked as outdated.
This comment has been minimized.
This comment has been minimized.
Move #if !__TVOS__ outside the #region directives so they nest properly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
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.
…validation. Add the attribute to the known-and-skipped list in the method attribute validation loop, fixing BI1007 'Unknown attribute' errors during binding generation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
This comment has been minimized.
This comment has been minimized.
|
/review |
|
✅ .NET for Apple Platforms PR Reviewer completed successfully! |
✅ [PR Build #1f90e6a] Build passed (Detect API changes) ✅Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
@copilot ## Review Summary
Reviewed the AVFoundation binding fixes for LoadTrack*/LoadTracks* method signatures. The approach is sound — obsoleting incorrectly-typed methods behind XAMCORE_5_0 guards and adding properly-typed replacements with named delegate types. The use of [OverloadResolutionPriority (-1)] on obsolete methods is appropriate to guide callers to the new overloads.
Issues Found:
- ❌ 1 critical error: Copy-paste mistake in an Obsolete message (line 12853)
⚠️ 1 consistency issue: Missing[Async]attribute on AVAsset wrapper (line 5734)
Positive observations:
- Correct use of
XAMCORE_5_0guards for breaking changes - Named delegate types improve API clarity over generic
Action<>delegates - Comprehensive test coverage for all new APIs
- bgen changes properly handle
OverloadResolutionPriorityAttribute - Platform attributes are preserved correctly
Once the two issues are addressed, this will be ready to merge.
Generated by .NET for Apple Platforms PR Reviewer for issue #25653 · 62.4 AIC · ⌖ 8.8 AIC · ⊞ 5.1K
Comment /review to run again
| [Export ("loadTracksWithMediaType:completionHandler:")] | ||
| void LoadTracksWithMediaType (string mediaType, AVAssetLoadTracksCallback completionHandler); | ||
|
|
||
| [Wrap ("LoadTracksWithMediaType (mediaType.GetConstant ()!, completionHandler)")] |
There was a problem hiding this comment.
🤖 [Async] attribute on this [Wrap] method. All the other classes (AVMovie, AVMutableMovie, AVFragmentedMovie, AVComposition) have [Async] on their corresponding LoadTracksWithMediaType (AVMediaTypes, ...) wrap methods (lines 12744, 12871, 13156, 13793), but AVAsset is missing it here.
For consistency and to generate the async variant, add:
[Async]
[Wrap ("LoadTracksWithMediaType (mediaType.GetConstant ()!, completionHandler)")]
void LoadTracksWithMediaType (AVMediaTypes mediaType, AVAssetLoadTracksCallback completionHandler);Rule: Consistency — follow the same pattern within the PR
| #endif | ||
|
|
||
| #if !XAMCORE_5_0 | ||
| [Obsolete ("Call the 'LoadTracksWithMediaType (..., AVMutableMovieLoadTracksCallback)' overload instead (or the 'LoadTracksWithMediaCharacteristic2Async' method).")] |
There was a problem hiding this comment.
🤖 ❌ Binding definition — Copy-paste error in Obsolete message. This obsoletes LoadTracksWithMediaType, so it should refer to LoadTracksWithMediaType2Async, not LoadTracksWithMediaCharacteristic2Async.
Should be: [Obsolete ("Call the 'LoadTracksWithMediaType (..., AVMutableMovieLoadTracksCallback)' overload instead (or the 'LoadTracksWithMediaType2Async' method).")]
Rule: Obsolete messages must be helpful and accurate
There was a problem hiding this comment.
Pull request overview
Fixes AVFoundation LoadTrack*/LoadTracks* bindings whose completion-handler parameter types were incorrect by obsoleting the old signatures (pre-XAMCORE_5_0) and introducing correctly-typed overloads using named delegate callback types. This also updates bgen to preserve OverloadResolutionPriorityAttribute and adds tests/known-failure updates to cover the new APIs.
Changes:
- Add correctly-typed
LoadTrack*/LoadTracks*overloads (plus new named callback delegate types) and obsolete the incorrectly-typed variants behind!XAMCORE_5_0. - Teach bgen to recognize/emit
OverloadResolutionPriorityAttributeand add the required implicit namespace. - Add monotouch runtime tests for the new APIs and update
Documentation.KnownFailures.txtaccordingly.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/monotouch-test/AVFoundation/AVAssetLoadTracksTest.cs | Adds runtime coverage for the new LoadTrack*/LoadTracks* overloads on several AVFoundation types. |
| tests/cecil-tests/Documentation.KnownFailures.txt | Updates the documentation known-failure allowlist for newly introduced (and newly obsolete) members/types. |
| src/bgen/Generator.cs | Adds support for printing OverloadResolutionPriorityAttribute and treating it as a known binding attribute. |
| src/bgen/Caches/NamespaceCache.cs | Adds System.Runtime.CompilerServices as an implicit namespace for generated code. |
| src/bgen/AttributeManager.cs | Adds type-resolution support for System.Runtime.CompilerServices.OverloadResolutionPriorityAttribute. |
| src/avfoundation.cs | Implements the corrected AVFoundation binding surface (new delegates, overloads, and obsoletions). |
| void LoadTrackWithMediaCharacteristics (string mediaCharacteristic, AVAssetLoadTracksCallback completionHandler); | ||
|
|
||
| #if !XAMCORE_5_0 | ||
| [Obsolete ("Call 'LoadTracksWithMediaType (..., AVAssetLoadTracksCallback)' instead (or the 'LoadTracksWithMediaType' method).")] |
| AVMovieTrack [] GetTracks (AVMediaCharacteristics mediaCharacteristic); | ||
|
|
||
| #if !XAMCORE_5_0 | ||
| [Obsolete ("Call the 'LoadTrack (..., AVMovieLoadTracksCallback)' overload instead (or the 'LoadTrack2Async' method).")] |
| #endif | ||
|
|
||
| #if !XAMCORE_5_0 | ||
| [Obsolete ("Call the 'LoadTracksWithMediaType (..., AVMutableMovieLoadTracksCallback)' overload instead (or the 'LoadTracksWithMediaCharacteristic2Async' method).")] |
| void LoadTrack (int trackId, AVCompositionLoadTrackCallback completionHandler); | ||
|
|
||
| #if !XAMCORE_5_0 | ||
| [Obsolete ("Call the 'LoadTracksWithMediaType (..., AVCompositionLoadTracksCallback)' overload instead (or the 'LoadTracksWithMediaType' method).")] |
| void LoadTracksWithMediaType (AVMediaTypes mediaType, AVCompositionLoadTracksCallback completionHandler); | ||
|
|
||
| #if !XAMCORE_5_0 | ||
| [Obsolete ("Call the 'LoadTracksWithMediaCharacteristic (..., AVCompositionLoadTracksCallback)' overload instead (or the 'LoadTracksWithMediaCharacteristic' method).")] |
| using var url = NSUrl.FromFilename (VideoPath); | ||
| using var asset = AVAsset.FromUrl (url); | ||
|
|
||
| var tcs = new TaskCompletionSource<AVAssetTrack?> (); | ||
| asset.LoadTrack2 (1, (track, error) => { | ||
| tcs.TrySetResult (track); | ||
| }); |
| M:AVFoundation.AVAsset.LoadTracksWithMediaType(AVFoundation.AVMediaTypes,AVFoundation.AVAssetLoadTracksCallback) | ||
| M:AVFoundation.AVAsset.LoadTracksWithMediaType(System.String,AVFoundation.AVAssetLoadTracksCallback) | ||
| M:AVFoundation.AVAsset.LoadTracksWithMediaType2Async(System.String) | ||
| M:AVFoundation.AVAsset.LoadTrackWithMediaCharacteristics(System.String,AVFoundation.AVAssetLoadTracksCallback) | ||
| M:AVFoundation.AVAsset.LoadTrackWithMediaCharacteristics2Async(System.String) |
✅ [PR Build #1f90e6a] Build passed (Build packages) ✅Pipeline on Agent |
✅ API diff for current PR / commitNET (empty diffs)✅ API diff vs stableNET (empty diffs)ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
✅ [PR Build #1f90e6a] Build passed (Build macOS tests) ✅Pipeline on Agent |
🔥 [CI Build #1f90e6a] Test results 🔥Test results❌ Tests failed on VSTS: test results 0 tests crashed, 3 tests failed, 204 tests passed. Failures❌ monotouch tests (macOS)1 tests failed, 19 tests passed.Failed tests
Html Report (VSDrops) Download ❌ monotouch tests (tvOS)1 tests failed, 19 tests passed.Failed tests
Html Report (VSDrops) Download ❌ Tests on macOS Tahoe (26) tests1 tests failed, 4 tests passed.Failed tests
Html Report (VSDrops) Download Successes✅ assembly-processing: All 1 tests passed. Html Report (VSDrops) Download macOS tests✅ Tests on macOS Monterey (12): All 5 tests passed. Html Report (VSDrops) Download Linux Build VerificationPipeline on Agent |
The completion handler callbacks for
LoadTrack*/LoadTracks*methods on several AVFoundation classes had incorrect parameter types (e.g.AVMutableCompositionTrackinstead ofAVMovieTrack).This PR:
XAMCORE_5_0)2suffix where naming conflicts arise due to delegate type inheritance relationships (AVAsset, AVMutableMovie)Affected classes:
AVAsset:LoadTrack2,LoadTrackWithMediaCharacteristics,LoadTracksWithMediaTypeAVMovie(category):LoadTrack,LoadTracksWithMediaType,LoadTracksWithMediaCharacteristicAVMutableMovie:LoadTrack2,LoadTracksWithMediaType,LoadTracksWithMediaCharacteristicAVFragmentedMovie(category):LoadTrack,LoadTracksWithMediaType,LoadTracksWithMediaCharacteristicAVComposition(category):LoadTrack,LoadTracksWithMediaType,LoadTracksWithMediaCharacteristicFixes #25606
🤖 Pull request created by Copilot