From 83697028c31a6ca97197d0dd5b252c1a54567880 Mon Sep 17 00:00:00 2001 From: Vincent Dondain Date: Tue, 31 Jan 2017 13:39:25 -0500 Subject: [PATCH 1/5] [modelio] Update for iOS 10.3 beta 1 --- src/ModelIO/MDLAsset.cs | 11 ++++ src/ModelIO/MDLObject.cs | 17 +++++ src/frameworks.sources | 1 + src/modelio.cs | 50 +++++++++++++++ tests/monotouch-test/ModelIO/MDLAsset.cs | 76 +++++++++++++++++++++++ tests/monotouch-test/ModelIO/MDLObject.cs | 15 ++++- 6 files changed, 169 insertions(+), 1 deletion(-) create mode 100644 src/ModelIO/MDLObject.cs create mode 100644 tests/monotouch-test/ModelIO/MDLAsset.cs diff --git a/src/ModelIO/MDLAsset.cs b/src/ModelIO/MDLAsset.cs index e0778641dfe4..c022e65eacf0 100644 --- a/src/ModelIO/MDLAsset.cs +++ b/src/ModelIO/MDLAsset.cs @@ -1,5 +1,6 @@ #if XAMCORE_2_0 || !MONOMAC using System; +using XamCore.ObjCRuntime; namespace XamCore.ModelIO { public partial class MDLAsset { public MDLObject this [nuint index] { @@ -7,6 +8,16 @@ public MDLObject this [nuint index] { return GetObject (index); } } + + [iOS (10,3), TV (10,2), Mac (10,12,4)] + public IMDLComponent this [Protocol key] { + get { + return ObjectForKeyedSubscript (key); + } + set { + SetObject (value, key); + } + } } } #endif \ No newline at end of file diff --git a/src/ModelIO/MDLObject.cs b/src/ModelIO/MDLObject.cs new file mode 100644 index 000000000000..8a7eb7c2edaf --- /dev/null +++ b/src/ModelIO/MDLObject.cs @@ -0,0 +1,17 @@ +#if XAMCORE_2_0 || !MONOMAC +using System; +using XamCore.ObjCRuntime; +namespace XamCore.ModelIO { + public partial class MDLObject { + [iOS (10,3), TV (10,2), Mac (10,12,4)] + public IMDLComponent this [Protocol key] { + get { + return ObjectForKeyedSubscript (key); + } + set { + SetObject (value, key); + } + } + } +} +#endif \ No newline at end of file diff --git a/src/frameworks.sources b/src/frameworks.sources index db63ecca96bc..03c3b2f17656 100644 --- a/src/frameworks.sources +++ b/src/frameworks.sources @@ -947,6 +947,7 @@ MODELIO_CORE_SOURCES = \ MODELIO_SOURCES = \ ModelIO/MDLAsset.cs \ + ModelIO/MDLObject.cs \ ModelIO/MDLNoiseTexture.cs \ ModelIO/MDLVertexDescriptor.cs \ ModelIO/MDLMesh.cs \ diff --git a/src/modelio.cs b/src/modelio.cs index e1bc9153cb37..0807a8bacfd6 100644 --- a/src/modelio.cs +++ b/src/modelio.cs @@ -90,6 +90,28 @@ interface MDLAsset : NSCopying [Export ("canExportFileExtension:")] bool CanExportFileExtension (string extension); + [iOS (10,3), TV (10,2), Mac (10,12,4)] + [Export ("components", ArgumentSemantic.Copy)] + IMDLComponent[] Components { get; } + + [iOS (10,3), TV (10,2), Mac (10,12,4)] + [Export ("setComponent:forProtocol:")] + void SetComponent (IMDLComponent component, Protocol protocol); + + [iOS (10,3), TV (10,2), Mac (10,12,4)] + [Export ("componentConformingToProtocol:")] + [return: NullAllowed] + IMDLComponent IsComponentConforming (Protocol protocol); + + [Internal] + [Export ("objectForKeyedSubscript:")] + [return: NullAllowed] + IMDLComponent ObjectForKeyedSubscript (Protocol key); + + [Internal] + [Export ("setObject:forKeyedSubscript:")] + void SetObject ([NullAllowed] IMDLComponent obj, Protocol key); + [iOS (10,0)] [Mac (10,12)] [TV (10,0)] @@ -986,6 +1008,10 @@ interface MDLNormalMapTexture [BaseType (typeof(NSObject))] interface MDLObject : MDLNamed { + [iOS (10,3), TV (10,2), Mac (10,12,4)] + [Export ("components", ArgumentSemantic.Copy)] + IMDLComponent[] Components { get; } + [Export ("setComponent:forProtocol:")] void SetComponent (IMDLComponent component, Protocol protocol); @@ -993,6 +1019,15 @@ interface MDLObject : MDLNamed [return: NullAllowed] IMDLComponent IsComponentConforming (Protocol protocol); + [Internal] + [Export ("objectForKeyedSubscript:")] + [return: NullAllowed] + IMDLComponent ObjectForKeyedSubscript (Protocol key); + + [Internal] + [Export ("setObject:forKeyedSubscript:")] + void SetObject ([NullAllowed] IMDLComponent obj, Protocol key); + [NullAllowed, Export ("parent", ArgumentSemantic.Weak)] MDLObject Parent { get; set; } @@ -1068,6 +1103,16 @@ interface MDLObjectContainerComponent : MDLComponent, INSFastEnumeration [Export ("removeObject:")] void RemoveObject (MDLObject @object); + [iOS (10,3), TV (10,2), Mac (10,12,4)] + [Abstract] + [Export ("objectAtIndexedSubscript:")] + MDLObject GetObjectAtIndexedSubscript (nuint index); + + [iOS (10,3), TV (10,2), Mac (10,12,4)] + [Abstract] + [Export ("count")] + nuint Count { get; } + [Abstract] [Export ("objects", ArgumentSemantic.Retain)] MDLObject[] Objects { get; } @@ -1537,6 +1582,11 @@ interface MDLTransform : MDLTransformComponent, NSCopying { [MarshalDirective (NativePrefix = "xamarin_simd__", Library = "__Internal")] void SetRotation (Vector3 rotation, double time); + [iOS (10,3), TV (10,2), Mac (10,12,4)] + [Export ("setMatrix:forTime:")] + [MarshalDirective (NativePrefix = "xamarin_simd__", Library = "__Internal")] + void SetMatrix (Matrix4 matrix, double time); + [Export ("shear", ArgumentSemantic.Assign)] Vector3 Shear { [MarshalDirective (NativePrefix = "xamarin_simd__", Library = "__Internal")] diff --git a/tests/monotouch-test/ModelIO/MDLAsset.cs b/tests/monotouch-test/ModelIO/MDLAsset.cs new file mode 100644 index 000000000000..f35356fa9468 --- /dev/null +++ b/tests/monotouch-test/ModelIO/MDLAsset.cs @@ -0,0 +1,76 @@ +// +// MDLAsset Unit Tests +// +// Authors: +// Vincent Dondain +// +// Copyright 2017 Microsoft. +// + +#if !__WATCHOS__ + +using System; +#if XAMCORE_2_0 +using CoreGraphics; +using Foundation; +using UIKit; +using ModelIO; +using ObjCRuntime; +#else +using MonoTouch.CoreGraphics; +using MonoTouch.Foundation; +using MonoTouch.UIKit; +using MonoTouch.ModelIO; +using MonoTouch.ObjCRuntime; +#endif +using OpenTK; +using NUnit.Framework; + +namespace MonoTouchFixtures.ModelIO { + + [TestFixture] + // we want the test to be available if we use the linker + [Preserve (AllMembers = true)] + public class MDLAssetTest { + [TestFixtureSetUp] + public void Setup () + { + if (!UIDevice.CurrentDevice.CheckSystemVersion (9, 0)) + Assert.Ignore ("Requires iOS9+"); + + if (Runtime.Arch == Arch.SIMULATOR && IntPtr.Size == 4) { + // There's a bug in the i386 version of objc_msgSend where it doesn't preserve SIMD arguments + // when resizing the cache of method selectors for a type. So here we call all selectors we can + // find, so that the subsequent tests don't end up producing any cache resize (radar #21630410). + using (var obj = new MDLAsset ()) { + object dummy; + obj.SetComponent (new MDLTransform (), new Protocol ("MDLComponent")); + obj.IsComponentConforming (new Protocol ("MDLComponent")); + obj.GetBoundingBox (0); + dummy = obj.StartTime; + dummy = obj.EndTime; + dummy = obj.Url; + dummy = obj.BufferAllocator; + dummy = obj.VertexDescriptor; + dummy = obj.Count; + dummy = obj.Masters; + } + } + } + + [Test] + public void IndexerTest () + { + using (var obj = new MDLAsset ()) { + var key = new Protocol ("MDLComponent"); + var container = new MDLObjectContainer (); + // Use the indexer's setter + obj [key] = container; + // Assert with the indexer's getter + Assert.AreEqual (container, obj [key], "#1"); + } + } + } +} + +#endif // !__WATCHOS__ diff --git a/tests/monotouch-test/ModelIO/MDLObject.cs b/tests/monotouch-test/ModelIO/MDLObject.cs index e20d4728c47a..36acecd23955 100644 --- a/tests/monotouch-test/ModelIO/MDLObject.cs +++ b/tests/monotouch-test/ModelIO/MDLObject.cs @@ -1,5 +1,5 @@ // -// MDLLight Unit Tests +// MDLObject Unit Tests // // Authors: // Rolf Bjarne Kvinge @@ -63,6 +63,19 @@ public void GetBoundingBox () var bb = obj.GetBoundingBox (0); } } + + [Test] + public void IndexerTest () + { + using (var obj = new MDLObject ()) { + var key = new Protocol ("MDLComponent"); + var container = new MDLObjectContainer (); + // Use the indexer's setter + obj [key] = container; + // Assert with the indexer's getter + Assert.AreEqual (container, obj [key], "#1"); + } + } } } From a5c203482690e0d730d987d336e4a8da78d281d5 Mon Sep 17 00:00:00 2001 From: Vincent Dondain Date: Wed, 1 Feb 2017 16:00:25 -0500 Subject: [PATCH 2/5] [modelio] Fixes based on comments --- src/ModelIO/MDLAsset.cs | 11 ---- src/ModelIO/MDLObject.cs | 17 ----- src/ObjCRuntime/Protocol.cs | 12 ++++ src/frameworks.sources | 1 - src/modelio.cs | 42 +++++++------ tests/monotouch-test/ModelIO/MDLAsset.cs | 76 ----------------------- tests/monotouch-test/ModelIO/MDLObject.cs | 13 ---- 7 files changed, 34 insertions(+), 138 deletions(-) delete mode 100644 src/ModelIO/MDLObject.cs delete mode 100644 tests/monotouch-test/ModelIO/MDLAsset.cs diff --git a/src/ModelIO/MDLAsset.cs b/src/ModelIO/MDLAsset.cs index c022e65eacf0..e0778641dfe4 100644 --- a/src/ModelIO/MDLAsset.cs +++ b/src/ModelIO/MDLAsset.cs @@ -1,6 +1,5 @@ #if XAMCORE_2_0 || !MONOMAC using System; -using XamCore.ObjCRuntime; namespace XamCore.ModelIO { public partial class MDLAsset { public MDLObject this [nuint index] { @@ -8,16 +7,6 @@ public MDLObject this [nuint index] { return GetObject (index); } } - - [iOS (10,3), TV (10,2), Mac (10,12,4)] - public IMDLComponent this [Protocol key] { - get { - return ObjectForKeyedSubscript (key); - } - set { - SetObject (value, key); - } - } } } #endif \ No newline at end of file diff --git a/src/ModelIO/MDLObject.cs b/src/ModelIO/MDLObject.cs deleted file mode 100644 index 8a7eb7c2edaf..000000000000 --- a/src/ModelIO/MDLObject.cs +++ /dev/null @@ -1,17 +0,0 @@ -#if XAMCORE_2_0 || !MONOMAC -using System; -using XamCore.ObjCRuntime; -namespace XamCore.ModelIO { - public partial class MDLObject { - [iOS (10,3), TV (10,2), Mac (10,12,4)] - public IMDLComponent this [Protocol key] { - get { - return ObjectForKeyedSubscript (key); - } - set { - SetObject (value, key); - } - } - } -} -#endif \ No newline at end of file diff --git a/src/ObjCRuntime/Protocol.cs b/src/ObjCRuntime/Protocol.cs index 65832a16cb72..ae8f600a1b30 100644 --- a/src/ObjCRuntime/Protocol.cs +++ b/src/ObjCRuntime/Protocol.cs @@ -24,6 +24,18 @@ public Protocol (string name) throw new ArgumentException (String.Format ("'{0}' is an unknown protocol", name)); } + public Protocol (Type type) + { + this.handle = Class.GetHandle (type); + + IntPtr namePtr = protocol_getName (this.handle); + string name = Marshal.PtrToStringAuto (namePtr); + IntPtr ptr = objc_getProtocol (name); + + if (this.handle == IntPtr.Zero || ptr == IntPtr.Zero) + throw new ArgumentException (String.Format ("'{0}' is an unknown protocol", type.Name)); + } + public Protocol (IntPtr handle) { this.handle = handle; diff --git a/src/frameworks.sources b/src/frameworks.sources index 03c3b2f17656..db63ecca96bc 100644 --- a/src/frameworks.sources +++ b/src/frameworks.sources @@ -947,7 +947,6 @@ MODELIO_CORE_SOURCES = \ MODELIO_SOURCES = \ ModelIO/MDLAsset.cs \ - ModelIO/MDLObject.cs \ ModelIO/MDLNoiseTexture.cs \ ModelIO/MDLVertexDescriptor.cs \ ModelIO/MDLMesh.cs \ diff --git a/src/modelio.cs b/src/modelio.cs index 0807a8bacfd6..0d22c9fc2bca 100644 --- a/src/modelio.cs +++ b/src/modelio.cs @@ -94,23 +94,22 @@ interface MDLAsset : NSCopying [Export ("components", ArgumentSemantic.Copy)] IMDLComponent[] Components { get; } - [iOS (10,3), TV (10,2), Mac (10,12,4)] + [Internal] [Export ("setComponent:forProtocol:")] void SetComponent (IMDLComponent component, Protocol protocol); [iOS (10,3), TV (10,2), Mac (10,12,4)] - [Export ("componentConformingToProtocol:")] - [return: NullAllowed] - IMDLComponent IsComponentConforming (Protocol protocol); + [Wrap ("SetComponent (component, new Protocol (type))")] + void SetComponent (IMDLComponent component, Type type); [Internal] - [Export ("objectForKeyedSubscript:")] + [Export ("componentConformingToProtocol:")] [return: NullAllowed] - IMDLComponent ObjectForKeyedSubscript (Protocol key); + IMDLComponent GetComponent (Protocol protocol); - [Internal] - [Export ("setObject:forKeyedSubscript:")] - void SetObject ([NullAllowed] IMDLComponent obj, Protocol key); + [iOS (10,3), TV (10,2), Mac (10,12,4)] + [Wrap ("GetComponent (new Protocol (type))")] + IMDLComponent GetComponent (Type type); [iOS (10,0)] [Mac (10,12)] @@ -1012,21 +1011,26 @@ interface MDLObject : MDLNamed [Export ("components", ArgumentSemantic.Copy)] IMDLComponent[] Components { get; } +#if XAMCORE_4_0 + [Internal] +#endif + [Obsolete ("Use SetComponent (Type protocol)")] [Export ("setComponent:forProtocol:")] void SetComponent (IMDLComponent component, Protocol protocol); - [Export ("componentConformingToProtocol:")] - [return: NullAllowed] - IMDLComponent IsComponentConforming (Protocol protocol); + [Wrap ("SetComponent (component, new Protocol (type))")] + void SetComponent (IMDLComponent component, Type type); +#if XAMCORE_4_0 [Internal] - [Export ("objectForKeyedSubscript:")] +#endif + [Obsolete ("Use GetComponent (Type protocol)")] + [Export ("componentConformingToProtocol:")] [return: NullAllowed] - IMDLComponent ObjectForKeyedSubscript (Protocol key); + IMDLComponent IsComponentConforming (Protocol protocol); - [Internal] - [Export ("setObject:forKeyedSubscript:")] - void SetObject ([NullAllowed] IMDLComponent obj, Protocol key); + [Wrap ("IsComponentConforming (new Protocol (type))")] + IMDLComponent GetComponent (Type type); [NullAllowed, Export ("parent", ArgumentSemantic.Weak)] MDLObject Parent { get; set; } @@ -1104,12 +1108,10 @@ interface MDLObjectContainerComponent : MDLComponent, INSFastEnumeration void RemoveObject (MDLObject @object); [iOS (10,3), TV (10,2), Mac (10,12,4)] - [Abstract] [Export ("objectAtIndexedSubscript:")] - MDLObject GetObjectAtIndexedSubscript (nuint index); + MDLObject GetObject (nuint index); [iOS (10,3), TV (10,2), Mac (10,12,4)] - [Abstract] [Export ("count")] nuint Count { get; } diff --git a/tests/monotouch-test/ModelIO/MDLAsset.cs b/tests/monotouch-test/ModelIO/MDLAsset.cs deleted file mode 100644 index f35356fa9468..000000000000 --- a/tests/monotouch-test/ModelIO/MDLAsset.cs +++ /dev/null @@ -1,76 +0,0 @@ -// -// MDLAsset Unit Tests -// -// Authors: -// Vincent Dondain -// -// Copyright 2017 Microsoft. -// - -#if !__WATCHOS__ - -using System; -#if XAMCORE_2_0 -using CoreGraphics; -using Foundation; -using UIKit; -using ModelIO; -using ObjCRuntime; -#else -using MonoTouch.CoreGraphics; -using MonoTouch.Foundation; -using MonoTouch.UIKit; -using MonoTouch.ModelIO; -using MonoTouch.ObjCRuntime; -#endif -using OpenTK; -using NUnit.Framework; - -namespace MonoTouchFixtures.ModelIO { - - [TestFixture] - // we want the test to be available if we use the linker - [Preserve (AllMembers = true)] - public class MDLAssetTest { - [TestFixtureSetUp] - public void Setup () - { - if (!UIDevice.CurrentDevice.CheckSystemVersion (9, 0)) - Assert.Ignore ("Requires iOS9+"); - - if (Runtime.Arch == Arch.SIMULATOR && IntPtr.Size == 4) { - // There's a bug in the i386 version of objc_msgSend where it doesn't preserve SIMD arguments - // when resizing the cache of method selectors for a type. So here we call all selectors we can - // find, so that the subsequent tests don't end up producing any cache resize (radar #21630410). - using (var obj = new MDLAsset ()) { - object dummy; - obj.SetComponent (new MDLTransform (), new Protocol ("MDLComponent")); - obj.IsComponentConforming (new Protocol ("MDLComponent")); - obj.GetBoundingBox (0); - dummy = obj.StartTime; - dummy = obj.EndTime; - dummy = obj.Url; - dummy = obj.BufferAllocator; - dummy = obj.VertexDescriptor; - dummy = obj.Count; - dummy = obj.Masters; - } - } - } - - [Test] - public void IndexerTest () - { - using (var obj = new MDLAsset ()) { - var key = new Protocol ("MDLComponent"); - var container = new MDLObjectContainer (); - // Use the indexer's setter - obj [key] = container; - // Assert with the indexer's getter - Assert.AreEqual (container, obj [key], "#1"); - } - } - } -} - -#endif // !__WATCHOS__ diff --git a/tests/monotouch-test/ModelIO/MDLObject.cs b/tests/monotouch-test/ModelIO/MDLObject.cs index 36acecd23955..633ee71d325e 100644 --- a/tests/monotouch-test/ModelIO/MDLObject.cs +++ b/tests/monotouch-test/ModelIO/MDLObject.cs @@ -63,19 +63,6 @@ public void GetBoundingBox () var bb = obj.GetBoundingBox (0); } } - - [Test] - public void IndexerTest () - { - using (var obj = new MDLObject ()) { - var key = new Protocol ("MDLComponent"); - var container = new MDLObjectContainer (); - // Use the indexer's setter - obj [key] = container; - // Assert with the indexer's getter - Assert.AreEqual (container, obj [key], "#1"); - } - } } } From d7882fbedea818b10959f57bf320848e6e444072 Mon Sep 17 00:00:00 2001 From: Vincent Dondain Date: Thu, 2 Feb 2017 14:36:43 -0500 Subject: [PATCH 3/5] [modelio] Fixes based on comments (2) --- src/ObjCRuntime/Protocol.cs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/ObjCRuntime/Protocol.cs b/src/ObjCRuntime/Protocol.cs index ae8f600a1b30..08968bb9d2ff 100644 --- a/src/ObjCRuntime/Protocol.cs +++ b/src/ObjCRuntime/Protocol.cs @@ -26,14 +26,19 @@ public Protocol (string name) public Protocol (Type type) { - this.handle = Class.GetHandle (type); - - IntPtr namePtr = protocol_getName (this.handle); - string name = Marshal.PtrToStringAuto (namePtr); - IntPtr ptr = objc_getProtocol (name); - - if (this.handle == IntPtr.Zero || ptr == IntPtr.Zero) - throw new ArgumentException (String.Format ("'{0}' is an unknown protocol", type.Name)); + var exception = new ArgumentException (string.Format ("'{0}' is an unknown protocol", type.FullName)); + if (!type.IsInterface) + throw exception; + + var protocols = type.GetCustomAttributes (typeof (ProtocolAttribute), false); + if (protocols.Length == 0) + throw exception; + + var protocol = (ProtocolAttribute)protocols [0]; + var protocolName = protocol.Name; + handle = objc_getProtocol (protocolName); + if (handle == IntPtr.Zero) + throw exception; } public Protocol (IntPtr handle) From 5a3e8624fc4eff6eb40574696be0c9470609c487 Mon Sep 17 00:00:00 2001 From: Vincent Dondain Date: Fri, 3 Feb 2017 14:58:40 -0500 Subject: [PATCH 4/5] [modelio] Fixes based on comments (3) --- src/ObjCRuntime/Protocol.cs | 20 ++++++++------------ src/modelio.cs | 16 ++++++++-------- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/src/ObjCRuntime/Protocol.cs b/src/ObjCRuntime/Protocol.cs index 08968bb9d2ff..b766d4ca3a00 100644 --- a/src/ObjCRuntime/Protocol.cs +++ b/src/ObjCRuntime/Protocol.cs @@ -26,19 +26,15 @@ public Protocol (string name) public Protocol (Type type) { - var exception = new ArgumentException (string.Format ("'{0}' is an unknown protocol", type.FullName)); - if (!type.IsInterface) - throw exception; - - var protocols = type.GetCustomAttributes (typeof (ProtocolAttribute), false); - if (protocols.Length == 0) - throw exception; - - var protocol = (ProtocolAttribute)protocols [0]; - var protocolName = protocol.Name; - handle = objc_getProtocol (protocolName); + if (type.IsInterface) { + foreach (var pa in type.GetCustomAttributes (false)) { + handle = objc_getProtocol (pa.Name); + if (handle != IntPtr.Zero) + return; + } + } if (handle == IntPtr.Zero) - throw exception; + throw new ArgumentException (string.Format ("'{0}' is an unknown protocol", type.FullName)); } public Protocol (IntPtr handle) diff --git a/src/modelio.cs b/src/modelio.cs index 0d22c9fc2bca..6db0e5858759 100644 --- a/src/modelio.cs +++ b/src/modelio.cs @@ -94,7 +94,7 @@ interface MDLAsset : NSCopying [Export ("components", ArgumentSemantic.Copy)] IMDLComponent[] Components { get; } - [Internal] + [EditorBrowsable (EditorBrowsableState.Advanced)] [Export ("setComponent:forProtocol:")] void SetComponent (IMDLComponent component, Protocol protocol); @@ -102,7 +102,7 @@ interface MDLAsset : NSCopying [Wrap ("SetComponent (component, new Protocol (type))")] void SetComponent (IMDLComponent component, Type type); - [Internal] + [EditorBrowsable (EditorBrowsableState.Advanced)] [Export ("componentConformingToProtocol:")] [return: NullAllowed] IMDLComponent GetComponent (Protocol protocol); @@ -1011,10 +1011,6 @@ interface MDLObject : MDLNamed [Export ("components", ArgumentSemantic.Copy)] IMDLComponent[] Components { get; } -#if XAMCORE_4_0 - [Internal] -#endif - [Obsolete ("Use SetComponent (Type protocol)")] [Export ("setComponent:forProtocol:")] void SetComponent (IMDLComponent component, Protocol protocol); @@ -1024,12 +1020,16 @@ interface MDLObject : MDLNamed #if XAMCORE_4_0 [Internal] #endif - [Obsolete ("Use GetComponent (Type protocol)")] + [Obsolete ("Use GetComponent (Type type)")] [Export ("componentConformingToProtocol:")] [return: NullAllowed] IMDLComponent IsComponentConforming (Protocol protocol); - [Wrap ("IsComponentConforming (new Protocol (type))")] + [EditorBrowsable (EditorBrowsableState.Advanced)] + [Wrap ("IsComponentConforming (protocol)")] + IMDLComponent GetComponent (Protocol protocol); + + [Wrap ("GetComponent (new Protocol (type))")] IMDLComponent GetComponent (Type type); [NullAllowed, Export ("parent", ArgumentSemantic.Weak)] From 640892fa520bbcaca16df6f9ffdccba285dd6ae4 Mon Sep 17 00:00:00 2001 From: Vincent Dondain Date: Mon, 6 Feb 2017 11:25:49 -0500 Subject: [PATCH 5/5] [modelio] Fixes (4) --- src/modelio.cs | 2 ++ tests/monotouch-test/ModelIO/MDLObject.cs | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/src/modelio.cs b/src/modelio.cs index 6db0e5858759..a212b21417c0 100644 --- a/src/modelio.cs +++ b/src/modelio.cs @@ -94,6 +94,7 @@ interface MDLAsset : NSCopying [Export ("components", ArgumentSemantic.Copy)] IMDLComponent[] Components { get; } + [iOS (10,3), TV (10,2), Mac (10,12,4)] [EditorBrowsable (EditorBrowsableState.Advanced)] [Export ("setComponent:forProtocol:")] void SetComponent (IMDLComponent component, Protocol protocol); @@ -102,6 +103,7 @@ interface MDLAsset : NSCopying [Wrap ("SetComponent (component, new Protocol (type))")] void SetComponent (IMDLComponent component, Type type); + [iOS (10,3), TV (10,2), Mac (10,12,4)] [EditorBrowsable (EditorBrowsableState.Advanced)] [Export ("componentConformingToProtocol:")] [return: NullAllowed] diff --git a/tests/monotouch-test/ModelIO/MDLObject.cs b/tests/monotouch-test/ModelIO/MDLObject.cs index 633ee71d325e..fa4274851bfa 100644 --- a/tests/monotouch-test/ModelIO/MDLObject.cs +++ b/tests/monotouch-test/ModelIO/MDLObject.cs @@ -63,6 +63,16 @@ public void GetBoundingBox () var bb = obj.GetBoundingBox (0); } } + + [Test] + public void ProtocolTest () + { + using (var obj = new MDLObject ()) { + var p = new Protocol (typeof (IMDLComponent)); + obj.SetComponent (new MDLTransform (), p); + Assert.NotNull (obj.IsComponentConforming (p)); + } + } } }