-
Notifications
You must be signed in to change notification settings - Fork 515
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[UIKit] Inline the UITraitChangeObservable protocol into the classes …
…that implement it. Fixes #20265. (#21676) This also required fixing: * A bug in the static registrar where we'd ignore the generic parameters in a method when looking for methods implementing an interface. * A bug in the generator where we'd throw You_Should_Not_Call_base_In_This_Method() in some cases where we shouldn't. Also: * Enable nullability and fix any resulting issues. * Clean up some legacy code we don't need anymore. Ref: #19410 (comment) Fixes #20265. --------- Co-authored-by: GitHub Actions Autoformatter <[email protected]>
- Loading branch information
1 parent
3fcb5b3
commit 2a6e75b
Showing
9 changed files
with
770 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
using Foundation; | ||
using ObjCRuntime; | ||
|
||
#nullable enable | ||
|
||
namespace UIKit { | ||
public partial class UIPresentationController { | ||
#region Inlined from the UITraitChangeObservable protocol | ||
/// <summary> | ||
/// Registers a callback handler that will be executed when one of the specified traits changes. | ||
/// </summary> | ||
/// <param name="traits">The traits to observe.</param> | ||
/// <param name="handler">The callback to execute when any of the specified traits changes.</param> | ||
/// <returns>A token that can be used to unregister the callback by calling <see cref="M:UnregisterForTraitChanges" />.</returns> | ||
public IUITraitChangeRegistration RegisterForTraitChanges (Type [] traits, Action<IUITraitEnvironment, UITraitCollection> handler) | ||
{ | ||
return IUITraitChangeObservable._RegisterForTraitChanges (this, traits, handler); | ||
} | ||
|
||
/// <summary> | ||
/// Registers a callback handler that will be executed when one of the specified traits changes. | ||
/// </summary> | ||
/// <param name="traits">The traits to observe.</param> | ||
/// <param name="handler">The callback to execute when any of the specified traits changes.</param> | ||
/// <returns>A token that can be used to unregister the callback by calling <see cref="M:UnregisterForTraitChanges" />.</returns> | ||
public unsafe IUITraitChangeRegistration RegisterForTraitChanges (Action<IUITraitEnvironment, UITraitCollection> handler, params Type [] traits) | ||
{ | ||
// Add an override with 'params', unfortunately this means reordering the parameters. | ||
return IUITraitChangeObservable._RegisterForTraitChanges (this, handler, traits); | ||
} | ||
|
||
/// <summary> | ||
/// Registers a callback handler that will be executed when the specified trait changes. | ||
/// </summary> | ||
/// <typeparam name="T">The trait to observe.</typeparam> | ||
/// <param name="handler">The callback to execute when any of the specified traits changes.</param> | ||
/// <returns>A token that can be used to unregister the callback by calling <see cref="M:UnregisterForTraitChanges" />.</returns> | ||
public unsafe IUITraitChangeRegistration RegisterForTraitChanges<T> (Action<IUITraitEnvironment, UITraitCollection> handler) | ||
where T : IUITraitDefinition | ||
{ | ||
return IUITraitChangeObservable._RegisterForTraitChanges<T> (this, handler); | ||
} | ||
|
||
/// <summary> | ||
/// Registers a callback handler that will be executed when any of the specified traits changes. | ||
/// </summary> | ||
/// <typeparam name="T1">A trait to observe</typeparam> | ||
/// <typeparam name="T2">A trait to observe</typeparam> | ||
/// <param name="handler">The callback to execute when any of the specified traits changes.</param> | ||
/// <returns>A token that can be used to unregister the callback by calling <see cref="M:UnregisterForTraitChanges" />.</returns> | ||
public unsafe IUITraitChangeRegistration RegisterForTraitChanges<T1, T2> (Action<IUITraitEnvironment, UITraitCollection> handler) | ||
where T1 : IUITraitDefinition | ||
where T2 : IUITraitDefinition | ||
{ | ||
return IUITraitChangeObservable._RegisterForTraitChanges<T1, T2> (this, handler); | ||
} | ||
|
||
/// <summary> | ||
/// Registers a callback handler that will be executed when any of the specified traits changes. | ||
/// </summary> | ||
/// <typeparam name="T1">A trait to observe</typeparam> | ||
/// <typeparam name="T2">A trait to observe</typeparam> | ||
/// <typeparam name="T3">A trait to observe</typeparam> | ||
/// <param name="handler">The callback to execute when any of the specified traits changes.</param> | ||
/// <returns>A token that can be used to unregister the callback by calling <see cref="M:UnregisterForTraitChanges" />.</returns> | ||
public unsafe IUITraitChangeRegistration RegisterForTraitChanges<T1, T2, T3> (Action<IUITraitEnvironment, UITraitCollection> handler) | ||
where T1 : IUITraitDefinition | ||
where T2 : IUITraitDefinition | ||
where T3 : IUITraitDefinition | ||
{ | ||
return IUITraitChangeObservable._RegisterForTraitChanges<T1, T2, T3> (this, handler); | ||
} | ||
|
||
/// <summary> | ||
/// Registers a callback handler that will be executed when any of the specified traits changes. | ||
/// </summary> | ||
/// <typeparam name="T1">A trait to observe</typeparam> | ||
/// <typeparam name="T2">A trait to observe</typeparam> | ||
/// <typeparam name="T3">A trait to observe</typeparam> | ||
/// <typeparam name="T4">A trait to observe</typeparam> | ||
/// <param name="handler">The callback to execute when any of the specified traits changes.</param> | ||
/// <returns>A token that can be used to unregister the callback by calling <see cref="M:UnregisterForTraitChanges" />.</returns> | ||
public unsafe IUITraitChangeRegistration RegisterForTraitChanges<T1, T2, T3, T4> (Action<IUITraitEnvironment, UITraitCollection> handler) | ||
where T1 : IUITraitDefinition | ||
where T2 : IUITraitDefinition | ||
where T3 : IUITraitDefinition | ||
where T4 : IUITraitDefinition | ||
{ | ||
return IUITraitChangeObservable._RegisterForTraitChanges<T1, T2, T3, T4> (this, handler); | ||
} | ||
|
||
/// <summary> | ||
/// Registers a selector that will be called on the specified object when any of the specified traits changes. | ||
/// </summary> | ||
/// <param name="traits">The traits to observe.</param> | ||
/// <param name="target">The object whose specified selector will be called.</param> | ||
/// <param name="action">The selector to call on the specified object.</param> | ||
/// <returns>A token that can be used to unregister the callback by calling <see cref="M:UnregisterForTraitChanges" />.</returns> | ||
public IUITraitChangeRegistration RegisterForTraitChanges (Type [] traits, NSObject target, Selector action) | ||
{ | ||
return IUITraitChangeObservable._RegisterForTraitChanges (this, traits, target, action); | ||
} | ||
|
||
/// <summary> | ||
/// Registers a selector that will be called on the current object when any of the specified traits changes. | ||
/// </summary> | ||
/// <param name="traits">The traits to observe.</param> | ||
/// <param name="action">The selector to call on the current object.</param> | ||
/// <returns>A token that can be used to unregister the callback by calling <see cref="M:UnregisterForTraitChanges" />.</returns> | ||
public IUITraitChangeRegistration RegisterForTraitChanges (Type [] traits, Selector action) | ||
{ | ||
return IUITraitChangeObservable._RegisterForTraitChanges (this, traits, action); | ||
} | ||
#endregion | ||
} | ||
} |
Oops, something went wrong.
This comment was marked as outdated.
Sorry, something went wrong.
This comment was marked as outdated.
Sorry, something went wrong.
This comment was marked as outdated.
Sorry, something went wrong.
This comment was marked as outdated.
Sorry, something went wrong.
This comment was marked as outdated.
Sorry, something went wrong.
This comment was marked as outdated.
Sorry, something went wrong.