Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[main] Fix selectors from submission tests #16042

Merged
merged 12 commits into from
Sep 27, 2022
353 changes: 353 additions & 0 deletions src/Chip/ChipCompat.cs

Large diffs are not rendered by default.

113 changes: 70 additions & 43 deletions src/HomeKit/HMCompat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,19 @@
//

using System;
using System.ComponentModel;
using System.Threading.Tasks;
using Foundation;
using CoreFoundation;
using ObjCRuntime;

#if !NET
using NativeHandle = System.IntPtr;
#endif

#nullable enable
namespace HomeKit {

#if !NET
[Obsolete ("Use 'HMFetchRoomHandler' instead.")]
public delegate void FetchRoomHandler (NSArray<HMChipServiceRoom> rooms, NSError error);

Expand All @@ -26,84 +31,106 @@ namespace HomeKit {
[Register ("HMCHIPServiceRequestHandler", SkipRegistration = true)]
public class HMChipServiceRequestHandler : NSObject, INSExtensionRequestHandling {

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

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

public virtual void BeginRequestWithExtensionContext (NSExtensionContext context) => throw new InvalidOperationException ();
public virtual void ConfigureAccessory (string accessoryName, HMChipServiceRoom accessoryRoom, Action<NSError> completion) => throw new InvalidOperationException ();
public virtual Task ConfigureAccessoryAsync (string accessoryName, HMChipServiceRoom accessoryRoom) => throw new InvalidOperationException ();
public virtual void FetchRooms (HMChipServiceHome home, FetchRoomHandler completion) => throw new InvalidOperationException ();
public virtual Task<NSArray<HMChipServiceRoom>> FetchRoomsAsync (HMChipServiceHome home) => throw new InvalidOperationException ();
public virtual void PairAccessory (HMChipServiceHome home, string onboardingPayload, Action<NSError> completion) => throw new InvalidOperationException ();
public virtual Task PairAccessoryAsync (HMChipServiceHome home, string onboardingPayload) => throw new InvalidOperationException ();
public virtual void BeginRequestWithExtensionContext (NSExtensionContext context) => throw new InvalidOperationException (Constants.RemovedFromHomeKit);
public virtual void ConfigureAccessory (string accessoryName, HMChipServiceRoom accessoryRoom, Action<NSError> completion) => throw new InvalidOperationException (Constants.RemovedFromHomeKit);
public virtual Task ConfigureAccessoryAsync (string accessoryName, HMChipServiceRoom accessoryRoom) => throw new InvalidOperationException (Constants.RemovedFromHomeKit);
public virtual void FetchRooms (HMChipServiceHome home, FetchRoomHandler completion) => throw new InvalidOperationException (Constants.RemovedFromHomeKit);
public virtual Task<NSArray<HMChipServiceRoom>> FetchRoomsAsync (HMChipServiceHome home) => throw new InvalidOperationException (Constants.RemovedFromHomeKit);
public virtual void PairAccessory (HMChipServiceHome home, string onboardingPayload, Action<NSError> completion) => throw new InvalidOperationException (Constants.RemovedFromHomeKit);
public virtual Task PairAccessoryAsync (HMChipServiceHome home, string onboardingPayload) => throw new InvalidOperationException (Constants.RemovedFromHomeKit);

} /* class HMChipServiceRequestHandler */

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

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

protected HMChipServiceTopology (IntPtr handle) => throw new InvalidOperationException ();
public HMChipServiceTopology (NSCoder coder) => throw new InvalidOperationException ();
protected HMChipServiceTopology (NSObjectFlag t) => throw new InvalidOperationException ();
public HMChipServiceTopology (HMChipServiceHome[] homes) => throw new InvalidOperationException ();
protected HMChipServiceTopology (IntPtr handle) => throw new InvalidOperationException (Constants.RemovedFromHomeKit);
public HMChipServiceTopology (NSCoder coder) => throw new InvalidOperationException (Constants.RemovedFromHomeKit);
protected HMChipServiceTopology (NSObjectFlag t) => throw new InvalidOperationException (Constants.RemovedFromHomeKit);
public HMChipServiceTopology (HMChipServiceHome[] homes) => throw new InvalidOperationException (Constants.RemovedFromHomeKit);

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

} /* class HMChipServiceTopology */

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

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

protected HMChipServiceRoom (IntPtr handle) => throw new InvalidOperationException ();
public HMChipServiceRoom (NSCoder coder) => throw new InvalidOperationException ();
protected HMChipServiceRoom (NSObjectFlag t) => throw new InvalidOperationException ();
public HMChipServiceRoom (NSUuid uuid, string name) => throw new InvalidOperationException ();
protected HMChipServiceRoom (IntPtr handle) => throw new InvalidOperationException (Constants.RemovedFromHomeKit);
public HMChipServiceRoom (NSCoder coder) => throw new InvalidOperationException (Constants.RemovedFromHomeKit);
protected HMChipServiceRoom (NSObjectFlag t) => throw new InvalidOperationException (Constants.RemovedFromHomeKit);
public HMChipServiceRoom (NSUuid uuid, string name) => throw new InvalidOperationException (Constants.RemovedFromHomeKit);

public virtual NSObject Copy (NSZone? zone)=> throw new InvalidOperationException ();
public virtual void EncodeTo (NSCoder encoder) => throw new InvalidOperationException ();
public virtual string Name => throw new InvalidOperationException ();
public virtual NSUuid Uuid => throw new InvalidOperationException ();
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);

} /* class HMChipServiceRoom */

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

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

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

