From 2348736a2b970963e209c5144fd9ec2d561133ff Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Thu, 14 Mar 2024 07:58:45 +0100 Subject: [PATCH] [DeviceDiscoveryExtension] Added bindings for DeviceDiscoveryExtension. (#20272) --------- Co-authored-by: Israel Soto --- src/DeviceDiscoveryExtension/DDDevice.cs | 27 +++++ src/DeviceDiscoveryExtension/Enums.cs | 77 +++++++++++++ src/build/generator-frameworks.g.cs | 3 + src/devicediscoveryextension.cs | 107 ++++++++++++++++++ src/frameworks.sources | 9 ++ src/rsp/dotnet/ios-defines-dotnet.rsp | 1 + src/rsp/ios-defines.rsp | 1 + .../Documentation.KnownFailures.txt | 92 +++++++++++++++ tests/introspection/iOS/iOSApiProtocolTest.cs | 11 ++ .../DeviceDiscoveryExtension/DDDeviceTest.cs | 46 ++++++++ tests/mtouch/RegistrarTest.cs | 1 + .../iOS-DeviceDiscoveryExtension.ignore | 9 ++ .../iOS-DeviceDiscoveryExtension.todo | 50 -------- .../iOS-DeviceDiscoveryExtension.ignore | 9 ++ .../iOS-DeviceDiscoveryExtension.todo | 50 -------- tools/common/Frameworks.cs | 2 + tools/mtouch/Makefile | 1 + 17 files changed, 396 insertions(+), 100 deletions(-) create mode 100644 src/DeviceDiscoveryExtension/DDDevice.cs create mode 100644 src/DeviceDiscoveryExtension/Enums.cs create mode 100644 src/devicediscoveryextension.cs create mode 100644 tests/monotouch-test/DeviceDiscoveryExtension/DDDeviceTest.cs create mode 100644 tests/xtro-sharpie/api-annotations-dotnet/iOS-DeviceDiscoveryExtension.ignore delete mode 100644 tests/xtro-sharpie/api-annotations-dotnet/iOS-DeviceDiscoveryExtension.todo create mode 100644 tests/xtro-sharpie/iOS-DeviceDiscoveryExtension.ignore delete mode 100644 tests/xtro-sharpie/iOS-DeviceDiscoveryExtension.todo diff --git a/src/DeviceDiscoveryExtension/DDDevice.cs b/src/DeviceDiscoveryExtension/DDDevice.cs new file mode 100644 index 000000000000..a012d1a41561 --- /dev/null +++ b/src/DeviceDiscoveryExtension/DDDevice.cs @@ -0,0 +1,27 @@ +// +// Custom methods for DDDevice +// +// Authors: +// Israel Soto (issoto@microsoft.com) +// Rolf Bjarne Kvinge (rolf@xamarin.com) +// +// Copyright 2022, 2024 Microsoft Corporation. +// + +#nullable enable + +using ObjCRuntime; +using Foundation; +using Network; +using System; + +using nw_endpoint_t = System.IntPtr; + +namespace DeviceDiscoveryExtension { + public partial class DDDevice { + public NWEndpoint? NetworkEndpoint { + get => _NetworkEndpoint != nw_endpoint_t.Zero ? new NWEndpoint (_NetworkEndpoint, false) : null; + set => _NetworkEndpoint = value.GetHandle (); + } + } +} diff --git a/src/DeviceDiscoveryExtension/Enums.cs b/src/DeviceDiscoveryExtension/Enums.cs new file mode 100644 index 000000000000..0113785876be --- /dev/null +++ b/src/DeviceDiscoveryExtension/Enums.cs @@ -0,0 +1,77 @@ +// +// Enums.cs +// +// Authors: +// Israel Soto (issoto@microsoft.com) +// Rolf Bjarne Kvinge (rolf@xamarin.com) +// +// Copyright 2022, 2024 Microsoft Corporation. +// + +using System; + +using ObjCRuntime; +using Foundation; + +namespace DeviceDiscoveryExtension { + + [NoMac, iOS (16, 0), NoMacCatalyst, NoWatch, NoTV] + [Native] + public enum DDDeviceProtocol : long { + Invalid = 0, + Dial = 1, + } + + [NoMac, iOS (16, 0), NoMacCatalyst, NoWatch, NoTV] + [Native] + public enum DDDeviceCategory : long { + HiFiSpeaker = 0, + HiFiSpeakerMultiple = 1, + TvWithMediaBox = 2, + Tv = 3, + LaptopComputer = 4, + DesktopComputer = 5, + } + + [NoMac, iOS (16, 0), NoMacCatalyst, NoWatch, NoTV] + [Native] + public enum DDDeviceState : long { + Invalid = 0, + Activating = 10, + Activated = 20, + Authorized = 25, + Invalidating = 30, + } + + [NoMac, iOS (16, 0), NoMacCatalyst, NoWatch, NoTV] + [Native] + public enum DDDeviceMediaPlaybackState : long { + NoContent = 0, + Paused = 1, + Playing = 2, + } + + [NoMac, iOS (16, 0), NoMacCatalyst, NoWatch, NoTV] + [ErrorDomain ("DDErrorDomain")] + [Native] + public enum DDErrorCode : long { + Success = 0, + Unknown = 350000, + BadParameter = 350001, + Unsupported = 350002, + Timeout = 350003, + Internal = 350004, + MissingEntitlement = 350005, + Permission = 350006, + // Next, // don't bind 'Next', it's not static and we'd have to break compat if it were ever to change + } + + [NoMac, iOS (16, 0), NoMacCatalyst, NoWatch, NoTV] + [Native] + public enum DDEventType : long { + Unknown = 0, + DeviceFound = 40, + DeviceLost = 41, + DeviceChanged = 42, + } +} diff --git a/src/build/generator-frameworks.g.cs b/src/build/generator-frameworks.g.cs index a7366d9a99d6..5ece100011cf 100644 --- a/src/build/generator-frameworks.g.cs +++ b/src/build/generator-frameworks.g.cs @@ -54,6 +54,7 @@ partial class Frameworks { "CoreText", "CoreVideo", "DeviceCheck", + "DeviceDiscoveryExtension", "EventKit", "EventKitUI", "ExternalAccessory", @@ -604,6 +605,7 @@ partial class Frameworks { bool? _CoreVideo; bool? _CoreWlan; bool? _DeviceCheck; + bool? _DeviceDiscoveryExtension; bool? _DeviceDiscoveryUI; bool? _EventKit; bool? _EventKitUI; @@ -770,6 +772,7 @@ partial class Frameworks { public bool HaveCoreVideo { get { if (!_CoreVideo.HasValue) _CoreVideo = GetValue ("CoreVideo"); return _CoreVideo.Value; } } public bool HaveCoreWlan { get { if (!_CoreWlan.HasValue) _CoreWlan = GetValue ("CoreWlan"); return _CoreWlan.Value; } } public bool HaveDeviceCheck { get { if (!_DeviceCheck.HasValue) _DeviceCheck = GetValue ("DeviceCheck"); return _DeviceCheck.Value; } } + public bool HaveDeviceDiscoveryExtension { get { if (!_DeviceDiscoveryExtension.HasValue) _DeviceDiscoveryExtension = GetValue ("DeviceDiscoveryExtension"); return _DeviceDiscoveryExtension.Value; } } public bool HaveDeviceDiscoveryUI { get { if (!_DeviceDiscoveryUI.HasValue) _DeviceDiscoveryUI = GetValue ("DeviceDiscoveryUI"); return _DeviceDiscoveryUI.Value; } } public bool HaveEventKit { get { if (!_EventKit.HasValue) _EventKit = GetValue ("EventKit"); return _EventKit.Value; } } public bool HaveEventKitUI { get { if (!_EventKitUI.HasValue) _EventKitUI = GetValue ("EventKitUI"); return _EventKitUI.Value; } } diff --git a/src/devicediscoveryextension.cs b/src/devicediscoveryextension.cs new file mode 100644 index 000000000000..d7b4900f3568 --- /dev/null +++ b/src/devicediscoveryextension.cs @@ -0,0 +1,107 @@ +// +// DeviceDiscoveryExtension C# bindings +// +// Authors: +// Israel Soto (issoto@microsoft.com) +// Rolf Bjarne Kvinge (rolf@xamarin.com) +// +// Copyright 2022, 2024 Microsoft Corporation. +// + +using System; +using ObjCRuntime; +using Foundation; +using UniformTypeIdentifiers; + +using nw_endpoint_t = System.IntPtr; + +#if !NET +using NativeHandle = System.IntPtr; +#endif + +namespace DeviceDiscoveryExtension { + + [Static] + [NoMac, iOS (16, 0), NoMacCatalyst, NoWatch, NoTV] + interface DDDeviceProtocolStrings { + [Field ("DDDeviceProtocolStringInvalid")] + NSString Invalid { get; } + + [Field ("DDDeviceProtocolStringDIAL")] + NSString Dial { get; } + } + + [NoMac, iOS (16, 0), NoMacCatalyst, NoWatch, NoTV] + [BaseType (typeof (NSObject))] + [DisableDefaultCtor] + interface DDDevice { + [Export ("initWithDisplayName:category:protocolType:identifier:")] + [DesignatedInitializer] + NativeHandle Constructor (string displayName, DDDeviceCategory category, UTType protocolType, string identifier); + + [NullAllowed, Export ("bluetoothIdentifier", ArgumentSemantic.Strong)] + NSUuid BluetoothIdentifier { get; set; } + + [Export ("category", ArgumentSemantic.Assign)] + DDDeviceCategory Category { get; set; } + + [Export ("displayName")] + string DisplayName { get; set; } + + [Export ("identifier")] + string Identifier { get; set; } + + [Internal] + [Export ("networkEndpoint", ArgumentSemantic.Strong)] + nw_endpoint_t _NetworkEndpoint { get; set; } + + [Export ("protocol", ArgumentSemantic.Assign)] + DDDeviceProtocol Protocol { get; set; } + + [Export ("protocolType", ArgumentSemantic.Strong)] + UTType ProtocolType { get; set; } + + [Export ("state", ArgumentSemantic.Assign)] + DDDeviceState State { get; set; } + + [NullAllowed, Export ("txtRecordData", ArgumentSemantic.Copy)] + NSData TxtRecordData { get; set; } + + [Export ("url", ArgumentSemantic.Copy)] + NSUrl Url { get; set; } + + [Export ("mediaPlaybackState", ArgumentSemantic.Assign)] + DDDeviceMediaPlaybackState MediaPlaybackState { get; set; } + + [NullAllowed, Export ("mediaContentTitle")] + string MediaContentTitle { get; set; } + + [NullAllowed, Export ("mediaContentSubtitle")] + string MediaContentSubtitle { get; set; } + + [iOS (17, 0)] + [Export ("supportsGrouping")] + bool SupportsGrouping { get; set; } + } + + [NoMac, iOS (16, 0), NoMacCatalyst, NoWatch, NoTV] + [BaseType (typeof (NSObject))] + [DisableDefaultCtor] + interface DDDeviceEvent { + [Export ("initWithEventType:device:")] + NativeHandle Constructor (DDEventType type, DDDevice device); + + [Export ("device", ArgumentSemantic.Strong)] + DDDevice Device { get; } + + [Export ("eventType", ArgumentSemantic.Assign)] + DDEventType EventType { get; } + } + + [NoMac, iOS (16, 0), NoMacCatalyst, NoWatch, NoTV] + [BaseType (typeof (NSObject))] + interface DDDiscoverySession { + [Export ("reportEvent:")] + void ReportEvent (DDDeviceEvent inEvent); + } +} diff --git a/src/frameworks.sources b/src/frameworks.sources index bc34c4398783..bf10e75532e0 100644 --- a/src/frameworks.sources +++ b/src/frameworks.sources @@ -726,6 +726,14 @@ COREWLAN_SOURCES = \ CoreWlan/CWInterface.cs \ CoreWlan/CWKeychain.cs \ +# DeviceDiscoveryExtension + +DEVICEDISCOVERYEXTENSION_API_SOURCES = \ + DeviceDiscoveryExtension/Enums.cs \ + +DEVICEDISCOVERYEXTENSION_SOURCES = \ + DeviceDiscoveryExtension/DDDevice.cs \ + # DeviceDiscoveryUI DEVICEDISCOVERYUI_SOURCES = \ @@ -2198,6 +2206,7 @@ IOS_FRAMEWORKS = \ CoreSpotlight \ CoreTelephony \ CoreText \ + DeviceDiscoveryExtension \ EventKit \ EventKitUI \ ExternalAccessory \ diff --git a/src/rsp/dotnet/ios-defines-dotnet.rsp b/src/rsp/dotnet/ios-defines-dotnet.rsp index 29b6f1c89452..8b2c3cd94dd9 100644 --- a/src/rsp/dotnet/ios-defines-dotnet.rsp +++ b/src/rsp/dotnet/ios-defines-dotnet.rsp @@ -48,6 +48,7 @@ -d:HAS_CORETEXT -d:HAS_COREVIDEO -d:HAS_DEVICECHECK +-d:HAS_DEVICEDISCOVERYEXTENSION -d:HAS_EVENTKIT -d:HAS_EVENTKITUI -d:HAS_EXTERNALACCESSORY diff --git a/src/rsp/ios-defines.rsp b/src/rsp/ios-defines.rsp index fa704c43677f..732a486073dd 100644 --- a/src/rsp/ios-defines.rsp +++ b/src/rsp/ios-defines.rsp @@ -49,6 +49,7 @@ -d:HAS_CORETEXT -d:HAS_COREVIDEO -d:HAS_DEVICECHECK +-d:HAS_DEVICEDISCOVERYEXTENSION -d:HAS_EVENTKIT -d:HAS_EVENTKITUI -d:HAS_EXTERNALACCESSORY diff --git a/tests/cecil-tests/Documentation.KnownFailures.txt b/tests/cecil-tests/Documentation.KnownFailures.txt index b4c65f7cb8fa..a0cb34c12499 100644 --- a/tests/cecil-tests/Documentation.KnownFailures.txt +++ b/tests/cecil-tests/Documentation.KnownFailures.txt @@ -9769,6 +9769,40 @@ F:DeviceCheck.DCError.InvalidKey F:DeviceCheck.DCError.ServerUnavailable F:DeviceCheck.DCError.UnknownSystemFailure F:DeviceCheck.DCError.value__ +F:DeviceDiscoveryExtension.DDDeviceCategory.DesktopComputer +F:DeviceDiscoveryExtension.DDDeviceCategory.HiFiSpeaker +F:DeviceDiscoveryExtension.DDDeviceCategory.HiFiSpeakerMultiple +F:DeviceDiscoveryExtension.DDDeviceCategory.LaptopComputer +F:DeviceDiscoveryExtension.DDDeviceCategory.Tv +F:DeviceDiscoveryExtension.DDDeviceCategory.TvWithMediaBox +F:DeviceDiscoveryExtension.DDDeviceCategory.value__ +F:DeviceDiscoveryExtension.DDDeviceMediaPlaybackState.NoContent +F:DeviceDiscoveryExtension.DDDeviceMediaPlaybackState.Paused +F:DeviceDiscoveryExtension.DDDeviceMediaPlaybackState.Playing +F:DeviceDiscoveryExtension.DDDeviceMediaPlaybackState.value__ +F:DeviceDiscoveryExtension.DDDeviceProtocol.Dial +F:DeviceDiscoveryExtension.DDDeviceProtocol.Invalid +F:DeviceDiscoveryExtension.DDDeviceProtocol.value__ +F:DeviceDiscoveryExtension.DDDeviceState.Activated +F:DeviceDiscoveryExtension.DDDeviceState.Activating +F:DeviceDiscoveryExtension.DDDeviceState.Authorized +F:DeviceDiscoveryExtension.DDDeviceState.Invalid +F:DeviceDiscoveryExtension.DDDeviceState.Invalidating +F:DeviceDiscoveryExtension.DDDeviceState.value__ +F:DeviceDiscoveryExtension.DDErrorCode.BadParameter +F:DeviceDiscoveryExtension.DDErrorCode.Internal +F:DeviceDiscoveryExtension.DDErrorCode.MissingEntitlement +F:DeviceDiscoveryExtension.DDErrorCode.Permission +F:DeviceDiscoveryExtension.DDErrorCode.Success +F:DeviceDiscoveryExtension.DDErrorCode.Timeout +F:DeviceDiscoveryExtension.DDErrorCode.Unknown +F:DeviceDiscoveryExtension.DDErrorCode.Unsupported +F:DeviceDiscoveryExtension.DDErrorCode.value__ +F:DeviceDiscoveryExtension.DDEventType.DeviceChanged +F:DeviceDiscoveryExtension.DDEventType.DeviceFound +F:DeviceDiscoveryExtension.DDEventType.DeviceLost +F:DeviceDiscoveryExtension.DDEventType.Unknown +F:DeviceDiscoveryExtension.DDEventType.value__ F:EventKit.EKAlarmProximity.Enter F:EventKit.EKAlarmProximity.Leave F:EventKit.EKAlarmProximity.None @@ -17555,6 +17589,7 @@ F:ObjCRuntime.Constants.CoreVideoLibrary F:ObjCRuntime.Constants.CoreWlanLibrary F:ObjCRuntime.Constants.CryptoTokenKitLibrary F:ObjCRuntime.Constants.DeviceCheckLibrary +F:ObjCRuntime.Constants.DeviceDiscoveryExtensionLibrary F:ObjCRuntime.Constants.DeviceDiscoveryUILibrary F:ObjCRuntime.Constants.EventKitLibrary F:ObjCRuntime.Constants.EventKitUILibrary @@ -60019,6 +60054,34 @@ M:DeviceCheck.DCDeviceGenerateTokenCompletionHandler.BeginInvoke(Foundation.NSDa M:DeviceCheck.DCDeviceGenerateTokenCompletionHandler.EndInvoke(System.IAsyncResult) M:DeviceCheck.DCDeviceGenerateTokenCompletionHandler.Invoke(Foundation.NSData,Foundation.NSError) M:DeviceCheck.DCErrorExtensions.GetDomain(DeviceCheck.DCError) +M:DeviceDiscoveryExtension.DDDevice.#ctor(Foundation.NSObjectFlag) +M:DeviceDiscoveryExtension.DDDevice.#ctor(ObjCRuntime.NativeHandle) +M:DeviceDiscoveryExtension.DDDevice.get_ClassHandle +M:DeviceDiscoveryExtension.DDDevice.get_NetworkEndpoint +M:DeviceDiscoveryExtension.DDDevice.set_BluetoothIdentifier(Foundation.NSUuid) +M:DeviceDiscoveryExtension.DDDevice.set_Category(DeviceDiscoveryExtension.DDDeviceCategory) +M:DeviceDiscoveryExtension.DDDevice.set_DisplayName(System.String) +M:DeviceDiscoveryExtension.DDDevice.set_Identifier(System.String) +M:DeviceDiscoveryExtension.DDDevice.set_MediaContentSubtitle(System.String) +M:DeviceDiscoveryExtension.DDDevice.set_MediaContentTitle(System.String) +M:DeviceDiscoveryExtension.DDDevice.set_MediaPlaybackState(DeviceDiscoveryExtension.DDDeviceMediaPlaybackState) +M:DeviceDiscoveryExtension.DDDevice.set_NetworkEndpoint(Network.NWEndpoint) +M:DeviceDiscoveryExtension.DDDevice.set_Protocol(DeviceDiscoveryExtension.DDDeviceProtocol) +M:DeviceDiscoveryExtension.DDDevice.set_ProtocolType(UniformTypeIdentifiers.UTType) +M:DeviceDiscoveryExtension.DDDevice.set_State(DeviceDiscoveryExtension.DDDeviceState) +M:DeviceDiscoveryExtension.DDDevice.set_SupportsGrouping(System.Boolean) +M:DeviceDiscoveryExtension.DDDevice.set_TxtRecordData(Foundation.NSData) +M:DeviceDiscoveryExtension.DDDevice.set_Url(Foundation.NSUrl) +M:DeviceDiscoveryExtension.DDDeviceEvent.#ctor(Foundation.NSObjectFlag) +M:DeviceDiscoveryExtension.DDDeviceEvent.#ctor(ObjCRuntime.NativeHandle) +M:DeviceDiscoveryExtension.DDDeviceEvent.get_ClassHandle +M:DeviceDiscoveryExtension.DDDeviceProtocolStrings.get_Dial +M:DeviceDiscoveryExtension.DDDeviceProtocolStrings.get_Invalid +M:DeviceDiscoveryExtension.DDDiscoverySession.#ctor +M:DeviceDiscoveryExtension.DDDiscoverySession.#ctor(Foundation.NSObjectFlag) +M:DeviceDiscoveryExtension.DDDiscoverySession.#ctor(ObjCRuntime.NativeHandle) +M:DeviceDiscoveryExtension.DDDiscoverySession.get_ClassHandle +M:DeviceDiscoveryExtension.DDErrorCodeExtensions.GetDomain(DeviceDiscoveryExtension.DDErrorCode) M:DeviceDiscoveryUI.DDDevicePickerViewController.#ctor(Foundation.NSCoder) M:DeviceDiscoveryUI.DDDevicePickerViewController.#ctor(Foundation.NSObjectFlag) M:DeviceDiscoveryUI.DDDevicePickerViewController.#ctor(ObjCRuntime.NativeHandle) @@ -127624,6 +127687,27 @@ P:DeviceCheck.DCAppAttestService.Supported P:DeviceCheck.DCDevice.ClassHandle P:DeviceCheck.DCDevice.CurrentDevice P:DeviceCheck.DCDevice.Supported +P:DeviceDiscoveryExtension.DDDevice.BluetoothIdentifier +P:DeviceDiscoveryExtension.DDDevice.Category +P:DeviceDiscoveryExtension.DDDevice.ClassHandle +P:DeviceDiscoveryExtension.DDDevice.DisplayName +P:DeviceDiscoveryExtension.DDDevice.Identifier +P:DeviceDiscoveryExtension.DDDevice.MediaContentSubtitle +P:DeviceDiscoveryExtension.DDDevice.MediaContentTitle +P:DeviceDiscoveryExtension.DDDevice.MediaPlaybackState +P:DeviceDiscoveryExtension.DDDevice.NetworkEndpoint +P:DeviceDiscoveryExtension.DDDevice.Protocol +P:DeviceDiscoveryExtension.DDDevice.ProtocolType +P:DeviceDiscoveryExtension.DDDevice.State +P:DeviceDiscoveryExtension.DDDevice.SupportsGrouping +P:DeviceDiscoveryExtension.DDDevice.TxtRecordData +P:DeviceDiscoveryExtension.DDDevice.Url +P:DeviceDiscoveryExtension.DDDeviceEvent.ClassHandle +P:DeviceDiscoveryExtension.DDDeviceEvent.Device +P:DeviceDiscoveryExtension.DDDeviceEvent.EventType +P:DeviceDiscoveryExtension.DDDeviceProtocolStrings.Dial +P:DeviceDiscoveryExtension.DDDeviceProtocolStrings.Invalid +P:DeviceDiscoveryExtension.DDDiscoverySession.ClassHandle P:DeviceDiscoveryUI.DDDevicePickerViewController.ClassHandle P:EventKit.EKAlarm.AbsoluteDate P:EventKit.EKAlarm.ClassHandle @@ -155865,6 +155949,14 @@ T:Darwin.TimeSpec T:DeviceCheck.DCDeviceGenerateTokenCompletionHandler T:DeviceCheck.DCError T:DeviceCheck.DCErrorExtensions +T:DeviceDiscoveryExtension.DDDeviceCategory +T:DeviceDiscoveryExtension.DDDeviceMediaPlaybackState +T:DeviceDiscoveryExtension.DDDeviceProtocol +T:DeviceDiscoveryExtension.DDDeviceProtocolStrings +T:DeviceDiscoveryExtension.DDDeviceState +T:DeviceDiscoveryExtension.DDErrorCode +T:DeviceDiscoveryExtension.DDErrorCodeExtensions +T:DeviceDiscoveryExtension.DDEventType T:EventKit.EKAlarmProximity T:EventKit.EKAlarmType T:EventKit.EKAuthorizationStatus diff --git a/tests/introspection/iOS/iOSApiProtocolTest.cs b/tests/introspection/iOS/iOSApiProtocolTest.cs index 1aafceecd09d..5cee056bebc1 100644 --- a/tests/introspection/iOS/iOSApiProtocolTest.cs +++ b/tests/introspection/iOS/iOSApiProtocolTest.cs @@ -390,6 +390,10 @@ protected override bool Skip (Type type, string protocolName) case "OSLogEntryLog": case "OSLogEntrySignpost": return true; + // iOS 16 + case "DDDevice": + case "DDDeviceEvent": + return true; #if __WATCHOS__ case "CLKComplicationTemplate": case "CLKComplicationTemplateCircularSmallRingImage": @@ -652,6 +656,10 @@ protected override bool Skip (Type type, string protocolName) case "OSLogEntryLog": case "OSLogEntrySignpost": return true; + // iOS 16 + case "DDDevice": + case "DDDeviceEvent": + return true; #if __WATCHOS__ case "CLKComplicationTemplate": case "CLKComplicationTemplateCircularSmallRingImage": @@ -818,6 +826,9 @@ protected override bool Skip (Type type, string protocolName) case "WKPreferences": // Conformance not in headers case "QLPreviewSceneActivationConfiguration": return true; + // iOS 16 + case "DDDevice": + return true; #if __WATCHOS__ case "CLKComplicationTimelineEntry": return true; diff --git a/tests/monotouch-test/DeviceDiscoveryExtension/DDDeviceTest.cs b/tests/monotouch-test/DeviceDiscoveryExtension/DDDeviceTest.cs new file mode 100644 index 000000000000..b535403fc23d --- /dev/null +++ b/tests/monotouch-test/DeviceDiscoveryExtension/DDDeviceTest.cs @@ -0,0 +1,46 @@ +// +// Unit tests for DDDevice +// +// Authors: +// Israel Soto (issoto@microsoft.com) +// Rolf Bjarne Kvinge (rolf@xamarin.com) +// +// Copyright 2022, 2024 Microsoft Corporation. +// + +#nullable enable + +#if __IOS__ && !__MACCATALYST__ + +using System; +using DeviceDiscoveryExtension; +using Foundation; +using Network; +using ObjCRuntime; +using UniformTypeIdentifiers; +using NUnit.Framework; + +namespace MonoTouchFixtures.DeviceDiscoveryExtension { + + [TestFixture] + [Preserve (AllMembers = true)] + public class DDDeviceTest { + + [Test] + public void NetworkEndpointTest () + { + TestRuntime.AssertXcodeVersion (14,0); + + var uuid = Guid.NewGuid (); + var endpoint = NWEndpoint.Create ("www.microsoft.com", "https"); + var device = new DDDevice ("MyDevice", DDDeviceCategory.LaptopComputer, UTType.CreateFromIdentifier ("com.adobe.pdf"), uuid.ToString ()); + + device.NetworkEndpoint = endpoint; + var tmpEndpoint = device.NetworkEndpoint; + + Assert.True (endpoint.GetHandle () == tmpEndpoint.GetHandle (), "NetworkEndpoint"); + } + } +} + +#endif // __IOS__ diff --git a/tests/mtouch/RegistrarTest.cs b/tests/mtouch/RegistrarTest.cs index 3aa118dc7d4a..f82927898999 100644 --- a/tests/mtouch/RegistrarTest.cs +++ b/tests/mtouch/RegistrarTest.cs @@ -348,6 +348,7 @@ public void MT4134 () new { Framework = "Chip", Version = "15.0" }, new { Framework = "ThreadNetwork", Version = "15.0" }, new { Framework = "BackgroundAssets", Version = "16.0" }, + new { Framework = "DeviceDiscoveryExtension", Version = "16.0" }, new { Framework = "MetalFX", Version = "16.0" }, new { Framework = "PushToTalk", Version = "16.0" }, new { Framework = "SharedWithYou", Version = "16.0" }, diff --git a/tests/xtro-sharpie/api-annotations-dotnet/iOS-DeviceDiscoveryExtension.ignore b/tests/xtro-sharpie/api-annotations-dotnet/iOS-DeviceDiscoveryExtension.ignore new file mode 100644 index 000000000000..6387ff1f6381 --- /dev/null +++ b/tests/xtro-sharpie/api-annotations-dotnet/iOS-DeviceDiscoveryExtension.ignore @@ -0,0 +1,9 @@ +## These C methods are helpers to cast an enum value to string, but the string value is not used anywhere. Ignored them for now. +!missing-pinvoke! DDDeviceCategoryToString is not bound +!missing-pinvoke! DDDeviceMediaPlaybackStateToString is not bound +!missing-pinvoke! DDDeviceProtocolToString is not bound +!missing-pinvoke! DDDeviceStateToString is not bound +!missing-pinvoke! DDEventTypeToString is not bound + +## This is a non-constant enum value, so we're not binding it so that we don't have to break compat in the future +!missing-enum-value! DDErrorCode native value DDErrorCodeNext = 350007 not bound diff --git a/tests/xtro-sharpie/api-annotations-dotnet/iOS-DeviceDiscoveryExtension.todo b/tests/xtro-sharpie/api-annotations-dotnet/iOS-DeviceDiscoveryExtension.todo deleted file mode 100644 index 1006f2f53cd5..000000000000 --- a/tests/xtro-sharpie/api-annotations-dotnet/iOS-DeviceDiscoveryExtension.todo +++ /dev/null @@ -1,50 +0,0 @@ -!missing-enum! DDDeviceCategory not bound -!missing-enum! DDDeviceProtocol not bound -!missing-enum! DDDeviceState not bound -!missing-enum! DDErrorCode not bound -!missing-enum! DDEventType not bound -!missing-field! DDDeviceProtocolStringDIAL not bound -!missing-field! DDDeviceProtocolStringInvalid not bound -!missing-field! DDErrorDomain not bound -!missing-pinvoke! DDDeviceCategoryToString is not bound -!missing-pinvoke! DDDeviceProtocolToString is not bound -!missing-pinvoke! DDDeviceStateToString is not bound -!missing-pinvoke! DDEventTypeToString is not bound -!missing-selector! DDDevice::bluetoothIdentifier not bound -!missing-selector! DDDevice::category not bound -!missing-selector! DDDevice::displayName not bound -!missing-selector! DDDevice::identifier not bound -!missing-selector! DDDevice::initWithDisplayName:category:protocolType:identifier: not bound -!missing-selector! DDDevice::networkEndpoint not bound -!missing-selector! DDDevice::protocol not bound -!missing-selector! DDDevice::protocolType not bound -!missing-selector! DDDevice::setBluetoothIdentifier: not bound -!missing-selector! DDDevice::setCategory: not bound -!missing-selector! DDDevice::setDisplayName: not bound -!missing-selector! DDDevice::setIdentifier: not bound -!missing-selector! DDDevice::setNetworkEndpoint: not bound -!missing-selector! DDDevice::setProtocol: not bound -!missing-selector! DDDevice::setProtocolType: not bound -!missing-selector! DDDevice::setState: not bound -!missing-selector! DDDevice::setTxtRecordData: not bound -!missing-selector! DDDevice::setUrl: not bound -!missing-selector! DDDevice::state not bound -!missing-selector! DDDevice::txtRecordData not bound -!missing-selector! DDDevice::url not bound -!missing-selector! DDDiscoverySession::reportEvent: not bound -!missing-type! DDDevice not bound -!missing-type! DDDeviceEvent not bound -!missing-type! DDDiscoverySession not bound -!missing-selector! DDDeviceEvent::device not bound -!missing-selector! DDDeviceEvent::initWithEventType:device: not bound -!missing-enum! DDDeviceMediaPlaybackState not bound -!missing-pinvoke! DDDeviceMediaPlaybackStateToString is not bound -!missing-selector! DDDevice::mediaContentSubtitle not bound -!missing-selector! DDDevice::mediaContentTitle not bound -!missing-selector! DDDevice::mediaPlaybackState not bound -!missing-selector! DDDevice::setMediaContentSubtitle: not bound -!missing-selector! DDDevice::setMediaContentTitle: not bound -!missing-selector! DDDevice::setMediaPlaybackState: not bound -!missing-selector! DDDeviceEvent::eventType not bound -!missing-selector! DDDevice::setSupportsGrouping: not bound -!missing-selector! DDDevice::supportsGrouping not bound diff --git a/tests/xtro-sharpie/iOS-DeviceDiscoveryExtension.ignore b/tests/xtro-sharpie/iOS-DeviceDiscoveryExtension.ignore new file mode 100644 index 000000000000..6387ff1f6381 --- /dev/null +++ b/tests/xtro-sharpie/iOS-DeviceDiscoveryExtension.ignore @@ -0,0 +1,9 @@ +## These C methods are helpers to cast an enum value to string, but the string value is not used anywhere. Ignored them for now. +!missing-pinvoke! DDDeviceCategoryToString is not bound +!missing-pinvoke! DDDeviceMediaPlaybackStateToString is not bound +!missing-pinvoke! DDDeviceProtocolToString is not bound +!missing-pinvoke! DDDeviceStateToString is not bound +!missing-pinvoke! DDEventTypeToString is not bound + +## This is a non-constant enum value, so we're not binding it so that we don't have to break compat in the future +!missing-enum-value! DDErrorCode native value DDErrorCodeNext = 350007 not bound diff --git a/tests/xtro-sharpie/iOS-DeviceDiscoveryExtension.todo b/tests/xtro-sharpie/iOS-DeviceDiscoveryExtension.todo deleted file mode 100644 index 1006f2f53cd5..000000000000 --- a/tests/xtro-sharpie/iOS-DeviceDiscoveryExtension.todo +++ /dev/null @@ -1,50 +0,0 @@ -!missing-enum! DDDeviceCategory not bound -!missing-enum! DDDeviceProtocol not bound -!missing-enum! DDDeviceState not bound -!missing-enum! DDErrorCode not bound -!missing-enum! DDEventType not bound -!missing-field! DDDeviceProtocolStringDIAL not bound -!missing-field! DDDeviceProtocolStringInvalid not bound -!missing-field! DDErrorDomain not bound -!missing-pinvoke! DDDeviceCategoryToString is not bound -!missing-pinvoke! DDDeviceProtocolToString is not bound -!missing-pinvoke! DDDeviceStateToString is not bound -!missing-pinvoke! DDEventTypeToString is not bound -!missing-selector! DDDevice::bluetoothIdentifier not bound -!missing-selector! DDDevice::category not bound -!missing-selector! DDDevice::displayName not bound -!missing-selector! DDDevice::identifier not bound -!missing-selector! DDDevice::initWithDisplayName:category:protocolType:identifier: not bound -!missing-selector! DDDevice::networkEndpoint not bound -!missing-selector! DDDevice::protocol not bound -!missing-selector! DDDevice::protocolType not bound -!missing-selector! DDDevice::setBluetoothIdentifier: not bound -!missing-selector! DDDevice::setCategory: not bound -!missing-selector! DDDevice::setDisplayName: not bound -!missing-selector! DDDevice::setIdentifier: not bound -!missing-selector! DDDevice::setNetworkEndpoint: not bound -!missing-selector! DDDevice::setProtocol: not bound -!missing-selector! DDDevice::setProtocolType: not bound -!missing-selector! DDDevice::setState: not bound -!missing-selector! DDDevice::setTxtRecordData: not bound -!missing-selector! DDDevice::setUrl: not bound -!missing-selector! DDDevice::state not bound -!missing-selector! DDDevice::txtRecordData not bound -!missing-selector! DDDevice::url not bound -!missing-selector! DDDiscoverySession::reportEvent: not bound -!missing-type! DDDevice not bound -!missing-type! DDDeviceEvent not bound -!missing-type! DDDiscoverySession not bound -!missing-selector! DDDeviceEvent::device not bound -!missing-selector! DDDeviceEvent::initWithEventType:device: not bound -!missing-enum! DDDeviceMediaPlaybackState not bound -!missing-pinvoke! DDDeviceMediaPlaybackStateToString is not bound -!missing-selector! DDDevice::mediaContentSubtitle not bound -!missing-selector! DDDevice::mediaContentTitle not bound -!missing-selector! DDDevice::mediaPlaybackState not bound -!missing-selector! DDDevice::setMediaContentSubtitle: not bound -!missing-selector! DDDevice::setMediaContentTitle: not bound -!missing-selector! DDDevice::setMediaPlaybackState: not bound -!missing-selector! DDDeviceEvent::eventType not bound -!missing-selector! DDDevice::setSupportsGrouping: not bound -!missing-selector! DDDevice::supportsGrouping not bound diff --git a/tools/common/Frameworks.cs b/tools/common/Frameworks.cs index 726547d30ea9..30f894895802 100644 --- a/tools/common/Frameworks.cs +++ b/tools/common/Frameworks.cs @@ -461,6 +461,7 @@ public static Frameworks CreateiOSFrameworks (bool is_simulator_build) { "AVRouting", "AVRouting", 16,0}, { "BackgroundAssets", "BackgroundAssets", 16,0}, + { "DeviceDiscoveryExtension", "DeviceDiscoveryExtension", 16, 0}, { "MetalFX", "MetalFX", new Version (16,0), NotAvailableInSimulator }, { "PushToTalk", "PushToTalk", new Version (16,0), new Version (16, 2) /* available to build with, although it's unusable */}, { "SharedWithYou", "SharedWithYou", 16, 0 }, @@ -691,6 +692,7 @@ public static Frameworks GetMacCatalystFrameworks () f.Version = v16_1; break; // These frameworks are not available on Mac Catalyst + case "DeviceDiscoveryExtension": case "OpenGLES": case "NewsstandKit": case "MediaSetup": diff --git a/tools/mtouch/Makefile b/tools/mtouch/Makefile index ae25da0fe00f..6a96bab19545 100644 --- a/tools/mtouch/Makefile +++ b/tools/mtouch/Makefile @@ -178,6 +178,7 @@ SIMLAUNCHER_FRAMEWORKS = \ \ -weak_framework AVRouting \ -weak_framework BackgroundAssets \ + -weak_framework DeviceDiscoveryExtension \ -weak_framework SharedWithYou \ -weak_framework SharedWithYouCore \ \