Skip to content
Merged
110 changes: 108 additions & 2 deletions src/HomeKit/HMCompat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class HMChipServiceRequestHandler : NSObject, INSExtensionRequestHandling

} /* class HMChipServiceRequestHandler */

[Obsolete ("This class is removed, use 'HMMatterTopology' instead.")]
[Obsolete ("This class is removed.")]
[Register ("HMCHIPServiceTopology", SkipRegistration = true)]
public class HMChipServiceTopology : NSObject, INSCoding, INSCopying, INSSecureCoding {

Expand Down Expand Up @@ -82,7 +82,7 @@ public class HMChipServiceRoom : NSObject, INSCoding, INSCopying, INSSecureCodin

} /* class HMChipServiceRoom */

[Obsolete ("This class is removed, use 'HMMatterHome' instead.")]
[Obsolete ("This class is removed.")]
[Register("HMCHIPServiceHome", SkipRegistration = true)]
public partial class HMChipServiceHome : NSObject, INSCoding, INSCopying, INSSecureCoding {

Expand Down Expand Up @@ -131,6 +131,112 @@ public unsafe partial class HMAccessorySetupManager : NSObject {
public virtual void PerformMatterEcosystemAccessorySetup (HMAccessorySetupRequest request, HMMatterTopology topology, Action<NSError> completion) => throw new InvalidOperationException (Constants.RemovedFromHomeKit);
public virtual Task PerformMatterEcosystemAccessorySetupAsync (HMAccessorySetupRequest request, HMMatterTopology topology) => throw new InvalidOperationException (Constants.RemovedFromHomeKit);
}

#endif

#if !NET
[Obsolete ("This class is removed.")]
#else
[UnsupportedOSPlatform ("ios16.1")]
[UnsupportedOSPlatform ("tvos16.1")]
[UnsupportedOSPlatform ("maccatalyst16.1")]
[UnsupportedOSPlatform ("macos13.0")]
#endif
[Register ("HMMatterRoom", SkipRegistration = true)]
public partial class HMMatterRoom : NSObject, INSCoding, INSCopying, INSSecureCoding {
public override NativeHandle ClassHandle => throw new InvalidOperationException (Constants.RemovedFromHomeKit);
protected HMMatterRoom (NativeHandle handle) => throw new InvalidOperationException (Constants.RemovedFromHomeKit);
public HMMatterRoom (NSCoder coder) => throw new InvalidOperationException (Constants.RemovedFromHomeKit);
protected HMMatterRoom (NSObjectFlag t) => throw new InvalidOperationException (Constants.RemovedFromHomeKit);
public HMMatterRoom (NSUuid uuid, string name) => throw new InvalidOperationException (Constants.RemovedFromHomeKit);

public virtual string Name => throw new InvalidOperationException (Constants.RemovedFromHomeKit);
public virtual NSUuid Uuid => throw new InvalidOperationException (Constants.RemovedFromHomeKit);

public virtual NSObject Copy (NSZone? zone)=> throw new InvalidOperationException (Constants.RemovedFromHomeKit);
public virtual void EncodeTo (NSCoder encoder) => throw new InvalidOperationException (Constants.RemovedFromHomeKit);

}

#if !NET
[Obsolete ("This class is removed.")]
#else
[UnsupportedOSPlatform ("ios16.1")]
[UnsupportedOSPlatform ("tvos16.1")]
[UnsupportedOSPlatform ("maccatalyst16.1")]
[UnsupportedOSPlatform ("macos13.0")]
#endif
[Register("HMMatterHome", SkipRegistration = true)]
public partial class HMMatterHome : NSObject, INSCoding, INSCopying, INSSecureCoding {

public override NativeHandle ClassHandle => throw new InvalidOperationException (Constants.RemovedFromHomeKit);

protected HMMatterHome (NativeHandle handle) => throw new InvalidOperationException (Constants.RemovedFromHomeKit);
public HMMatterHome (NSCoder coder) => throw new InvalidOperationException (Constants.RemovedFromHomeKit);
protected HMMatterHome (NSObjectFlag t) => throw new InvalidOperationException (Constants.RemovedFromHomeKit);

public HMMatterHome (NSUuid uuid, string name) => throw new InvalidOperationException (Constants.RemovedFromHomeKit);
public virtual NSObject Copy (NSZone? zone) => throw new InvalidOperationException (Constants.RemovedFromHomeKit);

public virtual void EncodeTo (NSCoder encoder) => throw new InvalidOperationException (Constants.RemovedFromHomeKit);
public virtual string Name => throw new InvalidOperationException (Constants.RemovedFromHomeKit);
public virtual NSUuid Uuid => throw new InvalidOperationException (Constants.RemovedFromHomeKit);

}

#if !NET
[Obsolete ("This class is removed.")]
#else
[UnsupportedOSPlatform ("ios16.1")]
[UnsupportedOSPlatform ("tvos16.1")]
[UnsupportedOSPlatform ("maccatalyst16.1")]
[UnsupportedOSPlatform ("macos13.0")]
#endif
[Register("HMMatterTopology", SkipRegistration = true)]
public partial class HMMatterTopology : NSObject, INSCoding, INSCopying, INSSecureCoding {

public override NativeHandle ClassHandle => throw new InvalidOperationException (Constants.RemovedFromHomeKit);

protected HMMatterTopology (NativeHandle handle) => throw new InvalidOperationException (Constants.RemovedFromHomeKit);
public HMMatterTopology (NSCoder coder) => throw new InvalidOperationException (Constants.RemovedFromHomeKit);
protected HMMatterTopology (NSObjectFlag t) => throw new InvalidOperationException (Constants.RemovedFromHomeKit);

public HMMatterTopology (HMMatterHome [] homes) => throw new InvalidOperationException (Constants.RemovedFromHomeKit);

public virtual HMMatterHome [] Homes => throw new InvalidOperationException (Constants.RemovedFromHomeKit);
public virtual NSObject Copy (NSZone? zone)=> throw new InvalidOperationException (Constants.RemovedFromHomeKit);
public virtual void EncodeTo (NSCoder encoder) => throw new InvalidOperationException (Constants.RemovedFromHomeKit);
}

public delegate void HMFetchRoomHandler (HMMatterRoom [] rooms, NSError error);

#if !NET
[Obsolete ("This class is removed.")]
#else
[UnsupportedOSPlatform ("ios16.1")]
[UnsupportedOSPlatform ("tvos16.1")]
[UnsupportedOSPlatform ("maccatalyst16.1")]
[UnsupportedOSPlatform ("macos13.0")]
#endif
[Register("HMMatterRequestHandler", SkipRegistration = true)]
public partial class HMMatterRequestHandler : NSObject, INSExtensionRequestHandling {
public override NativeHandle ClassHandle => throw new InvalidOperationException (Constants.RemovedFromHomeKit);

public HMMatterRequestHandler () => throw new InvalidOperationException (Constants.RemovedFromHomeKit);
protected HMMatterRequestHandler (NativeHandle handle) => throw new InvalidOperationException (Constants.RemovedFromHomeKit);
protected HMMatterRequestHandler (NSObjectFlag t) => throw new InvalidOperationException (Constants.RemovedFromHomeKit);

public virtual void FetchRooms (HMMatterHome home, HMFetchRoomHandler completion) => throw new InvalidOperationException (Constants.RemovedFromHomeKit);
public virtual Task<HMMatterRoom[]> FetchRoomsAsync (HMMatterHome home) => throw new InvalidOperationException (Constants.RemovedFromHomeKit);

public virtual void PairAccessory (HMMatterHome home, string onboardingPayload, Action<NSError> completion) => throw new InvalidOperationException (Constants.RemovedFromHomeKit);
public virtual Task PairAccessoryAsync (HMMatterHome home, string onboardingPayload) => throw new InvalidOperationException (Constants.RemovedFromHomeKit);

public virtual void ConfigureAccessory (string accessoryName, HMMatterRoom accessoryRoom, Action<NSError> completion) => throw new InvalidOperationException (Constants.RemovedFromHomeKit);
public virtual Task ConfigureAccessoryAsync (string accessoryName, HMMatterRoom accessoryRoom) => throw new InvalidOperationException (Constants.RemovedFromHomeKit);

public virtual void BeginRequestWithExtensionContext (NSExtensionContext context) => throw new InvalidOperationException (Constants.RemovedFromHomeKit);
}

#endif
}
94 changes: 22 additions & 72 deletions src/homekit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ partial interface HMHomeManager {
[Protocolize]
HMHomeManagerDelegate Delegate { get; set; }

[Deprecated (PlatformName.MacOSX, 13,0, message: "No longer supported.")]
[Deprecated (PlatformName.iOS, 16,1, message: "No longer supported.")]
[Deprecated (PlatformName.MacCatalyst, 16,1, message: "No longer supported.")]
[Deprecated (PlatformName.WatchOS, 9,1, message: "No longer supported.")]
[Deprecated (PlatformName.TvOS, 16,1, message: "No longer supported.")]
[NullAllowed, Export ("primaryHome", ArgumentSemantic.Retain)]
HMHome PrimaryHome { get; }

Expand All @@ -47,6 +52,9 @@ partial interface HMHomeManager {

[NoTV]
[NoWatch]
[Deprecated (PlatformName.MacOSX, 13, 0, message: "No longer supported.")]
[Deprecated (PlatformName.iOS, 16,1, message: "No longer supported.")]
[Deprecated (PlatformName.MacCatalyst, 16,1, message: "No longer supported.")]
[Async]
[Export ("updatePrimaryHome:completionHandler:")]
void UpdatePrimaryHome (HMHome home, Action<NSError> completion);
Expand Down Expand Up @@ -166,6 +174,11 @@ partial interface HMAccessory {
[NullAllowed, Export ("firmwareVersion")]
string FirmwareVersion { get; }

[NullAllowed]
[Mac (13,0), iOS (16,1), MacCatalyst (16,1), Watch (9,1), TV (16,1)]
[Export ("matterNodeID", ArgumentSemantic.Copy)]
NSNumber MatterNodeId { get; }

[NoTV]
[NoWatch]
[Async]
Expand Down Expand Up @@ -537,7 +550,6 @@ partial interface HMCharacteristicWriteAction {

[NoTV]
[NoWatch]
[DesignatedInitializer]
[Export ("initWithCharacteristic:targetValue:")]
#if XAMCORE_3_0
NativeHandle Constructor (HMCharacteristic characteristic, INSCopying targetValue);
Expand Down Expand Up @@ -774,6 +786,15 @@ partial interface HMHome {
[Export ("homeAccessControlForUser:")]
HMHomeAccessControl GetHomeAccessControl (HMUser user);

// @interface Matter (HMHome)
[TV (16,1), iOS (16, 1), MacCatalyst (16,1), Watch (9,1)]
[Export ("matterControllerID")]
string MatterControllerId { get; }

[TV (16,1), iOS (16, 1), MacCatalyst (16,1), Watch (9,1)]
[Export ("matterControllerXPCConnectBlock", ArgumentSemantic.Strong)]
Func<NSXpcConnection> MatterControllerXPCConnectBlock { get; }

// constants

[MacCatalyst (14,0)]
Expand Down Expand Up @@ -1921,77 +1942,6 @@ interface HMAccessControl {

}

[iOS (15,2), Watch (8,3), TV (15,2), MacCatalyst (15,2)]
[BaseType (typeof (NSObject))]
[DisableDefaultCtor]
interface HMMatterHome : NSCopying, NSSecureCoding
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was it intentional to remove these types?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, since it won't compile without them.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this addressed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh nevermind! I see that's what those added classes are there for!

{
[Wrap ("true ? throw new InvalidOperationException (Constants.RemovedFromHomeKit) : false", IsVirtual = true)]
[Export ("uuid", ArgumentSemantic.Strong)]
NSUuid Uuid { get; }

[Wrap ("true ? throw new InvalidOperationException (Constants.RemovedFromHomeKit) : false", IsVirtual = true)]
[Export ("name", ArgumentSemantic.Strong)]
string Name { get; }

[Wrap ("true ? throw new InvalidOperationException (Constants.RemovedFromHomeKit) : false", IsVirtual = true)]
[Export ("initWithUUID:name:")]
[DesignatedInitializer]
NativeHandle Constructor (NSUuid uuid, string name);
}

delegate void HMFetchRoomHandler (HMMatterRoom [] rooms, NSError error);

[iOS (15,2), Watch (8,3), TV (15,2), MacCatalyst (15,2)]
[BaseType (typeof (NSObject))]
interface HMMatterRequestHandler : NSExtensionRequestHandling
{
[Async]
[Export ("fetchRoomsInHome:completion:")]
void FetchRooms (HMMatterHome home, HMFetchRoomHandler completion);

[Async]
[Export ("pairAccessoryInHome:onboardingPayload:completion:")]
void PairAccessory (HMMatterHome home, string onboardingPayload, Action<NSError> completion);

[Async]
[Export ("configureAccessoryWithName:room:completion:")]
void ConfigureAccessory (string accessoryName, HMMatterRoom accessoryRoom, Action<NSError> completion);
}

[iOS (15,2), Watch (8,3), TV (15,2), MacCatalyst (15,2)]
[BaseType (typeof (NSObject))]
[DisableDefaultCtor]
interface HMMatterRoom : NSCopying, NSSecureCoding
{
[Wrap ("true ? throw new InvalidOperationException (Constants.RemovedFromHomeKit) : false", IsVirtual = true)]
[Export ("uuid", ArgumentSemantic.Strong)]
NSUuid Uuid { get; }

[Wrap ("true ? throw new InvalidOperationException (Constants.RemovedFromHomeKit) : false", IsVirtual = true)]
[Export ("name", ArgumentSemantic.Strong)]
string Name { get; }

[Wrap ("true ? throw new InvalidOperationException (Constants.RemovedFromHomeKit) : false", IsVirtual = true)]
[Export ("initWithUUID:name:")]
[DesignatedInitializer]
NativeHandle Constructor (NSUuid uuid, string name);
}

[iOS (15,2), Watch (8,3), TV (15,2), MacCatalyst (15,2)]
[BaseType (typeof (NSObject))]
[DisableDefaultCtor]
interface HMMatterTopology : NSCopying, NSSecureCoding
{
[Wrap ("true ? throw new InvalidOperationException (Constants.RemovedFromHomeKit) : false", IsVirtual = true)]
[Export ("initWithHomes:")]
NativeHandle Constructor (HMMatterHome [] homes);

[Wrap ("true ? throw new InvalidOperationException (Constants.RemovedFromHomeKit) : false", IsVirtual = true)]
[Export ("homes", ArgumentSemantic.Copy)]
HMMatterHome [] Homes { get; }
}

[NoWatch, NoTV, NoMacCatalyst, NoMac, iOS (15,4)]
[BaseType (typeof (NSObject))]
interface HMAccessorySetupRequest : NSCopying {
Expand Down
2 changes: 2 additions & 0 deletions tests/introspection/ApiCtorInitTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ protected virtual bool Skip (Type type)
// Causes a crash later. Filed as radar://18440271.
// Apple said they won't fix this ('init' isn't a designated initializer)
return true;
case "HMMatterRequestHandler": // got removed and the current API throws an exception at run time.
return true;
}

#if !NET
Expand Down
3 changes: 3 additions & 0 deletions tests/introspection/ApiProtocolTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ protected virtual bool Skip (Type type)
case "CLKComplicationWidgetMigrator":
// Not present in the simulator, is a migration class
return true;
// was removed by apple and is a compat class.
case "HMMatterRequestHandler":
return true;
default:
return SkipDueToAttribute (type);
}
Expand Down
10 changes: 0 additions & 10 deletions tests/xtro-sharpie/api-annotations-dotnet/iOS-HomeKit.todo

This file was deleted.

8 changes: 0 additions & 8 deletions tests/xtro-sharpie/api-annotations-dotnet/tvOS-HomeKit.todo

This file was deleted.

10 changes: 0 additions & 10 deletions tests/xtro-sharpie/iOS-HomeKit.todo

This file was deleted.

8 changes: 0 additions & 8 deletions tests/xtro-sharpie/tvOS-HomeKit.todo

This file was deleted.

8 changes: 0 additions & 8 deletions tests/xtro-sharpie/watchOS-HomeKit.todo

This file was deleted.