Skip to content

Commit

Permalink
[src] Fix definition of AVSampleCursorAudioDependencyInfo for Mac Cat…
Browse files Browse the repository at this point in the history
…alyst. (#20781)

We need the backwards compatible code for the
AVSampleCursorAudioDependencyInfo struct (i.e. use the
AVSampleCursorAudioDependencyInfo_Blittable version), so adjust the ifdefs
accordingly - which wasn't obvious at first, because __IOS__ is defined for
Mac Catalyst.

Also fix the corresponding test, because it would cache the result of
computing whether a struct was blittable or not, but that's not true across
platforms ("AVSampleCursorAudioDependencyInfo" is blittable on iOS, but not on
Mac Catalyst). The result was that the test would incorrectly pass if we
processed Microsoft.iOS.dll before Microsoft.MacCatalyst.dll. The fix is to
cache per platform, instead of using a global cache.
  • Loading branch information
rolfbjarne authored Jun 26, 2024
1 parent 02e14e6 commit 9b7ff19
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/AVFoundation/AVTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ public bool IsIndependentlyDecodable {
public nint PacketRefreshCount;
}

#if !XAMCORE_5_0 && !__IOS__ && !__TVOS__
#if !XAMCORE_5_0 && !(__IOS__ && !__MACCATALYST__) && !__TVOS__
[StructLayout (LayoutKind.Sequential)]
[NativeName ("AVSampleCursorAudioDependencyInfo")]
#if COREBUILD
Expand Down
2 changes: 1 addition & 1 deletion src/avfoundation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5365,7 +5365,7 @@ interface AVSampleCursor : NSCopying {


[Export ("currentSampleAudioDependencyInfo")]
#if XAMCORE_5_0 || IOS || TVOS
#if XAMCORE_5_0 || (IOS && !__MACCATALYST__) || TVOS
AVSampleCursorAudioDependencyInfo CurrentSampleAudioDependencyInfo { get; }
#else
[Internal]
Expand Down
9 changes: 6 additions & 3 deletions tests/cecil-tests/BlittablePInvokes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -268,13 +268,16 @@ public void CheckForNonBlittablePInvokes ()
var failures = new Dictionary<string, NonBlittablePInvokesFailure> ();
var pinvokes = new List<(AssemblyDefinition Assembly, MethodDefinition Method)> ();

foreach (var info in Helper.NetPlatformImplementationAssemblyDefinitions)
var blitCaches = new Dictionary<AssemblyDefinition, Dictionary<string, BlitAndReason>> ();
foreach (var info in Helper.NetPlatformImplementationAssemblyDefinitions) {
pinvokes.AddRange (AllPInvokes (info.Assembly).Select (v => (info.Assembly, v)));

blitCaches [info.Assembly] = new Dictionary<string, BlitAndReason> ();
}

Assert.That (pinvokes.Count, Is.GreaterThan (0), "Must have some P/Invokes at least");

var blitCache = new Dictionary<string, BlitAndReason> ();
var results = pinvokes.Select (pi => IsMethodBlittable (pi.Assembly, pi.Method, blitCache)).Where (r => !r.IsBlittable).ToArray ();
var results = pinvokes.Select (pi => IsMethodBlittable (pi.Assembly, pi.Method, blitCaches [pi.Assembly])).Where (r => !r.IsBlittable).ToArray ();
foreach (var result in results) {
failures [result.Method.FullName] = new (result.Method.FullName, result.Method.RenderLocation (), result.Result.ToString ());
}
Expand Down

7 comments on commit 9b7ff19

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

Please sign in to comment.