protected override string FindLibrary(string libraryName, bool requiresFullPath = false)
        {
            switch (libraryName)
            {
            case "CFNetwork":
                if (Mac.IsAtLeast(10, 8))
                {
                    break;
                }
                return("/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CFNetwork.framework/CFNetwork");

            case "CoreText":
            case "CoreGraphics":
                if (Mac.IsAtLeast(10, 8))
                {
                    break;
                }
                return(string.Format("/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/{0}.framework/{0}", libraryName));

            case "ImageIO":
                if (Mac.IsAtLeast(10, 9))
                {
                    break;
                }
                return("/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/ImageIO");

            case "CoreImage":
                // generated code uses QuartzCore correctly - even if the [Field] property is wrong
                libraryName = "QuartzCore";
                break;

            case "QuartzComposer":
            case "PdfKit":
            case "ImageKit":
                // generated code uses Quartz correctly - even if the [Field] property is wrong
                libraryName = "Quartz";
                break;

            case "CoreBluetooth":
                if (Mac.IsYosemiteOrHigher)
                {
                    // CoreBluetooth is in /System/Library/Frameworks/CoreBluetooth.framework starting with Yosemite.
                    break;
                }

                // CoreBluetooth is inside IOBluetooth.framework in earlier OSXs
                return("/System/Library/Frameworks/IOBluetooth.framework/Versions/A/Frameworks/CoreBluetooth.framework/CoreBluetooth");

            case "SearchKit":
                return("/System/Library/Frameworks/CoreServices.framework/Frameworks/SearchKit.framework/SearchKit");
            }

            return(base.FindLibrary(libraryName, requiresFullPath));
        }
