From 36f160dcb1b7be6247f9a492f145aecc4770165f Mon Sep 17 00:00:00 2001 From: Manuel de la Pena Date: Tue, 24 Aug 2021 14:31:19 -0400 Subject: [PATCH 1/3] [ThreadNetwork] Add new framework Xcode 13 beta 5. --- src/frameworks.sources | 1 + src/threadnetwork.cs | 74 +++++++++++++++++++ tests/introspection/ApiTypoTest.cs | 1 + tests/introspection/iOS/iOSApiClassPtrTest.cs | 4 +- tests/introspection/iOS/iOSApiCtorInitTest.cs | 2 + tests/introspection/iOS/iOSApiProtocolTest.cs | 1 + tests/introspection/iOS/iOSApiSelectorTest.cs | 1 + tests/mtouch/RegistrarTest.cs | 1 + tests/xtro-sharpie/iOS-ThreadNetwork.todo | 20 ----- tools/common/Frameworks.cs | 1 + tools/common/StaticRegistrar.cs | 3 + tools/common/Target.cs | 1 + tools/linker/ObjCExtensions.cs | 1 + 13 files changed, 88 insertions(+), 23 deletions(-) create mode 100644 src/threadnetwork.cs delete mode 100644 tests/xtro-sharpie/iOS-ThreadNetwork.todo diff --git a/src/frameworks.sources b/src/frameworks.sources index 144f7778a3c5..d1f3c6e30497 100644 --- a/src/frameworks.sources +++ b/src/frameworks.sources @@ -2119,6 +2119,7 @@ IOS_FRAMEWORKS = \ Social \ Speech \ SystemConfiguration \ + ThreadNetwork \ Twitter \ UIKit XKit \ UserNotifications \ diff --git a/src/threadnetwork.cs b/src/threadnetwork.cs new file mode 100644 index 000000000000..f76e77c36a3f --- /dev/null +++ b/src/threadnetwork.cs @@ -0,0 +1,74 @@ +using CoreFoundation; +using ObjCRuntime; +using Foundation; + +using System; + +namespace ThreadNetwork { + + [iOS (15,0)] + [BaseType (typeof (NSObject))] + interface THClient + { + [Async] + [Export ("retrieveAllCredentials:")] + void RetrieveAllCredentials (Action, NSError> completion); + + [Async] + [Export ("deleteCredentialsForBorderAgent:completion:")] + void DeleteCredentialsForBorderAgent (NSData borderAgentId, Action completion); + + [Async] + [Export ("retrieveCredentialsForBorderAgent:completion:")] + void RetrieveCredentialsForBorderAgent (NSData borderAgentId, Action completion); + + [Async] + [Export ("storeCredentialsForBorderAgent:activeOperationalDataSet:completion:")] + void StoreCredentialsForBorderAgent (NSData borderAgentId, NSData activeOperationalDataSet, Action completion); + + [Async] + [Export ("retrievePreferredCredentials:")] + void RetrievePreferredCredentials (Action completion); + + [Async] + [Export ("retrieveCredentialsForExtendedPANID:completion:")] + void RetrieveCredentialsForExtendedPanid (NSData extendedPanid, Action completion); + } + + [iOS (15,0)] + [BaseType (typeof (NSObject))] + [DisableDefaultCtor] + interface THCredentials : NSSecureCoding + { + [NullAllowed, Export ("networkName")] + string NetworkName { get; } + + [NullAllowed, Export ("extendedPANID")] + NSData ExtendedPanid { get; } + + [NullAllowed, Export ("borderAgentID")] + NSData BorderAgentId { get; } + + [NullAllowed, Export ("activeOperationalDataSet")] + NSData ActiveOperationalDataSet { get; } + + [NullAllowed, Export ("networkKey")] + NSData NetworkKey { get; } + + [NullAllowed, Export ("PSKC")] + NSData Pskc { get; } + + [Export ("channel")] + byte Channel { get; set; } + + [NullAllowed, Export ("panID")] + NSData PanId { get; } + + [NullAllowed, Export ("creationDate")] + NSDate CreationDate { get; } + + [NullAllowed, Export ("lastModificationDate")] + NSDate LastModificationDate { get; } + } + +} diff --git a/tests/introspection/ApiTypoTest.cs b/tests/introspection/ApiTypoTest.cs index 3c96c9d76d21..30de3d3546a8 100644 --- a/tests/introspection/ApiTypoTest.cs +++ b/tests/introspection/ApiTypoTest.cs @@ -1064,6 +1064,7 @@ public void ConstantsCheck () #endif #if !__MACOS__ case "ChipLibrary": + case "ThreadNetworkLibrary": case "MediaSetupLibrary": case "MLComputeLibrary": // Xcode 12 beta 2 does not ship these framework/headers for the simulators diff --git a/tests/introspection/iOS/iOSApiClassPtrTest.cs b/tests/introspection/iOS/iOSApiClassPtrTest.cs index 881c7f48453e..592137bfca31 100644 --- a/tests/introspection/iOS/iOSApiClassPtrTest.cs +++ b/tests/introspection/iOS/iOSApiClassPtrTest.cs @@ -21,10 +21,8 @@ protected override bool Skip (Type type) { switch (type.Namespace) { case "Phase": // missing in the sim - if (Runtime.Arch == Arch.SIMULATOR) - return true; - break; case "ShazamKit": // missing in the sim + case "ThreadNetwork": // missing in the sim if (Runtime.Arch == Arch.SIMULATOR) return true; break; diff --git a/tests/introspection/iOS/iOSApiCtorInitTest.cs b/tests/introspection/iOS/iOSApiCtorInitTest.cs index b62e8c347a65..ee9841131db7 100644 --- a/tests/introspection/iOS/iOSApiCtorInitTest.cs +++ b/tests/introspection/iOS/iOSApiCtorInitTest.cs @@ -228,6 +228,8 @@ protected override bool Skip (Type type) return TestRuntime.CheckXcodeVersion (11, 2); case "UIMenuController": // Stopped working with Xcode 11.3 beta 1 return TestRuntime.CheckXcodeVersion (11, 3); + case "THClient": + return Runtime.Arch == Arch.SIMULATOR; #if __TVOS__ case "MPSPredicate": // the device .ctor ends up calling `initWithBuffer:offset:` and crash on older (non 4k AppleTV devices) diff --git a/tests/introspection/iOS/iOSApiProtocolTest.cs b/tests/introspection/iOS/iOSApiProtocolTest.cs index 7c769d5ac646..e92ab4d89b1a 100644 --- a/tests/introspection/iOS/iOSApiProtocolTest.cs +++ b/tests/introspection/iOS/iOSApiProtocolTest.cs @@ -40,6 +40,7 @@ protected override bool Skip (Type type) case "MLCompute": case "MediaSetup": case "Phase": + case "ThreadNetwork": if (Runtime.Arch == Arch.SIMULATOR) return true; break; diff --git a/tests/introspection/iOS/iOSApiSelectorTest.cs b/tests/introspection/iOS/iOSApiSelectorTest.cs index e3c356b5ee7e..ffb91bca7d88 100644 --- a/tests/introspection/iOS/iOSApiSelectorTest.cs +++ b/tests/introspection/iOS/iOSApiSelectorTest.cs @@ -54,6 +54,7 @@ protected override bool Skip (Type type) case "MetalPerformanceShaders": case "MonoTouch.MetalPerformanceShaders": case "Phase": + case "ThreadNetwork": if (Runtime.Arch == Arch.SIMULATOR) return true; break; diff --git a/tests/mtouch/RegistrarTest.cs b/tests/mtouch/RegistrarTest.cs index e4f907daaa6c..9bd5e8998a67 100644 --- a/tests/mtouch/RegistrarTest.cs +++ b/tests/mtouch/RegistrarTest.cs @@ -348,6 +348,7 @@ public void MT4134 () new { Framework = "AutomaticAssessmentConfiguration", Version = "13.4" }, new { Framework = "CoreLocationUI", Version = "15.0" }, new { Framework = "Chip", Version = "15.0" }, + new { Framework = "ThreadNetwork", Version = "15.0" }, }; foreach (var framework in invalidFrameworks) mtouch.AssertError (4134, $"Your application is using the '{framework.Framework}' framework, which isn't included in the iOS SDK you're using to build your app (this framework was introduced in iOS {framework.Version}, while you're building with the iOS {mtouch.Sdk} SDK.) Please select a newer SDK in your app's iOS Build options."); diff --git a/tests/xtro-sharpie/iOS-ThreadNetwork.todo b/tests/xtro-sharpie/iOS-ThreadNetwork.todo deleted file mode 100644 index c1d74e5be131..000000000000 --- a/tests/xtro-sharpie/iOS-ThreadNetwork.todo +++ /dev/null @@ -1,20 +0,0 @@ -!missing-selector! THClient::deleteCredentialsForBorderAgent:completion: not bound -!missing-selector! THClient::init not bound -!missing-selector! THClient::retrieveAllCredentials: not bound -!missing-selector! THClient::retrieveCredentialsForBorderAgent:completion: not bound -!missing-selector! THClient::retrieveCredentialsForExtendedPANID:completion: not bound -!missing-selector! THClient::retrievePreferredCredentials: not bound -!missing-selector! THClient::storeCredentialsForBorderAgent:activeOperationalDataSet:completion: not bound -!missing-selector! THCredentials::activeOperationalDataSet not bound -!missing-selector! THCredentials::borderAgentID not bound -!missing-selector! THCredentials::channel not bound -!missing-selector! THCredentials::creationDate not bound -!missing-selector! THCredentials::extendedPANID not bound -!missing-selector! THCredentials::lastModificationDate not bound -!missing-selector! THCredentials::networkKey not bound -!missing-selector! THCredentials::networkName not bound -!missing-selector! THCredentials::panID not bound -!missing-selector! THCredentials::PSKC not bound -!missing-selector! THCredentials::setChannel: not bound -!missing-type! THClient not bound -!missing-type! THCredentials not bound diff --git a/tools/common/Frameworks.cs b/tools/common/Frameworks.cs index 53c7b0b7d03a..9fce5c10f3fc 100644 --- a/tools/common/Frameworks.cs +++ b/tools/common/Frameworks.cs @@ -430,6 +430,7 @@ public static Frameworks CreateiOSFrameworks (bool is_simulator_build) { "Phase", "PHASE", new Version (15,0), NotAvailableInSimulator /* no headers in beta 2 */ }, { "OSLog", "OSLog", 15,0 }, { "ShazamKit", "ShazamKit", new Version (15,0), NotAvailableInSimulator}, + { "ThreadNetwork", "ThreadNetwork", new Version (15,0), NotAvailableInSimulator}, // the above MUST be kept in sync with simlauncher // see tools/mtouch/Makefile diff --git a/tools/common/StaticRegistrar.cs b/tools/common/StaticRegistrar.cs index 650f81673707..dce758932872 100644 --- a/tools/common/StaticRegistrar.cs +++ b/tools/common/StaticRegistrar.cs @@ -2230,6 +2230,9 @@ void CheckNamespace (string ns, List exceptions) return; } goto default; + case "ThreadNetwork": + h = ""; + break; default: h = string.Format ("<{0}/{0}.h>", ns); break; diff --git a/tools/common/Target.cs b/tools/common/Target.cs index 399a4aa7f010..b94574e33785 100644 --- a/tools/common/Target.cs +++ b/tools/common/Target.cs @@ -224,6 +224,7 @@ public void GatherFrameworks () case "MetalPerformanceShaders": case "CHIP": case "PHASE": + case "ThreadNetwork": // some frameworks do not exists on simulators and will result in linker errors if we include them if (App.IsSimulatorBuild) continue; diff --git a/tools/linker/ObjCExtensions.cs b/tools/linker/ObjCExtensions.cs index 955396f0e534..30aa926d132e 100644 --- a/tools/linker/ObjCExtensions.cs +++ b/tools/linker/ObjCExtensions.cs @@ -73,6 +73,7 @@ static class Namespaces { public const string Social = nameof (Social); public const string SpriteKit = nameof (SpriteKit); public const string StoreKit = nameof (StoreKit); + public const string ThreadNetwork = nameof (ThreadNetwork); public const string UIKit = nameof (UIKit); public const string VideoSubscriberAccount = nameof (VideoSubscriberAccount); public const string VideoToolbox = nameof (VideoToolbox); From b24ccb2b429015dadc45c7e70e7b96ac542a5e05 Mon Sep 17 00:00:00 2001 From: Manuel de la Pena Date: Tue, 24 Aug 2021 17:03:37 -0400 Subject: [PATCH 2/3] Update src/threadnetwork.cs --- src/threadnetwork.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/threadnetwork.cs b/src/threadnetwork.cs index f76e77c36a3f..e4c52dcbb250 100644 --- a/src/threadnetwork.cs +++ b/src/threadnetwork.cs @@ -32,7 +32,7 @@ interface THClient [Async] [Export ("retrieveCredentialsForExtendedPANID:completion:")] - void RetrieveCredentialsForExtendedPanid (NSData extendedPanid, Action completion); + void RetrieveCredentialsForExtendedPanId (NSData extendedPanId, Action completion); } [iOS (15,0)] From 5e2d07296108067a3c484a2cfd9da3da6c69a996 Mon Sep 17 00:00:00 2001 From: Manuel de la Pena Date: Wed, 25 Aug 2021 08:01:57 -0400 Subject: [PATCH 3/3] Update src/threadnetwork.cs Co-authored-by: Rolf Bjarne Kvinge --- src/threadnetwork.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/threadnetwork.cs b/src/threadnetwork.cs index e4c52dcbb250..29fc6e937000 100644 --- a/src/threadnetwork.cs +++ b/src/threadnetwork.cs @@ -44,7 +44,7 @@ interface THCredentials : NSSecureCoding string NetworkName { get; } [NullAllowed, Export ("extendedPANID")] - NSData ExtendedPanid { get; } + NSData ExtendedPanId { get; } [NullAllowed, Export ("borderAgentID")] NSData BorderAgentId { get; }