From 1d88f13be62e9a4da3ae327f17a6e13b7432ebf9 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Wed, 16 Oct 2019 08:01:55 +0200 Subject: [PATCH] Fix a few introspection issues on Catalina. (#7212) * [SceneKit] Adjust deprecation message. Fixes this introspection failure: [FAIL] [Rule 4] Don't use availability keywords in attribute's message: "OpenGL API deprecated, please use Metal instead." - Type: SCNLayer [FAIL] [Rule 4] Don't use availability keywords in attribute's message: "OpenGL API deprecated, please use Metal instead." - Member name: get_OpenGLContext, Type: SCNView [FAIL] [Rule 4] Don't use availability keywords in attribute's message: "OpenGL API deprecated, please use Metal instead." - Member name: set_OpenGLContext, Type: SCNView [FAIL] [Rule 4] Don't use availability keywords in attribute's message: "OpenGL API deprecated, please use Metal instead." - Member name: get_PixelFormat, Type: SCNView [FAIL] [Rule 4] Don't use availability keywords in attribute's message: "OpenGL API deprecated, please use Metal instead." - Member name: set_PixelFormat, Type: SCNView * [tests] Fix introspection and xammac tests on Catalina. (#7200) * [tests] Adjust NaturalLanguage.EmbeddingTest to cope with non-existent embeddings. Fixes xamarin/maccore#2011. Fixes https://github.com/xamarin/maccore/issues/2011. * [tests] Fix typo test on macOS 10.15. Fixes #7116. Fixes https://github.com/xamarin/xamarin-macios/issues/7116. * [introspection] Ignore MTLCounterSampleBufferDescriptor's selectors. They're implemented using a different/internal type: $ nm /System/Library/Frameworks/Metal.framework/Metal | grep MTLCounterSampleBuffer 00000000000458ab t +[MTLCounterSampleBufferDescriptor allocWithZone:] 0000000000045897 t +[MTLCounterSampleBufferDescriptor alloc] 000000000004591e t -[MTLCounterSampleBufferDescriptor copyWithZone:] 000000000004598e t -[MTLCounterSampleBufferDescriptorInternal copyWithZone:] 0000000000045c0f t -[MTLCounterSampleBufferDescriptorInternal counterSet] 0000000000045936 t -[MTLCounterSampleBufferDescriptorInternal dealloc] 0000000000045b65 t -[MTLCounterSampleBufferDescriptorInternal hash] 0000000000045a31 t -[MTLCounterSampleBufferDescriptorInternal isEqual:] 0000000000045c58 t -[MTLCounterSampleBufferDescriptorInternal label] 0000000000045c7f t -[MTLCounterSampleBufferDescriptorInternal sampleCount] 0000000000045c25 t -[MTLCounterSampleBufferDescriptorInternal setCounterSet:] 0000000000045c6e t -[MTLCounterSampleBufferDescriptorInternal setLabel:] 0000000000045c90 t -[MTLCounterSampleBufferDescriptorInternal setSampleCount:] 0000000000045c47 t -[MTLCounterSampleBufferDescriptorInternal setStorageMode:] 0000000000045c36 t -[MTLCounterSampleBufferDescriptorInternal storageMode] 000000000010b0b8 S _OBJC_CLASS_$_MTLCounterSampleBufferDescriptor 000000000010b0e0 S _OBJC_CLASS_$_MTLCounterSampleBufferDescriptorInternal 0000000000107070 S _OBJC_IVAR_$_MTLCounterSampleBufferDescriptorInternal._counterSet 0000000000107078 S _OBJC_IVAR_$_MTLCounterSampleBufferDescriptorInternal._label 0000000000107088 S _OBJC_IVAR_$_MTLCounterSampleBufferDescriptorInternal._sampleCount 0000000000107080 S _OBJC_IVAR_$_MTLCounterSampleBufferDescriptorInternal._storageMode 000000000010b108 S _OBJC_METACLASS_$_MTLCounterSampleBufferDescriptor 000000000010b130 S _OBJC_METACLASS_$_MTLCounterSampleBufferDescriptorInternal Fixes these test failures: 1) ApiSelectorTest.InstanceMethods (Introspection.MacApiSelectorTest.ApiSelectorTest.InstanceMethods) 8 errors found in 26658 instance selector validated: Selector not found for Metal.MTLCounterSampleBufferDescriptor : counterSet Selector not found for Metal.MTLCounterSampleBufferDescriptor : setCounterSet: Selector not found for Metal.MTLCounterSampleBufferDescriptor : label Selector not found for Metal.MTLCounterSampleBufferDescriptor : setLabel: Selector not found for Metal.MTLCounterSampleBufferDescriptor : sampleCount Selector not found for Metal.MTLCounterSampleBufferDescriptor : setSampleCount: Selector not found for Metal.MTLCounterSampleBufferDescriptor : storageMode Selector not found for Metal.MTLCounterSampleBufferDescriptor : setStorageMode: * [introspection] Ignore some API we've bound incorrectly. Fixes #7116. There are also a few API fixes, those will be submitted in a different PR. Fixes https://github.com/xamarin/xamarin-macios/issues/7116. --- src/AppKit/Enums.cs | 4 ++++ src/scenekit.cs | 10 +++++----- tests/introspection/ApiProtocolTest.cs | 6 ++++++ tests/introspection/ApiTypoTest.cs | 4 ++++ tests/introspection/Mac/MacApiSelectorTest.cs | 8 ++++++++ .../NaturalLanguage/EmbeddingTest.cs | 17 ++++++++++++----- 6 files changed, 39 insertions(+), 10 deletions(-) diff --git a/src/AppKit/Enums.cs b/src/AppKit/Enums.cs index b82778ba90..16013bf99e 100644 --- a/src/AppKit/Enums.cs +++ b/src/AppKit/Enums.cs @@ -2198,7 +2198,11 @@ namespace AppKit { GenericPreferencesIcon = 0x70726566, //'pref' GenericQueryDocumentIcon = 0x71657279, //'qery' GenericRamDiskIcon = 0x72616D64, //'ramd' +#if !XAMCORE_4_0 + [Obsolete ("Use 'GenericSharedLibraryIcon' instead.")] GenericSharedLibaryIcon = 0x73686C62, //'shlb' +#endif + GenericSharedLibraryIcon = 0x73686C62, //'shlb' GenericStationeryIcon = 0x73646F63, //'sdoc' GenericSuitcaseIcon = 0x73756974, //'suit' GenericUrlIcon = 0x6775726C, //'gurl' diff --git a/src/scenekit.cs b/src/scenekit.cs index 5378eb9ded..b9c4d4538b 100644 --- a/src/scenekit.cs +++ b/src/scenekit.cs @@ -1213,7 +1213,7 @@ namespace SceneKit { #if MONOMAC [iOS (8,0)] - [Deprecated (PlatformName.MacOSX, 10, 14, message: "OpenGL API deprecated, please use Metal instead.")] + [Deprecated (PlatformName.MacOSX, 10, 14, message: "Please use Metal instead of OpenGL API.")] [Unavailable (PlatformName.MacCatalyst)][Advice ("This API is not available when using UIKit on macOS.")] [BaseType (typeof (CAOpenGLLayer))] interface SCNLayer : SCNSceneRenderer, SCNTechniqueSupport { @@ -3507,16 +3507,16 @@ namespace SceneKit { bool AllowsCameraControl { get; set; } #if MONOMAC - [Deprecated (PlatformName.MacOSX, 10, 14, message: "OpenGL API deprecated, please use Metal instead.")] + [Deprecated (PlatformName.MacOSX, 10, 14, message: "Please use Metal instead of OpenGL API.")] [Export ("openGLContext", ArgumentSemantic.Retain)] NSOpenGLContext OpenGLContext { get; set; } - [Deprecated (PlatformName.MacOSX, 10, 14, message: "OpenGL API deprecated, please use Metal instead.")] + [Deprecated (PlatformName.MacOSX, 10, 14, message: "Please use Metal instead of OpenGL API.")] [Export ("pixelFormat", ArgumentSemantic.Retain)] NSOpenGLPixelFormat PixelFormat { get; set; } #elif !WATCH - [Deprecated (PlatformName.iOS, 12, 0, message: "OpenGL API deprecated, please use Metal instead.")] - [Deprecated (PlatformName.TvOS, 12, 0, message: "OpenGL API deprecated, please use Metal instead.")] + [Deprecated (PlatformName.iOS, 12, 0, message: "Please use Metal instead of OpenGL API.")] + [Deprecated (PlatformName.TvOS, 12, 0, message: "Please use Metal instead of OpenGL API.")] [Export ("eaglContext", ArgumentSemantic.Retain)] #if XAMCORE_2_0 EAGLContext EAGLContext { get; set; } diff --git a/tests/introspection/ApiProtocolTest.cs b/tests/introspection/ApiProtocolTest.cs index 19ccc112d5..c0a4217b14 100644 --- a/tests/introspection/ApiProtocolTest.cs +++ b/tests/introspection/ApiProtocolTest.cs @@ -299,6 +299,12 @@ namespace Introspection { break; } break; +#if !XAMCORE_4_0 + case "MTLCounter": + case "MTLCounterSampleBuffer": + case "MTLCounterSet": + return true; // Incorrectly bound, will be fixed for XAMCORE_4_0. +#endif } return false; } diff --git a/tests/introspection/ApiTypoTest.cs b/tests/introspection/ApiTypoTest.cs index aad09889cd..16cb357aab 100644 --- a/tests/introspection/ApiTypoTest.cs +++ b/tests/introspection/ApiTypoTest.cs @@ -145,6 +145,7 @@ namespace Introspection "Cartes", // french "Cavlc", "Cda", // acronym: Clinical Document Architecture + "Cdrom", "Cfa", // acronym: Color Filter Array "Celp", // MPEG4ObjectID "Characterteristic", @@ -386,6 +387,7 @@ namespace Introspection "nint", "Nntps", "Ntlm", + "Nsl", // InternetLocationNslNeighborhoodIcon "Ntsc", "nuint", "Ndef", @@ -436,6 +438,7 @@ namespace Introspection "Prerolls", "Preseti", "Prev", + "Privs", // SharingPrivsNotApplicableIcon "Propogate", "Psec", "Psm", // Protocol/Service Multiplexer @@ -864,6 +867,7 @@ namespace Introspection "Attributest", "Failwith", "Imageimage", + "Libary", "Musthold", "Olus", // Typo, should be 'Bolus', fixed in 'HKInsulinDeliveryReason' "Ostprandial", // Typo, should be 'Postprandial', fixed in 'HKBloodGlucoseMealTime' diff --git a/tests/introspection/Mac/MacApiSelectorTest.cs b/tests/introspection/Mac/MacApiSelectorTest.cs index 9a6663d692..76601a62f3 100644 --- a/tests/introspection/Mac/MacApiSelectorTest.cs +++ b/tests/introspection/Mac/MacApiSelectorTest.cs @@ -694,6 +694,14 @@ namespace Introspection { break; } break; + case "Metal": + switch (type.Name) { + case "MTLCounterSampleBufferDescriptor": + // This whole type is implemented using a different (internal) type, + // and it's the internal type who knows how to respond to the selectors. + return true; + } + break; } return base.Skip (type, selectorName); } diff --git a/tests/monotouch-test/NaturalLanguage/EmbeddingTest.cs b/tests/monotouch-test/NaturalLanguage/EmbeddingTest.cs index b24eb902da..465e10a82f 100644 --- a/tests/monotouch-test/NaturalLanguage/EmbeddingTest.cs +++ b/tests/monotouch-test/NaturalLanguage/EmbeddingTest.cs @@ -22,11 +22,18 @@ namespace MonoTouchFixtures.NaturalLanguage { { TestRuntime.AssertXcodeVersion (11, 0); - using (var e = NLEmbedding.GetWordEmbedding (NLLanguage.English)) { - Assert.NotNull (e, "GetWordEmbedding"); - Assert.Null (e.GetVector ("Xamarin"), "GetVector"); - Assert.False (e.TryGetVector ("Xamarin", out var vector), "TryGetVector"); - Assert.Null (vector, "vector"); + foreach (NLLanguage v in Enum.GetValues (typeof (NLLanguage))) { + if (v == NLLanguage.Unevaluated) + continue; // this is not a value provided by Apple. + + NLEmbedding e = null; + Assert.DoesNotThrow (() => e = NLEmbedding.GetWordEmbedding (v), $"Throws: {v}"); + if (e != null) { + Assert.NotNull (e, "GetWordEmbedding"); + Assert.Null (e.GetVector ("Xamarin"), "GetVector"); + Assert.False (e.TryGetVector ("Xamarin", out var vector), "TryGetVector"); + Assert.Null (vector, "vector"); + } } } #endif