Skip to content

Commit

Permalink
[AppKit/MediaExtension/introspection] Fix issues found with introspec…
Browse files Browse the repository at this point in the history
…tion on Sequoia. (#21587)

* Mark a few MediaExtension fields as Notification fields.
* Remove extreanous NSSharingCollaborationModeRestriction.AlertRecoverySuggestionButtonLaunchUrl setter.
* introspection: ignore methods that start with '_Init', aren't publicly
  visible, and bind an Objective-C constructor when verifying that a managed
  method doesn't bind an Objective-C constructor.
  • Loading branch information
rolfbjarne authored Nov 8, 2024
1 parent 2e9273a commit 9ea3cff
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
10 changes: 9 additions & 1 deletion src/appkit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28757,7 +28757,15 @@ interface NSSharingCollaborationModeRestriction : NSSecureCoding, NSCopying {
string AlertRecoverySuggestionButtonTitle { get; }

[Export ("alertRecoverySuggestionButtonLaunchURL", ArgumentSemantic.Copy), NullAllowed]
NSUrl AlertRecoverySuggestionButtonLaunchUrl { get; set; }
#if XAMCORE_5_0
NSUrl AlertRecoverySuggestionButtonLaunchUrl { get; }
#else
NSUrl AlertRecoverySuggestionButtonLaunchUrl {
get;
[Obsolete ("Do not use, the native class doesn't have this setter.")]
set;
}
#endif

[Export ("initWithDisabledMode:")]
NativeHandle Constructor (NSSharingCollaborationMode disabledMode);
Expand Down
3 changes: 3 additions & 0 deletions src/mediaextension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@ interface IMEVideoDecoder {}
[NoWatch, NoTV, NoiOS, Mac (15,0), NoMacCatalyst]
[Static]
interface MEVideoDecoderFields {
[Notification]
[Field ("MEVideoDecoderReadyForMoreMediaDataDidChangeNotification")]
NSString ReadyForMoreMediaDataDidChangeNotification { get; }
}
Expand Down Expand Up @@ -759,9 +760,11 @@ interface MERawProcessor
[Static]
interface MERawProcessorFields
{
[Notification]
[Field ("MERAWProcessorValuesDidChangeNotification")]
NSString ValuesDidChangeNotification { get; }

[Notification]
[Field ("MERAWProcessorReadyForMoreMediaDataDidChangeNotification")]
NSString ReadyForMoreMediaDataDidChangeNotification { get; }
}
Expand Down
17 changes: 15 additions & 2 deletions tests/introspection/ApiSelectorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,14 @@ protected virtual bool Skip (Type type, string selectorName)
}
break;
#endif // __MACCATALYST__
#if !XAMCORE_5_0
case "NSSharingCollaborationModeRestriction":
switch (selectorName) {
case "setAlertRecoverySuggestionButtonLaunchURL:":// binding mistake
return true;
}
break;
#endif
}

// old binding mistake
Expand Down Expand Up @@ -1213,8 +1221,13 @@ void CheckInit (Type t, MethodBase m, string name)
if (!init)
ReportError ("Selector {0} used on a constructor (not a method) on {1}", name, t.FullName);
} else {
if (init)
ReportError ("Selector {0} used on a method (not a constructor) on {1}", name, t.FullName);
if (init) {
var isPubliclyVisible = m.IsPublic || m.IsFamily || m.IsFamilyOrAssembly;
if (isPubliclyVisible || !m.Name.StartsWith ("_Init", StringComparison.Ordinal)) {
// ignore methods that start '_Init' and aren't publicly exposed, they're probably used by manually bound ctors.
ReportError ($"Selector {name} used on the method '{m.Name}' (not a constructor) on {t.FullName}");
}
}
}
}

Expand Down

6 comments on commit 9ea3cff

@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.