From ca718991df4fe6bd1b9f694bf21322eb580600cf Mon Sep 17 00:00:00 2001 From: Vincent Dondain Date: Wed, 22 Jun 2016 23:32:00 +0200 Subject: [PATCH] [introspection] Fix bindings so the tests pass (#254) - Added missing NSCopying, NSCoding and NSSecureCoding. - Filled radar://26939747 with Apple - https://trello.com/c/6aIzLH4a --- src/contacts.cs | 4 ++++ src/foundation.cs | 2 +- src/gameplaykit.cs | 24 +++++++++++++++++++ src/modelio.cs | 11 +++++++-- src/networkextension.cs | 4 ++++ src/wkwebkit.cs | 24 +++++++++++++++++-- tests/introspection/ApiProtocolTest.cs | 15 ++++++++++++ tests/introspection/iOS/iOSApiProtocolTest.cs | 1 + .../ModelIO/MDLMaterialProperty.cs | 9 +++++++ 9 files changed, 89 insertions(+), 5 deletions(-) diff --git a/src/contacts.cs b/src/contacts.cs index 4e08695566..00bbd8a67a 100644 --- a/src/contacts.cs +++ b/src/contacts.cs @@ -273,7 +273,11 @@ namespace XamCore.Contacts { [iOS (9,0), Mac (10,11, onlyOn64: true)] [BaseType (typeof (NSObject))] [DisableDefaultCtor] // using init raises an exception according to docs + #if !MONOMAC + public interface CNContactFetchRequest : NSSecureCoding { + #else public interface CNContactFetchRequest { + #endif [DesignatedInitializer] [Export ("initWithKeysToFetch:")] diff --git a/src/foundation.cs b/src/foundation.cs index 7c1538643a..bc7cec07c4 100644 --- a/src/foundation.cs +++ b/src/foundation.cs @@ -954,7 +954,7 @@ namespace XamCore.Foundation [Since (3,2)] [BaseType (typeof (NSObject))] - public interface NSCharacterSet : NSCoding, NSMutableCopying { + public interface NSCharacterSet : NSSecureCoding, NSMutableCopying { [Static, Export ("alphanumericCharacterSet")] NSCharacterSet Alphanumerics {get;} diff --git a/src/gameplaykit.cs b/src/gameplaykit.cs index 2de8d5dee7..055a449562 100644 --- a/src/gameplaykit.cs +++ b/src/gameplaykit.cs @@ -87,7 +87,11 @@ namespace XamCore.GameplayKit { // https://bugzilla.xamarin.com/show_bug.cgi?id=4391 [iOS (9,0), Mac (10,11, onlyOn64 : true)] [BaseType (typeof (NSObject))] + #if !MONOMAC + interface GKBehavior : NSCopying { + #else interface GKBehavior { + #endif [Export ("goalCount")] nint GoalCount { get; } @@ -136,7 +140,11 @@ namespace XamCore.GameplayKit { [iOS (9,0), Mac (10,11, onlyOn64 : true)] [BaseType (typeof (NSObject))] [Abstract] + #if !MONOMAC + interface GKComponent : NSCopying, NSCoding { + #else interface GKComponent : NSCopying { + #endif [NullAllowed] [Export ("entity", ArgumentSemantic.Weak)] @@ -189,7 +197,11 @@ namespace XamCore.GameplayKit { [iOS (9,0), Mac (10,11, onlyOn64 : true)] [BaseType (typeof (NSObject))] + #if !MONOMAC + interface GKEntity : NSCopying, NSCoding { + #else interface GKEntity : NSCopying { + #endif [Static] [Export ("entity")] @@ -346,7 +358,11 @@ namespace XamCore.GameplayKit { [iOS (9,0), Mac (10,11, onlyOn64 : true)] [BaseType (typeof (NSObject))] + #if !MONOMAC + interface GKGraph : NSCopying, NSCoding { + #else interface GKGraph { + #endif [NullAllowed] [Export ("nodes")] @@ -459,7 +475,11 @@ namespace XamCore.GameplayKit { [iOS (9,0), Mac (10,11, onlyOn64 : true)] [BaseType (typeof (NSObject))] + #if !MONOMAC + interface GKGraphNode : NSCoding { + #else interface GKGraphNode { + #endif [Export ("connectedNodes")] GKGraphNode [] ConnectedNodes { get; } @@ -594,7 +614,11 @@ namespace XamCore.GameplayKit { [iOS (9,0), Mac (10,11, onlyOn64 : true)] [DisableDefaultCtor] [BaseType (typeof (GKObstacle))] + #if !MONOMAC + interface GKPolygonObstacle : NSCoding { + #else interface GKPolygonObstacle { + #endif [Export ("vertexCount")] nuint VertexCount { get; } diff --git a/src/modelio.cs b/src/modelio.cs index c06ed0749f..fbbc4b7c65 100644 --- a/src/modelio.cs +++ b/src/modelio.cs @@ -391,6 +391,9 @@ namespace XamCore.ModelIO { [iOS (9,0)][Mac (10,11, onlyOn64 : true)] [BaseType (typeof(NSObject))] [DisableDefaultCtor] + // TODO: NSCopying defined but copyWithZone doesn't work + // filled radar://26939747 with Apple + // https://trello.com/c/6aIzLH4a interface MDLMaterialProperty : MDLNamed { [DesignatedInitializer] @@ -1171,8 +1174,12 @@ namespace XamCore.ModelIO { [iOS (9,0), Mac(10,11, onlyOn64 : true)] [BaseType (typeof(NSObject))] - interface MDLTransform : MDLTransformComponent - { + #if !MONOMAC + interface MDLTransform : MDLTransformComponent, NSCopying { + #else + interface MDLTransform : MDLTransformComponent { + #endif + [Export ("initWithTransformComponent:")] IntPtr Constructor (IMDLTransformComponent component); diff --git a/src/networkextension.cs b/src/networkextension.cs index 4f86f6f457..9ce3b482b2 100644 --- a/src/networkextension.cs +++ b/src/networkextension.cs @@ -1051,7 +1051,11 @@ namespace XamCore.NetworkExtension { [iOS (9,0)][Mac (10,11, onlyOn64 : true)] [BaseType (typeof (NSObject))] [Abstract] + #if !MONOMAC + interface NWEndpoint : NSSecureCoding, NSCopying { + #else interface NWEndpoint { + #endif } [iOS (9,0)][Mac (10,11, onlyOn64 : true)] diff --git a/src/wkwebkit.cs b/src/wkwebkit.cs index 404da42d18..ba5b12dae6 100644 --- a/src/wkwebkit.cs +++ b/src/wkwebkit.cs @@ -159,7 +159,11 @@ namespace XamCore.WebKit [iOS (8,0), Mac (10,10, onlyOn64 : true)] // Not defined in 32-bit [BaseType (typeof (NSObject))] + #if !MONOMAC + interface WKPreferences : NSCoding { + #else interface WKPreferences { + #endif [Export ("minimumFontSize")] nfloat MinimumFontSize { get; set; } @@ -263,8 +267,12 @@ namespace XamCore.WebKit [iOS (9,0), Mac(10,11, onlyOn64 : true)] [BaseType (typeof(NSObject))] - interface WKWebsiteDataStore - { + #if !MONOMAC + interface WKWebsiteDataStore : NSCoding { + #else + interface WKWebsiteDataStore { + #endif + [Static] [Export ("defaultDataStore")] WKWebsiteDataStore DefaultDataStore { get; } @@ -316,7 +324,11 @@ namespace XamCore.WebKit [iOS (8,0), Mac (10,10, onlyOn64 : true)] // Not defined in 32-bit [BaseType (typeof (NSObject))] + #if !MONOMAC + interface WKUserContentController : NSCoding { + #else interface WKUserContentController { + #endif [Export ("userScripts")] WKUserScript [] UserScripts { get; } @@ -496,7 +508,11 @@ namespace XamCore.WebKit [iOS (8,0), Mac (10,10, onlyOn64 : true)] // Not defined in 32-bit [BaseType (typeof (NSObject))] + #if !MONOMAC + interface WKWebViewConfiguration : NSCopying, NSCoding { + #else interface WKWebViewConfiguration : NSCopying { + #endif [Export ("processPool", ArgumentSemantic.Retain)] WKProcessPool ProcessPool { get; set; } @@ -549,7 +565,11 @@ namespace XamCore.WebKit [iOS (8,0), Mac (10,10, onlyOn64 : true)] // Not defined in 32-bit [BaseType (typeof (NSObject))] + #if !MONOMAC + interface WKProcessPool : NSCoding { + #else interface WKProcessPool { + #endif // as of Mac 10.10, iOS 8.0 Beta 2, // this interface is completely empty } diff --git a/tests/introspection/ApiProtocolTest.cs b/tests/introspection/ApiProtocolTest.cs index 487a111419..c5de58d146 100644 --- a/tests/introspection/ApiProtocolTest.cs +++ b/tests/introspection/ApiProtocolTest.cs @@ -73,6 +73,14 @@ namespace Introspection { case "GKScore": // new in iOS8 and 10.0 case "NSExtensionContext": + // TODO: MDLMaterialProperty has NSCopying defined but copyWithZone doesn't work + // filled radar://26939747 with Apple + // https://trello.com/c/6aIzLH4a + case "MDLMaterialProperty": + case "NSLayoutAnchor`1": + case "NSLayoutDimension": + case "NSLayoutXAxisAnchor": + case "NSLayoutYAxisAnchor": return true; // skip } break; @@ -89,6 +97,12 @@ namespace Introspection { // new in iOS8 and 10.0 case "NSExtensionContext": case "NSItemProvider": + // iOS9 / 10.11 + case "CNSaveRequest": + case "NSLayoutAnchor`1": + case "NSLayoutDimension": + case "NSLayoutXAxisAnchor": + case "NSLayoutYAxisAnchor": // undocumented return true; } @@ -109,6 +123,7 @@ namespace Introspection { case "NSMutableParagraphStyle": //17770106 return true; // skip // iOS9 / 10.11 + case "CNSaveRequest": case "NSPersonNameComponentsFormatter": return true; // skip } diff --git a/tests/introspection/iOS/iOSApiProtocolTest.cs b/tests/introspection/iOS/iOSApiProtocolTest.cs index 4c1bc2751d..b79280cea4 100644 --- a/tests/introspection/iOS/iOSApiProtocolTest.cs +++ b/tests/introspection/iOS/iOSApiProtocolTest.cs @@ -243,6 +243,7 @@ namespace Introspection { case "HKQuantitySample": case "HKSample": case "HKWorkout": + case "PKPaymentMethod": // iOS 10 case "CXCallDirectoryExtensionContext": case "SFSafariViewControllerConfiguration": diff --git a/tests/monotouch-test/ModelIO/MDLMaterialProperty.cs b/tests/monotouch-test/ModelIO/MDLMaterialProperty.cs index 545593a37d..f902fedcda 100644 --- a/tests/monotouch-test/ModelIO/MDLMaterialProperty.cs +++ b/tests/monotouch-test/ModelIO/MDLMaterialProperty.cs @@ -191,6 +191,15 @@ namespace MonoTouchFixtures.ModelIO { Assert.AreEqual (3.1415f, obj.FloatValue, "11 FloatValue"); } } + + [Test] + [Ignore ("MDLMaterialProperty has NSCopying defined but copyWithZone doesn't work. radar://26939747 - https://trello.com/c/6aIzLH4a")] + public void Copy () + { + using (var obj = new MDLMaterialProperty ("name", MDLMaterialSemantic.AmbientOcclusion)) { + Assert.IsNotNull (obj.Copy ()); + } + } } }