예제 #2
0
        protected override bool Skip(Type type, string selectorName)
        {
            switch (selectorName)
            {
            case "accessibilityNotifiesWhenDestroyed":
                // The header declares this on an NSObject category but
                // it doesn't even respondsToSelector on NSView/NSCell...
                return(true);

#if !XAMCORE_4_0
            case "xamarinselector:removed:":
                return(true);
#endif
#if !XAMCORE_3_0
            case "initWithPasteboardPropertyList:ofType:":
                // This is a broken binding, but it's an abstract protocol
                // method, so there's no way to remove it without breaking
                // compat.
                return(true);
#endif
            case "waitUntilExit":
                // category, NSTask won't respond -> @interface NSTask (NSTaskConveniences)
                if (type.Name == "NSTask")
                {
                    return(true);
                }
                break;

            case "readInBackgroundAndNotifyForModes:":
            case "readInBackgroundAndNotify":
            case "readToEndOfFileInBackgroundAndNotifyForModes:":
            case "readToEndOfFileInBackgroundAndNotify":
            case "acceptConnectionInBackgroundAndNotifyForModes:":
            case "acceptConnectionInBackgroundAndNotify":
            case "waitForDataInBackgroundAndNotifyForModes:":
            case "waitForDataInBackgroundAndNotify":
                // category, NSFileHandle won't respond -> @interface NSFileHandle (NSFileHandleAsynchronousAccess)
                if (type.Name == "NSFileHandle")
                {
                    return(true);
                }
                break;

            // initWithPlayerIDs: works (valid handle) and is documented - but does not respond when queried
            case "initWithPlayerIDs:":
                if (type.Name == "GKLeaderboard")
                {
                    return(true);
                }
                break;

            // some types had NSCopying added after they were first introduced
            case "copyWithZone:":
                if (type.Name == "CBPeripheral" && !Mac.CheckSystemVersion(10, 9))
                {
                    return(true);
                }
                break;

            case "readingOptionsForType:pasteboard:":
            case "writingOptionsForType:pasteboard:":
                return(true);                // Optional selectors on NSPasteboardReading/NSPasteboardWriting
            }

            switch (type.Namespace)
            {
            // Notifications seems to follow a pattern were selectors are routed to an internal concrete type
            case "MonoMac.Foundation":
            case "Foundation":
                switch (type.Name)
                {
                // looks like it's routed to (private) NSConcreteUserNotificationCenter
                case "NSUserNotificationCenter":
                    switch (selectorName)
                    {
                    case "delegate":
                    case "setDelegate:":
                    case "scheduledNotifications":
                    case "setScheduledNotifications:":
                    case "deliveredNotifications":
                        return(true);
                    }
                    break;

                // looks like it's routed to (private) NSConcreteUserNotification
                case "NSUserNotification":
                    switch (selectorName)
                    {
                    case "title":
                    case "setTitle:":
                    case "subtitle":
                    case "setSubtitle:":
                    case "informativeText":
                    case "setInformativeText:":
                    case "actionButtonTitle":
                    case "setActionButtonTitle:":
                    case "userInfo":
                    case "setUserInfo:":
                    case "deliveryDate":
                    case "setDeliveryDate:":
                    case "deliveryTimeZone":
                    case "setDeliveryTimeZone:":
                    case "deliveryRepeatInterval":
                    case "setDeliveryRepeatInterval:":
                    case "actualDeliveryDate":
                    case "isPresented":
                    case "isRemote":
                    case "soundName":
                    case "setSoundName:":
                    case "hasActionButton":
                    case "setHasActionButton:":
                    case "activationType":
                    case "otherButtonTitle":
                    case "setOtherButtonTitle:":
                        return(true);
                    }
                    break;

                case "NSFileHandle":                 //Fails on Lion
                case "NSUrlAuthenticationChallenge":
                case "NSUrlCredential":
                case "NSUrlProtectionSpace":
                case "NSAppleEventDescriptor":
                    if (selectorName == "encodeWithCoder:" && !Mac.CheckSystemVersion(10, 8))
                    {
                        return(true);
                    }
                    break;

                case "NSValue":
                    switch (selectorName)
                    {
                    case "SCNMatrix4Value":
                    case "SCNVector3Value":
                    case "SCNVector4Value":
                    case "valueWithSCNMatrix4:":
                        if (IntPtr.Size != 8)
                        {
                            return(true);
                        }
                        break;
                    }
                    break;

                case "NSUrlSession":
                    switch (selectorName)
                    {
                    case "delegateQueue":
                    case "sessionDescription":
                    case "setSessionDescription:":
                    case "delegate":
                        if (Mac.CheckSystemVersion(10, 11))
                        {
                            return(true);
                        }
                        break;
                    }
                    break;

                case "NSUrlSessionStreamTask":
                    switch (selectorName)
                    {
                    case "captureStreams":
                    case "closeRead":
                    case "closeWrite":
                    case "readDataOfMinLength:maxLength:timeout:completionHandler:":
                    case "startSecureConnection":
                    case "stopSecureConnection":
                    case "writeData:timeout:completionHandler:":
                        if (Mac.CheckSystemVersion(10, 11))
                        {
                            return(true);
                        }
                        break;
                    }
                    break;

                case "NSUrlSessionTask":
                    switch (selectorName)
                    {
                    case "countOfBytesExpectedToReceive":
                    case "countOfBytesExpectedToSend":
                    case "countOfBytesReceived":
                    case "countOfBytesSent":
                    case "currentRequest":
                    case "error":
                    case "originalRequest":
                    case "response":
                    case "state":
                    case "taskDescription":
                    case "setTaskDescription:":
                    case "taskIdentifier":
                        if (Mac.CheckSystemVersion(10, 11))
                        {
                            return(true);
                        }
                        break;
                    }
                    break;

                case "NSUrlSessionConfiguration":
                    if (Mac.IsAtLeast(10, 11))
                    {
                        return(true);
                    }
                    break;
                }
                break;

            case "MonoMac.AppKit":
            case "AppKit":
                switch (type.Name)
                {
#if !XAMCORE_3_0                // These should be not be marked [Abstract] but can't fix w/o breaking change...
                case "NSScrollView":
                case "NSTextView":
                    switch (selectorName)
                    {
                    case "contentViewAtIndex:effectiveCharacterRange:":
                    case "didReplaceCharacters":
                    case "drawCharactersInRange:forContentView:":
                    case "rectsForCharacterRange:":
                    case "replaceCharactersInRange:withString:":
                    case "scrollRangeToVisible:":
                    case "shouldReplaceCharactersInRanges:withStrings:":
                    case "stringAtIndex:effectiveRange:endsWithSearchBoundary:":
                    case "stringLength":
                    case "allowsMultipleSelection":
                    case "isEditable":
                    case "firstSelectedRange":
                    case "isSelectable":
                    case "selectedRanges":
                    case "setSelectedRanges:":
                    case "string":
                    case "visibleCharacterRanges":
                        return(true);
                    }
                    break;
#endif
                case "NSMenuDelegate":
                    switch (selectorName)
                    {
#if !XAMCORE_3_0
                    case "menu:willHighlightItem:":
                        return(true);                        // bound
#endif
                    }
                    break;

                case "NSResponder":
                    switch (selectorName)
                    {
                    case "smartMagnifyWithEvent:":
                    case "quickLookWithEvent:":
                        if (!Mac.CheckSystemVersion(10, 8))
                        {
                            return(true);
                        }
                        break;
                    }
                    break;

                case "NSViewController":
                    switch (selectorName)
                    {
                    case "identifier":                     //
                    case "setIdentifier:":
                        // In Yosemite (but not before) NSViewController implements the NSUserInterfaceItemIdentification
                        // protocol (which brings a r/w Identifier property). We don't have any way of expressing that
                        // a type started implementing a protocol in a particular version, so just ignore these selectors.
                        if (!Mac.CheckSystemVersion(10, 10))
                        {
                            return(true);
                        }
                        break;
                    }
                    break;
                }
                break;

            // GameKit seems to follow a pattern were selectors are routed to an internal concrete type
            case "MonoMac.GameKit":
            case "GameKit":
                switch (type.Name)
                {
                case "GKTurnBasedExchange":
                    switch (selectorName)
                    {
                    case "completionDate":
                    case "data":
                    case "exchangeID":
                    case "sendDate":
                    case "timeoutDate":
                        return(true);
                    }
                    break;

                case "GKTurnBasedExchangeReply":
                    switch (selectorName)
                    {
                    case "data":
                    case "replyDate":
                        return(true);
                    }
                    break;

                // looks like it's routed to (private) GKDialogController_Concrete
                case "GKDialogController":
                    switch (selectorName)
                    {
                    case "parentWindow":
                    case "setParentWindow:":
                        return(true);
                    }
                    break;

                // looks like it's routed to (private) GKVoiceChat_Concrete
                case "GKVoiceChat":
                    switch (selectorName)
                    {
                    case "start":
                    case "stop":
                    case "setMute:forPlayer:":
                    case "name":
                    case "isActive":
                    case "setActive:":
                    case "volume":
                    case "setVolume:":
                    case "playerStateUpdateHandler":
                    case "setPlayerStateUpdateHandler:":
                    case "playerIDs":
                        return(true);
                    }
                    break;

                // looks like it's routed to (private) GKLeaderboard_Concrete
                case "GKLeaderboard":
                    switch (selectorName)
                    {
                    case "loadScoresWithCompletionHandler:":
                    case "timeScope":
                    case "setTimeScope:":
                    case "playerScope":
                    case "setPlayerScope:":
                    case "maxRange":
                    case "category":
                    case "setCategory:":
                    case "title":
                    case "range":
                    case "setRange:":
                    case "scores":
                    case "localPlayerScore":
                    case "groupIdentifier":
                    case "setGroupIdentifier:":
                        return(true);
                    }
                    break;

                // looks like it's routed to (private) GKLeaderboard_Concrete
                case "GKLocalPlayer":
                    switch (selectorName)
                    {
                    case "authenticateWithCompletionHandler:":
                    case "loadDefaultLeaderboardCategoryIDWithCompletionHandler:":
                    case "setDefaultLeaderboardCategoryID:completionHandler:":
                    case "authenticateHandler":
                    case "setAuthenticateHandler:":
                    case "loadFriendsWithCompletionHandler:":
                    case "isAuthenticated":
                        return(true);
                    }
                    break;

                // looks like it's routed to (private) GKMatch_Concrete
                case "GKMatch":
                    switch (selectorName)
                    {
                    case "sendData:toPlayers:withDataMode:error:":
                    case "sendDataToAllPlayers:withDataMode:error:":
                    case "disconnect":
                    case "voiceChatWithName:":
                    case "playerIDs":
                    case "delegate":
                    case "setDelegate:":
                    case "expectedPlayerCount":
                        return(true);
                    }
                    break;

                // looks like it's routed to (private) GKMatchmater_Concrete
                case "GKMatchmaker":
                    switch (selectorName)
                    {
                    case "inviteHandler":
                    case "setInviteHandler:":
                    case "findMatchForRequest:withCompletionHandler:":
                    case "findPlayersForHostedMatchRequest:withCompletionHandler:":
                    case "addPlayersToMatch:matchRequest:completionHandler:":
                    case "cancel":
                    case "queryPlayerGroupActivity:withCompletionHandler:":
                    case "queryActivityWithCompletionHandler:":
                        return(true);
                    }
                    break;
                }
                break;

            // Gone in Mavericks
            case "MonoMac.StoreKit":
            case "StoreKit":
                switch (type.Name)
                {
                case "SKPayment":
                case "SKMutablePayment":
                    switch (selectorName)
                    {
                    case "paymentWithProductIdentifier:":
                        if (Mac.CheckSystemVersion(10, 9))
                        {
                            return(true);
                        }
                        break;
                    }
                    break;
                }
                break;

            case "MonoMac.PdfKit":             // Bug 20232
            case "PdfKit":
                switch (type.Name)
                {
                case "PdfBorder":                 // Fails on Lion
                case "PdfAnnotation":
                    if (selectorName == "encodeWithCoder:" && !Mac.CheckSystemVersion(10, 8))
                    {
                        return(true);
                    }
                    break;

                case "PdfView":
                    switch (selectorName)
                    {
#if !XAMCORE_3_0
                    case "menu:willHighlightItem:":
                        return(true);
#endif
                    }
                    break;
                }
                break;

            case "MonoMac.SceneKit":
            case "SceneKit":
                switch (type.Name)
                {
                case "SCNGeometryElement":
                    // Ignore on 10.8 where SCNGeometryPrimitiveType is int (32), but
                    // on 10.9+ is NSInteger/nint (32/64). SceneKit is next to useless
                    // on 10.8 anyway. -abock
                    if (selectorName == "primitiveType" && Mac.CheckSystemVersion(10, 8))
                    {
                        return(true);
                    }
                    // fall through
                    goto case "SCNCamera";

                case "SCNCamera":
                case "SCNGeometry":
                case "SCNGeometrySource":
                case "SCNLight":
                case "SCNMaterial":
                case "SCNMaterialProperty":
                case "SCNNode":
                case "SCNProgram":
                case "SCNScene":
                case "SCNMorpher":
                case "SCNSkinner":
                case "SCNConstraint":
                case "SCNLevelOfDetail":
                    // The NSSecureCoding protocol was added to these types in Yosemite,
                    // and we can't (yet?) describe "type added protocol P in version X.Y"
                    // with our AvailabilityAttribute, so do this check manually.
                    if (selectorName == "encodeWithCoder:" && !Mac.CheckSystemVersion(10, 10))
                    {
                        return(true);
                    }
                    break;
                }

                switch (type.Name)
                {
                case "SCNGeometry":
                    // SCNGeometry added the SCNShadable protocol in 10.9, which brings in the 'program' selector.
                    switch (selectorName)
                    {
                    case "program":
                    case "setProgram:":
                        if (!Mac.CheckSystemVersion(10, 9))
                        {
                            return(true);
                        }
                        break;
                    }
                    break;
                }
                break;
            }
            return(base.Skip(type, selectorName));
        }