public HMChipServiceHome (NSUuid uuid, string name) => throw new InvalidOperationException ();
public virtual NSObject Copy (NSZone? zone) => throw new InvalidOperationException ();
public HMChipServiceHome (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 ();
public virtual string Name => throw new InvalidOperationException ();
public virtual NSUuid Uuid => throw new InvalidOperationException ();
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);

} /* class HMChipServiceHome */

[Obsolete ("This class is removed.")]
public partial class HMAccessorySetupManager {

#pragma warning disable CS0618 // HMChipServiceTopology and HMErrorHandler is obsolete
public virtual void AddAndSetUpAccessories (HMChipServiceTopology topology, HMErrorHandler completion) => throw new InvalidOperationException ();
public virtual Task AddAndSetUpAccessoriesAsync (HMChipServiceTopology topology) => throw new InvalidOperationException ();
public virtual void AddAndSetUpAccessories (HMChipServiceTopology topology, HMErrorHandler completion) => throw new InvalidOperationException (Constants.RemovedFromHomeKit);
public virtual Task AddAndSetUpAccessoriesAsync (HMChipServiceTopology topology) => throw new InvalidOperationException (Constants.RemovedFromHomeKit);
#pragma warning restore CS0618 // HMChipServiceTopology and HMErrorHandler is obsolete
}
#endif // !NET

} /* class HMAccessorySetupManager */

#if !XAMCORE_5_0
#if __IOS__ && !__MACCATALYST__
#if NET
[EditorBrowsable (EditorBrowsableState.Never)]
[Obsolete ("This class is removed.")]
#endif
public unsafe partial class HMAccessorySetupManager : NSObject {
Copy link
Member

Choose a reason for hiding this comment

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

Same: add Obsolete?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea - done.

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

public HMAccessorySetupManager () : base (NSObjectFlag.Empty) => throw new InvalidOperationException (Constants.RemovedFromHomeKit);
protected HMAccessorySetupManager (NSObjectFlag t) : base (t) => throw new InvalidOperationException (Constants.RemovedFromHomeKit);
protected internal HMAccessorySetupManager (NativeHandle handle) : base (handle) => throw new InvalidOperationException (Constants.RemovedFromHomeKit);

public virtual void AddAndSetUpAccessories (HMMatterTopology topology, Action<NSError> completion) => throw new InvalidOperationException (Constants.RemovedFromHomeKit);
public virtual Task AddAndSetUpAccessoriesAsync (HMMatterTopology topology) => throw new InvalidOperationException (Constants.RemovedFromHomeKit);
public virtual void PerformAccessorySetup (HMAccessorySetupRequest request, Action<HMAccessorySetupResult, NSError> completion) => throw new InvalidOperationException (Constants.RemovedFromHomeKit);
public virtual Task<HMAccessorySetupResult> PerformAccessorySetupAsync (HMAccessorySetupRequest request) => throw new InvalidOperationException (Constants.RemovedFromHomeKit);
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
#endif
}
#endif // !NET
3 changes: 3 additions & 0 deletions src/ObjCRuntime/ObsoleteConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ partial class Constants {
internal const string RemovedFromChip = "This API has been removed from the 'CHIP' framework.";

internal const string BrokenBinding = "This API was incorrectly bound and does not work correctly. Use the new version indicated in the associated Obsolete attribute.";

internal const string RemovedFromHomeKit = "This API has been removed from the 'HomeKit' framework.";

internal const string ApiRemovedGeneral = "This API has been removed from the framework.";
}
}
Loading