[xtro] Report missing-protocol-conformance when protocols are defined… (#3187)

- Fixes bug #59272: [xtro] Report !missing-protocol-conformance! when protocols are defined in categories
(https://bugzilla.xamarin.com/show_bug.cgi?id=59272)
- Implemented missing protocol conformances based on tool's new data.
- Remove Internal check from VisitObjCCategoryDecl and VisitObjCInterfaceDecl
- Ignore previewItemTitle failure (normal since it's optional)
- Only skip UIStateRestoring for subclasses of UIViewController
- Ignore UIStateRestoring test on watchOS (UIViewController not available)
- Remove protocol conformances that generated wrong availability attributes (https://github.com/xamarin/xamarin-macios/issues/3213)
- Avoid new virtual or virtual when adding protocol conformance (https://github.com/xamarin/xamarin-macios/issues/3217)
This commit is contained in:
Vincent Dondain 2018-01-18 13:41:09 -05:00 коммит произвёл GitHub
Родитель 75e851fdda
Коммит 4da8016db4
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
26 изменённых файлов: 172 добавлений и 30 удалений

Просмотреть файл

@ -4205,11 +4205,7 @@ namespace XamCore.AVFoundation {
[BaseType (typeof (AVAsset), Name="AVURLAsset")]
// 'init' returns NIL
[DisableDefaultCtor]
interface AVUrlAsset {
[TV (10, 2), Mac (10, 12, 4), iOS (10, 3)]
[Export ("mayRequireContentKeysForMediaDataProcessing")]
bool MayRequireContentKeysForMediaDataProcessing { get; }
interface AVUrlAsset : AVContentKeyRecipient {
[Export ("URL", ArgumentSemantic.Copy)]
NSUrl Url { get; }
@ -11517,7 +11513,13 @@ namespace XamCore.AVFoundation {
bool ReadyForMoreMediaData { [Bind ("isReadyForMoreMediaData")] get; }
[Export ("enqueueSampleBuffer:")]
void Enqueue (CMSampleBuffer sampleBuffer);
#if !XAMCORE_4_0
[Wrap ("Enqueue (sampleBuffer)", IsVirtual = true)]
[Obsolete ("Use the 'Enqueue' method instead.")]
void EnqueueSampleBuffer (CMSampleBuffer sampleBuffer);
#endif
[Export ("flush")]
void Flush ();
@ -11526,11 +11528,22 @@ namespace XamCore.AVFoundation {
void FlushAndRemoveImage ();
[Export ("requestMediaDataWhenReadyOnQueue:usingBlock:")]
void RequestMediaData (DispatchQueue queue, Action handler);
#if !XAMCORE_4_0
[Wrap ("RequestMediaData (queue, enqueuer)", IsVirtual = true)]
[Obsolete ("Use the 'RequestMediaData' method instead.")]
void RequestMediaDataWhenReadyOnQueue (DispatchQueue queue, Action enqueuer);
#endif
[Export ("stopRequestingMediaData")]
void StopRequestingMediaData ();
// TODO: Remove (alongside others) when https://github.com/xamarin/xamarin-macios/issues/3213 is fixed and conformance to 'AVQueuedSampleBufferRendering' is restored.
[TV (11,0), Mac (10,13), iOS (11,0)]
[Export ("timebase", ArgumentSemantic.Retain)]
CMTimebase Timebase { get; }
[iOS (8, 0), Mac (10,10)]
[Field ("AVSampleBufferDisplayLayerFailedToDecodeNotification")]
[Notification]

Просмотреть файл

@ -12,7 +12,7 @@ namespace XamCore.CloudKit {
[iOS (8,0), Mac (10,10, onlyOn64 : true)]
[DisableDefaultCtor] // NSInvalidArgumentException Reason: You must call -[CKAsset initWithFileURL:] or -[CKAsset initWithData:]
[BaseType (typeof (NSObject))]
interface CKAsset : NSCoding, NSSecureCoding {
interface CKAsset : NSCoding, NSSecureCoding, CKRecordValue {
[Export ("initWithFileURL:")]
IntPtr Constructor (NSUrl fileUrl);
@ -1511,7 +1511,7 @@ namespace XamCore.CloudKit {
[iOS (8,0), Mac (10,10, onlyOn64 : true)]
[DisableDefaultCtor] // NSInvalidArgumentException Reason: You must call -[CKReference initWithRecordID:] or -[CKReference initWithRecord:] or -[CKReference initWithAsset:]
[BaseType (typeof (NSObject))]
interface CKReference : NSSecureCoding, NSCopying {
interface CKReference : NSSecureCoding, NSCopying, CKRecordValue {
[DesignatedInitializer]
[Export ("initWithRecordID:action:")]

Просмотреть файл

@ -28,7 +28,7 @@ namespace XamCore.CoreAudioKit {
#if XAMCORE_2_0 || !MONOMAC
[iOS (9,0)][Mac (10,11, onlyOn64 : true)]
[BaseType (typeof(AUViewControllerBase))]
interface AUViewController : NSExtensionRequestHandling {
interface AUViewController {
[Export ("initWithNibName:bundle:")]
[PostGet ("NibBundle")]
IntPtr Constructor ([NullAllowed] string nibName, [NullAllowed] NSBundle bundle);

Просмотреть файл

@ -727,7 +727,7 @@ namespace XamCore.CoreData
// 'init' issues a warning: CoreData: error: Failed to call designated initializer on NSManagedObject class 'NSManagedObject'
// then crash while disposing the instance
[DisableDefaultCtor]
interface NSManagedObject {
interface NSManagedObject : NSFetchRequestResult {
[DesignatedInitializer]
[Export ("initWithEntity:insertIntoManagedObjectContext:")]
IntPtr Constructor (NSEntityDescription entity, [NullAllowed] NSManagedObjectContext context);
@ -1145,7 +1145,7 @@ namespace XamCore.CoreData
[BaseType (typeof (NSObject))]
// Objective-C exception thrown. Name: NSInvalidArgumentException Reason: *** -URIRepresentation cannot be sent to an abstract object of class NSManagedObjectID: Create a concrete instance!
[DisableDefaultCtor]
interface NSManagedObjectID : NSCopying {
interface NSManagedObjectID : NSCopying, NSFetchRequestResult {
[Export ("entity", ArgumentSemantic.Strong)]
NSEntityDescription Entity { get; }

Просмотреть файл

@ -11,6 +11,7 @@
//
using XamCore.ObjCRuntime;
using XamCore.Foundation;
using XamCore.CloudKit;
using XamCore.CoreGraphics;
using XamCore.CoreLocation;
#if !MONOMAC
@ -70,7 +71,7 @@ namespace XamCore.CoreLocation {
}
[BaseType (typeof (NSObject))]
partial interface CLLocation : NSSecureCoding, NSCopying {
partial interface CLLocation : NSSecureCoding, NSCopying, CKRecordValue {
[Export ("coordinate")]
CLLocationCoordinate2D Coordinate { get; }

Просмотреть файл

@ -32,13 +32,21 @@
//
#define DOUBLE_BLOCKS
using XamCore.ObjCRuntime;
using XamCore.CloudKit;
using XamCore.CoreData;
using XamCore.CoreFoundation;
using XamCore.Foundation;
using XamCore.CoreGraphics;
#if IOS
using XamCore.QuickLook;
#endif
#if !TVOS
using XamCore.Contacts;
#endif
#if !WATCH
using XamCore.CoreAnimation;
using XamCore.CoreMedia;
using XamCore.CoreSpotlight;
using XamCore.CloudKit;
#endif
using XamCore.SceneKit;
using XamCore.Security;
@ -48,6 +56,7 @@ using XamCore.FileProvider;
#if MONOMAC
using XamCore.AppKit;
using XamCore.QuickLookUI;
#else
using XamCore.CoreLocation;
using XamCore.UIKit;
@ -102,7 +111,7 @@ namespace XamCore.Foundation
interface NSArray<TValue> : NSArray {}
[BaseType (typeof (NSObject))]
interface NSArray : NSSecureCoding, NSMutableCopying, INSFastEnumeration {
interface NSArray : NSSecureCoding, NSMutableCopying, INSFastEnumeration, CKRecordValue {
[Export ("count")]
nuint Count { get; }
@ -1372,7 +1381,7 @@ namespace XamCore.Foundation
delegate void NSDataByteRangeEnumerator (IntPtr bytes, NSRange range, ref bool stop);
[BaseType (typeof (NSObject))]
interface NSData : NSSecureCoding, NSMutableCopying {
interface NSData : NSSecureCoding, NSMutableCopying, CKRecordValue {
[Export ("dataWithContentsOfURL:")]
[Static]
NSData FromUrl (NSUrl url);
@ -3495,7 +3504,7 @@ namespace XamCore.Foundation
}
[BaseType (typeof (NSObject))]
interface NSDate : NSSecureCoding, NSCopying {
interface NSDate : NSSecureCoding, NSCopying, CKRecordValue {
[Export ("timeIntervalSinceReferenceDate")]
double SecondsSinceReferenceDate { get; }
@ -3542,7 +3551,7 @@ namespace XamCore.Foundation
}
[BaseType (typeof (NSObject))]
interface NSDictionary : NSSecureCoding, NSMutableCopying {
interface NSDictionary : NSSecureCoding, NSMutableCopying, NSFetchRequestResult, INSFastEnumeration {
[Export ("dictionaryWithContentsOfFile:")]
[Static]
NSDictionary FromFile (string path);
@ -4069,7 +4078,11 @@ namespace XamCore.Foundation
}
[BaseType (typeof (NSObject))]
interface NSNull : NSSecureCoding, NSCopying {
interface NSNull : NSSecureCoding, NSCopying
#if !WATCH
, CAAction
#endif
{
[Export ("null"), Static]
NSNull Null { get; }
}
@ -5264,6 +5277,9 @@ namespace XamCore.Foundation
#endif
#if !(MONOMAC && !XAMCORE_2_0) // exclude Classic/XM
, NSItemProviderWriting, NSItemProviderReading
#endif
#if IOS || MONOMAC
, QLPreviewItem
#endif
{
[Export ("initWithScheme:host:path:")]
@ -7726,7 +7742,7 @@ namespace XamCore.Foundation
}
[BaseType (typeof (NSObject)), Bind ("NSString")]
interface NSString2 : NSSecureCoding, NSMutableCopying
interface NSString2 : NSSecureCoding, NSMutableCopying, CKRecordValue
#if MONOMAC
, NSPasteboardReading, NSPasteboardWriting // Documented that it implements NSPasteboard protocols even if header doesn't show it
#endif
@ -10522,7 +10538,7 @@ namespace XamCore.Foundation
[BaseType (typeof (NSValue))]
// init returns NIL
[DisableDefaultCtor]
interface NSNumber {
interface NSNumber : CKRecordValue, NSFetchRequestResult {
[Export ("charValue")]
sbyte SByteValue { get; }

Просмотреть файл

@ -696,7 +696,11 @@ namespace XamCore.GameKit {
[Watch (3,0)]
[Mac (10, 8)]
[BaseType (typeof (GKPlayer))]
interface GKLocalPlayer {
interface GKLocalPlayer
#if !TVOS && !WATCH
: GKSavedGameListener
#endif
{
[Export ("authenticated")]
bool Authenticated { [Bind ("isAuthenticated")] get; }

Просмотреть файл

@ -279,9 +279,9 @@ namespace XamCore.MapKit {
[iOS (6,0)]
[TV (9,2)]
[Mac (10,9, onlyOn64 : true)]
interface MKMapItem
interface MKMapItem : NSSecureCoding
#if IOS // #if TARGET_OS_IOS
: NSItemProviderReading, NSItemProviderWriting
, NSItemProviderReading, NSItemProviderWriting
#endif
{
[Export ("placemark", ArgumentSemantic.Retain)]

Просмотреть файл

@ -13596,7 +13596,7 @@ namespace XamCore.UIKit {
interface IUIContentContainer {}
[BaseType (typeof (UIResponder))]
interface UIViewController : NSCoding, UIAppearanceContainer, UIContentContainer, UITraitEnvironment, UIFocusEnvironment {
interface UIViewController : NSCoding, UIAppearanceContainer, UIContentContainer, UITraitEnvironment, UIFocusEnvironment, NSExtensionRequestHandling {
[DesignatedInitializer]
[Export ("initWithNibName:bundle:")]
[PostGet ("NibBundle")]

Просмотреть файл

@ -2426,7 +2426,11 @@ namespace XamCore.WebKit {
"WeakUIDelegate",
"WeakPolicyDelegate" }
)]
partial interface WebView {
partial interface WebView
#if MONOMAC
: NSUserInterfaceValidations
#endif
{
[Static]
[Export ("canShowMIMEType:")]
bool CanShowMimeType (string MimeType);

Просмотреть файл

@ -539,7 +539,11 @@ namespace XamCore.WebKit
#endif
)]
[DisableDefaultCtor ()] // Crashes during deallocation in Xcode 6 beta 2. radar 17377712.
interface WKWebView {
interface WKWebView
#if MONOMAC
: NSUserInterfaceValidations
#endif
{
[DesignatedInitializer]
[Export ("initWithFrame:configuration:")]

Просмотреть файл

@ -175,6 +175,21 @@ namespace Introspection {
return !TestRuntime.CheckXcodeVersion (9, 0);
}
break;
#if !XAMCORE_4_0
case "NSUrl":
switch (selectorName) {
case "previewItemTitle":
// 'previewItemTitle' should be optional (fixed in XAMCORE_4_0)
return true;
}
break;
#endif
case "MKMapItem": // Selector not available on iOS 32-bit
switch (selectorName) {
case "encodeWithCoder:":
return !TestRuntime.CheckXcodeVersion (9, 0);
}
break;
#if !MONOMAC
case "MTLCaptureManager":
case "NEHotspotEapSettings": // Wireless Accessory Configuration is not supported in the simulator.

Просмотреть файл

@ -681,6 +681,12 @@ namespace Introspection {
case "UIPasteConfigurationSupporting": // types do not conform to protocol but protocol methods work on those types (base type tests in monotouch-test)
return true; // Skip everything because 'UIResponder' implements 'UIPasteConfigurationSupporting' and that's 130+ types
#if !__WATCHOS__
// Undocumented conformance (members were inlinded in 'UIViewController' before so all subtypes should conform)
case "UIStateRestoring":
return type.Name == "UIViewController" || type.IsSubclassOf (typeof (UIViewController));
#endif
}
return base.Skip (type, protocolName);
}

Просмотреть файл

@ -10,6 +10,7 @@ namespace Extrospection {
public class ObjCInterfaceCheck : BaseVisitor {
Dictionary<string, TypeDefinition> type_map = new Dictionary<string, TypeDefinition> ();
Dictionary<string, TypeDefinition> type_map_copy = new Dictionary<string, TypeDefinition> ();
public override void VisitManagedType (TypeDefinition type)
{
@ -49,9 +50,10 @@ namespace Extrospection {
}
if (!skip && wrapper && !String.IsNullOrEmpty (rname)) {
TypeDefinition td;
if (!type_map.TryGetValue (rname, out td))
if (!type_map.TryGetValue (rname, out td)) {
type_map.Add (rname, type);
else {
type_map_copy.Add (rname, type);
} else {
// always report in the same order (for unique error messages)
var sorted = Helpers.Sort (type, td);
var framework = Helpers.GetFramework (sorted.Item1);
@ -60,6 +62,37 @@ namespace Extrospection {
}
}
public override void VisitObjCCategoryDecl (ObjCCategoryDecl decl, VisitKind visitKind)
{
if (visitKind != VisitKind.Enter)
return;
var categoryName = decl.Name;
if (categoryName == null)
return;
// check availability macros to see if the API is available on the OS and not deprecated
if (!decl.IsAvailable ())
return;
var framework = Helpers.GetFramework (decl);
if (framework == null)
return;
var ciName = decl.ClassInterface.Name;
if (!type_map_copy.TryGetValue (ciName, out var td)) {
// other checks can't be done without an actual type to inspect
return;
}
// check protocols
foreach (var protocol in decl.Protocols) {
var pname = protocol.Name;
if (!ImplementProtocol (pname, td))
Log.On (framework).Add ($"!missing-protocol-conformance! {ciName} should conform to {pname} (defined in '{categoryName}' category)");
}
}
public override void VisitObjCInterfaceDecl (ObjCInterfaceDecl decl, VisitKind visitKind)
{
if (visitKind != VisitKind.Enter)
@ -68,8 +101,6 @@ namespace Extrospection {
return;
var name = decl.Name;
if (name.EndsWith ("Internal", StringComparison.Ordinal))
return;
// check availability macros to see if the API is available on the OS and not deprecated
if (!decl.IsAvailable ())

Просмотреть файл

@ -884,3 +884,6 @@
!unknown-native-enum! NSUbiquitousKeyValueStoreChangeReason bound
!unknown-protocol! NSObject bound
!unknown-type! NSObject bound
## Used 'INSFastEnumeration' placeholer (just so we can start flagging things)
!missing-protocol-conformance! NSDictionary should conform to NSFastEnumeration (defined in 'NSGenericFastEnumeraiton' category)

Просмотреть файл

@ -23,3 +23,6 @@
!missing-selector! AVCapturePhotoOutput::setDualCameraDualPhotoDeliveryEnabled: not bound
!missing-selector! AVCaptureResolvedPhotoSettings::embeddedThumbnailDimensions not bound
!missing-selector! AVCaptureResolvedPhotoSettings::expectedPhotoCount not bound
## https://github.com/xamarin/xamarin-macios/issues/3213 should be fixed before conformance to 'AVQueuedSampleBufferRendering' is restored.
!missing-protocol-conformance! AVSampleBufferDisplayLayer should conform to AVQueuedSampleBufferRendering (defined in 'AVSampleBufferDisplayLayerQueueManagement' category)

Просмотреть файл

@ -0,0 +1,2 @@
## Will add conformance once https://github.com/xamarin/xamarin-macios/issues/3217 is fixed. Otherwise we're duplicating members from 'NSObject'.
!missing-protocol-conformance! NSString should conform to CNKeyDescriptor (defined in 'Contacts' category)

Просмотреть файл

@ -46,3 +46,6 @@
!missing-selector! NSObject::accessibilityDropPointDescriptors not bound
!missing-selector! NSObject::setAccessibilityDragSourceDescriptors: not bound
!missing-selector! NSObject::setAccessibilityDropPointDescriptors: not bound
## https://github.com/xamarin/xamarin-macios/issues/3213 should be fixed before conformance to 'UIStateRestoring' is restored.
!missing-protocol-conformance! UIViewController should conform to UIStateRestoring (defined in 'UIStateRestoration' category)

Просмотреть файл

@ -48,3 +48,6 @@
!unknown-type! AVCaptureSynchronizedData bound
!unknown-type! AVCaptureSynchronizedDataCollection bound
!unknown-type! AVPersistableContentKeyRequest bound
## https://github.com/xamarin/xamarin-macios/issues/3213 should be fixed before conformance to 'AVQueuedSampleBufferRendering' is restored.
!missing-protocol-conformance! AVSampleBufferDisplayLayer should conform to AVQueuedSampleBufferRendering (defined in 'AVSampleBufferDisplayLayerQueueManagement' category)

Просмотреть файл

@ -1242,3 +1242,6 @@
!unknown-native-enum! NSWindowStyle bound
!wrong-enum-size! NSEventSubtype managed 8 vs native 2
!wrong-enum-size! NSSpellingState managed 4 vs native 8
## NSGlyphStorage protocol not bound
!missing-protocol-conformance! NSLayoutManager should conform to NSGlyphStorage (defined in 'NSGlyphGeneration' category)

Просмотреть файл

@ -1 +1,4 @@
!missing-selector! +CNGroup::predicateForSubgroupsInGroupWithIdentifier: not bound
## Will add conformance once https://github.com/xamarin/xamarin-macios/issues/3217 is fixed. Otherwise we're duplicating members from 'NSObject'.
!missing-protocol-conformance! NSString should conform to CNKeyDescriptor (defined in 'Contacts' category)

Просмотреть файл

@ -4,3 +4,6 @@
## this was tvos 10.2 in Xcode 8.3 and changed to iOS-only in Xcode9 betas
## it's still exposed by AVContentKeySessionDelegate which is available in tvos 10.2
!unknown-type! AVPersistableContentKeyRequest bound
## https://github.com/xamarin/xamarin-macios/issues/3213 should be fixed before conformance to 'AVQueuedSampleBufferRendering' is restored.
!missing-protocol-conformance! AVSampleBufferDisplayLayer should conform to AVQueuedSampleBufferRendering (defined in 'AVSampleBufferDisplayLayerQueueManagement' category)

Просмотреть файл

@ -7,8 +7,12 @@
## all members are not available so the protocol is empty
## however this is confusing because some protocols have no members (so it can't just be ignored)
!missing-protocol! GKFriendRequestComposeViewControllerDelegate not bound
## 36619511 Is GKSavedGameListener available on tvOS? (https://trello.com/c/9q0MT7SY)
!missing-protocol! GKSavedGameListener not bound
## GKSavedGameListener is not available on tvOS (see missing-protocol above)
!missing-protocol-conformance! GKLocalPlayer should conform to GKSavedGameListener (defined in 'GKSavedGame' category)
## GKSession is not in the tvOS API but the GKSessionDelegate is not marked
## looks like mistakes as the API is not used anywhere else
## easier to add later, if needed, than remove

Просмотреть файл

@ -50,3 +50,14 @@
## Apple renamed NSTextAlignment from NSTextAlignment and we kept the old name
!unknown-native-enum! UITextAlignment bound
## Ignore what the header files say, the NSItemProviderReading methods are not actually implemented on TV or Watch
!missing-protocol-conformance! NSAttributedString should conform to NSItemProviderReading (defined in 'UINSItemProvider' category)
!missing-protocol-conformance! NSAttributedString should conform to NSItemProviderWriting (defined in 'UINSItemProvider' category)
!missing-protocol-conformance! UIColor should conform to NSItemProviderReading (defined in 'UINSItemProvider' category)
!missing-protocol-conformance! UIColor should conform to NSItemProviderWriting (defined in 'UINSItemProvider' category)
!missing-protocol-conformance! UIImage should conform to NSItemProviderReading (defined in 'NSItemProvider' category)
!missing-protocol-conformance! UIImage should conform to NSItemProviderWriting (defined in 'NSItemProvider' category)
## https://github.com/xamarin/xamarin-macios/issues/3213 should be fixed before conformance to 'UIStateRestoring' is restored.
!missing-protocol-conformance! UIViewController should conform to UIStateRestoring (defined in 'UIStateRestoration' category)

Просмотреть файл

@ -0,0 +1,2 @@
## Will add conformance once https://github.com/xamarin/xamarin-macios/issues/3217 is fixed. Otherwise we're duplicating members from 'NSObject'.
!missing-protocol-conformance! NSString should conform to CNKeyDescriptor (defined in 'Contacts' category)

Просмотреть файл

@ -20,3 +20,11 @@
## Apple renamed NSTextAlignment from NSTextAlignment and we kept the old name
!unknown-native-enum! UITextAlignment bound
## Ignore what the header files say, the NSItemProviderReading methods are not actually implemented on TV or Watch
!missing-protocol-conformance! NSAttributedString should conform to NSItemProviderReading (defined in 'UINSItemProvider' category)
!missing-protocol-conformance! NSAttributedString should conform to NSItemProviderWriting (defined in 'UINSItemProvider' category)
!missing-protocol-conformance! UIColor should conform to NSItemProviderReading (defined in 'UINSItemProvider' category)
!missing-protocol-conformance! UIColor should conform to NSItemProviderWriting (defined in 'UINSItemProvider' category)
!missing-protocol-conformance! UIImage should conform to NSItemProviderReading (defined in 'NSItemProvider' category)
!missing-protocol-conformance! UIImage should conform to NSItemProviderWriting (defined in 'NSItemProvider' category)