Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 42 additions & 42 deletions src/UIKit/UIAppearance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
// Copyright 2011, 2015 Xamarin Inc
//

using System.Reflection;

// Disable until we get around to enable + fix any issues.
#nullable disable
#nullable enable
Comment thread
rolfbjarne marked this conversation as resolved.

namespace UIKit {
#if __TVOS__
Expand All @@ -21,27 +18,29 @@ namespace UIKit {
/// <include file="../../docs/api/UIKit/UIAppearance.xml" path="/Documentation/Docs[@DocId='T:UIKit.UIAppearance']/*" />
#endif
public partial class UIAppearance {
/// <param name="other">To be added.</param>
/// <summary>Whether this is equivalent to <paramref name="other" />.</summary>
/// <returns>To be added.</returns>
/// <remarks>To be added.</remarks>
public override bool Equals (object other)
/// <summary>Determines whether the specified object is equal to the current <see cref="UIAppearance" />.</summary>
/// <param name="other">The object to compare with the current instance.</param>
/// <returns><see langword="true" /> if <paramref name="other" /> is a <see cref="UIAppearance" /> and has the same <see cref="Foundation.NSObject.Handle" />; otherwise, <see langword="false" />.</returns>
public override bool Equals (object? other)
{
UIAppearance ao = other as UIAppearance;
var ao = other as UIAppearance;
if (ao is null)
return false;
return ao.Handle == Handle;
}

/// <summary>Generates a hash code for the current instance.</summary>
/// <returns>A int containing the hash code for this instance.</returns>
/// <remarks>The algorithm used to generate the hash code is unspecified.</remarks>
/// <returns>A hash code for the current instance.</returns>
public override int GetHashCode ()
{
return Handle.GetHashCode ();
}

public static bool operator == (UIAppearance a, UIAppearance b)
/// <summary>Determines whether two <see cref="UIAppearance" /> instances have the same native handle.</summary>
/// <param name="a">The first instance to compare.</param>
/// <param name="b">The second instance to compare.</param>
/// <returns><see langword="true" /> if both instances are <see langword="null" /> or have the same <see cref="Foundation.NSObject.Handle" />; otherwise, <see langword="false" />.</returns>
public static bool operator == (UIAppearance? a, UIAppearance? b)
{
if (ReferenceEquals (a, null))
return ReferenceEquals (b, null);
Expand All @@ -50,7 +49,11 @@ public override int GetHashCode ()
return a.Handle == b.Handle;
}

public static bool operator != (UIAppearance a, UIAppearance b)
/// <summary>Determines whether two <see cref="UIAppearance" /> instances have different native handles.</summary>
/// <param name="a">The first instance to compare.</param>
/// <param name="b">The second instance to compare.</param>
/// <returns><see langword="true" /> if the instances have different native handles or exactly one is <see langword="null" />; otherwise, <see langword="false" />.</returns>
public static bool operator != (UIAppearance? a, UIAppearance? b)
{
return !(a == b);
}
Expand All @@ -74,10 +77,12 @@ static IntPtr [] TypesToPointers (Type [] whenFoundIn)
}

#if TVOS
// new in iOS9 but the only option for tvOS
const string selAppearanceWhenContainedInInstancesOfClasses = "appearanceWhenContainedInInstancesOfClasses:";

// +(instancetype _Nonnull)appearanceWhenContainedInInstancesOfClasses:(NSArray<Class<UIAppearanceContainer>> * _Nonnull)containerTypes
/// <summary>Gets the appearance proxy for a class in the specified containment hierarchy.</summary>
/// <param name="class_ptr">The Objective-C class pointer for the type to get the appearance proxy for.</param>
/// <param name="whenFoundIn">The types representing the containment hierarchy in which the appearance should be applied.</param>
/// <returns>The appearance proxy for the specified class when found in the specified containment hierarchy.</returns>
public static IntPtr GetAppearance (IntPtr class_ptr, params Type [] whenFoundIn)
{
using (var array = NSArray.FromIntPtrs (TypesToPointers (whenFoundIn))) {
Expand All @@ -88,11 +93,14 @@ public static IntPtr GetAppearance (IntPtr class_ptr, params Type [] whenFoundIn

const string selAppearanceForTraitCollectionWhenContainedInInstancesOfClasses = "appearanceForTraitCollection:whenContainedInInstancesOfClasses:";

// new in iOS9 but the only option for tvOS
/// <summary>Gets the appearance proxy for a class with the specified trait collection in the specified containment hierarchy.</summary>
/// <param name="class_ptr">The Objective-C class pointer for the type to get the appearance proxy for.</param>
/// <param name="traits">The <see cref="UITraitCollection" /> for which to return the appearance proxy.</param>
/// <param name="whenFoundIn">The types representing the containment hierarchy in which the appearance should be applied.</param>
/// <returns>The appearance proxy for the specified class and traits when found in the specified containment hierarchy.</returns>
public static IntPtr GetAppearance (IntPtr class_ptr, UITraitCollection traits, params Type [] whenFoundIn)
{
if (traits is null)
throw new ArgumentNullException ("traits");
ArgumentNullException.ThrowIfNull (traits);

using (var array = NSArray.FromIntPtrs (TypesToPointers (whenFoundIn))) {
IntPtr result = Messaging.IntPtr_objc_msgSend_IntPtr_IntPtr (class_ptr,
Expand All @@ -106,11 +114,10 @@ public static IntPtr GetAppearance (IntPtr class_ptr, UITraitCollection traits,
const string selAppearanceWhenContainedIn = "appearanceWhenContainedIn:";
const string selAppearanceForTraitCollectionWhenContainedIn = "appearanceForTraitCollection:whenContainedIn:";

/// <param name="class_ptr">To be added.</param>
/// <param name="whenFoundIn">To be added.</param>
/// <summary>This object's appearance proxy in the specified containment hierarchy.</summary>
/// <returns>To be added.</returns>
/// <remarks>To be added.</remarks>
/// <summary>Gets the appearance proxy for a class in the specified containment hierarchy.</summary>
/// <param name="class_ptr">The Objective-C class pointer for the type to get the appearance proxy for.</param>
/// <param name="whenFoundIn">The types representing the containment hierarchy in which the appearance should be applied.</param>
/// <returns>The appearance proxy for the specified class when found in the specified containment hierarchy.</returns>
[BindingImpl (BindingImplOptions.Optimizable)]
public static IntPtr GetAppearance (IntPtr class_ptr, params Type [] whenFoundIn)
{
Comment thread
rolfbjarne marked this conversation as resolved.
Expand All @@ -127,17 +134,15 @@ public static IntPtr GetAppearance (IntPtr class_ptr, params Type [] whenFoundIn
ptrs);
}

/// <param name="class_ptr">To be added.</param>
/// <param name="traits">To be added.</param>
/// <param name="whenFoundIn">To be added.</param>
/// <summary>Returns an appearance proxy for the specified <paramref name="traits" /> when found in the <paramref name="whenFoundIn" /> containment hierarchy.</summary>
/// <returns>To be added.</returns>
/// <remarks>To be added.</remarks>
/// <summary>Gets the appearance proxy for a class with the specified trait collection in the specified containment hierarchy.</summary>
/// <param name="class_ptr">The Objective-C class pointer for the type to get the appearance proxy for.</param>
/// <param name="traits">The <see cref="UITraitCollection" /> for which to return the appearance proxy.</param>
/// <param name="whenFoundIn">The types representing the containment hierarchy in which the appearance should be applied.</param>
/// <returns>The appearance proxy for the specified class and traits when found in the specified containment hierarchy.</returns>
[BindingImpl (BindingImplOptions.Optimizable)]
public static IntPtr GetAppearance (IntPtr class_ptr, UITraitCollection traits, params Type [] whenFoundIn)
{
if (traits is null)
throw new ArgumentNullException ("traits");
ArgumentNullException.ThrowIfNull (traits);

var ptrs = TypesToPointers (whenFoundIn);
Comment thread
rolfbjarne marked this conversation as resolved.

Expand All @@ -154,22 +159,17 @@ public static IntPtr GetAppearance (IntPtr class_ptr, UITraitCollection traits,
GC.KeepAlive (traits);
return result;
}

[DllImport (Messaging.LIBOBJC_DYLIB, EntryPoint = "objc_msgSend")]
extern static IntPtr IntPtr_objc_msgSend_IntPtr_IntPtr_IntPtr_IntPtr_IntPtr_IntPtr_IntPtr_IntPtr_IntPtr_IntPtr_IntPtr (IntPtr receiver, IntPtr selector, IntPtr arg1, IntPtr arg2, IntPtr arg3, IntPtr arg4, System.IntPtr arg5, System.IntPtr arg6, System.IntPtr arg7, System.IntPtr arg8, System.IntPtr arg9, System.IntPtr arg10, System.IntPtr arg11);
#endif

const string selAppearanceForTraitCollection = "appearanceForTraitCollection:";

/// <param name="class_ptr">To be added.</param>
/// <param name="traits">To be added.</param>
/// <summary>Returns an appearance proxy for the specified <paramref name="traits" />.</summary>
/// <returns>To be added.</returns>
/// <remarks>To be added.</remarks>
/// <summary>Gets the appearance proxy for a class with the specified trait collection.</summary>
/// <param name="class_ptr">The Objective-C class pointer for the type to get the appearance proxy for.</param>
/// <param name="traits">The <see cref="UITraitCollection" /> for which to return the appearance proxy.</param>
/// <returns>The appearance proxy for the specified class and traits.</returns>
public static IntPtr GetAppearance (IntPtr class_ptr, UITraitCollection traits)
{
if (traits is null)
throw new ArgumentNullException ("traits");
ArgumentNullException.ThrowIfNull (traits);

IntPtr result = Messaging.IntPtr_objc_msgSend_IntPtr (class_ptr, Selector.GetHandle (UIAppearance.selAppearanceForTraitCollection), traits.Handle);
GC.KeepAlive (traits);
Expand Down
2 changes: 0 additions & 2 deletions tests/cecil-tests/Documentation.KnownFailures.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16947,8 +16947,6 @@ M:UIKit.UIAlertView.remove_Presented(System.EventHandler)
M:UIKit.UIAlertView.remove_WillDismiss(System.EventHandler{UIKit.UIButtonEventArgs})
M:UIKit.UIAlertView.remove_WillPresent(System.EventHandler)
M:UIKit.UIAlertView.UIAlertViewAppearance.#ctor(System.IntPtr)
M:UIKit.UIAppearance.op_Equality(UIKit.UIAppearance,UIKit.UIAppearance)
M:UIKit.UIAppearance.op_Inequality(UIKit.UIAppearance,UIKit.UIAppearance)
M:UIKit.UIApplication_DefaultApplication.GetDefaultStatus(UIKit.UIApplication,UIKit.UIApplicationCategory,Foundation.NSError@)
M:UIKit.UIApplication.AccessibilityActivate
M:UIKit.UIApplication.Dispose(System.Boolean)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
AppBundleSize: 3,611,965 bytes (3,527.3 KB = 3.4 MB)
AppBundleSize: 3,611,466 bytes (3,526.8 KB = 3.4 MB)
# The following list of files and their sizes is just informational / for review, and isn't used in the test:
_CodeSignature/CodeResources: 3,997 bytes (3.9 KB = 0.0 MB)
archived-expanded-entitlements.xcent: 384 bytes (0.4 KB = 0.0 MB)
Info.plist: 1,163 bytes (1.1 KB = 0.0 MB)
Microsoft.iOS.dll: 151,040 bytes (147.5 KB = 0.1 MB)
Info.plist: 1,160 bytes (1.1 KB = 0.0 MB)
Microsoft.iOS.dll: 150,528 bytes (147.0 KB = 0.1 MB)
PkgInfo: 8 bytes (0.0 KB = 0.0 MB)
runtimeconfig.bin: 1,405 bytes (1.4 KB = 0.0 MB)
SizeTestApp: 2,404,544 bytes (2,348.2 KB = 2.3 MB)
SizeTestApp.dll: 7,680 bytes (7.5 KB = 0.0 MB)
System.Private.CoreLib.aotdata.arm64: 41,296 bytes (40.3 KB = 0.0 MB)
System.Private.CoreLib.aotdata.arm64: 41,312 bytes (40.3 KB = 0.0 MB)
System.Private.CoreLib.dll: 987,136 bytes (964.0 KB = 0.9 MB)
System.Runtime.dll: 5,120 bytes (5.0 KB = 0.0 MB)
System.Runtime.InteropServices.dll: 8,192 bytes (8.0 KB = 0.0 MB)
4 changes: 2 additions & 2 deletions tests/dotnet/UnitTests/expected/iOS-MonoVM-size.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
AppBundleSize: 9,362,185 bytes (9,142.8 KB = 8.9 MB)
AppBundleSize: 9,362,182 bytes (9,142.8 KB = 8.9 MB)
# The following list of files and their sizes is just informational / for review, and isn't used in the test:
_CodeSignature/CodeResources: 5,229 bytes (5.1 KB = 0.0 MB)
aot-instances.aotdata.arm64: 827,592 bytes (808.2 KB = 0.8 MB)
archived-expanded-entitlements.xcent: 384 bytes (0.4 KB = 0.0 MB)
Info.plist: 1,163 bytes (1.1 KB = 0.0 MB)
Info.plist: 1,160 bytes (1.1 KB = 0.0 MB)
Microsoft.iOS.aotdata.arm64: 22,872 bytes (22.3 KB = 0.0 MB)
Microsoft.iOS.dll: 48,640 bytes (47.5 KB = 0.0 MB)
PkgInfo: 8 bytes (0.0 KB = 0.0 MB)
Expand Down
4 changes: 2 additions & 2 deletions tests/dotnet/UnitTests/expected/iOS-NativeAOT-size.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
AppBundleSize: 2,450,656 bytes (2,393.2 KB = 2.3 MB)
AppBundleSize: 2,450,653 bytes (2,393.2 KB = 2.3 MB)
# The following list of files and their sizes is just informational / for review, and isn't used in the test:
_CodeSignature/CodeResources: 2,589 bytes (2.5 KB = 0.0 MB)
archived-expanded-entitlements.xcent: 384 bytes (0.4 KB = 0.0 MB)
Info.plist: 1,163 bytes (1.1 KB = 0.0 MB)
Info.plist: 1,160 bytes (1.1 KB = 0.0 MB)
PkgInfo: 8 bytes (0.0 KB = 0.0 MB)
runtimeconfig.bin: 1,808 bytes (1.8 KB = 0.0 MB)
SizeTestApp: 2,444,704 bytes (2,387.4 KB = 2.3 MB)
Loading