From cbcd3f93b94b98b8e88aba730e460de703d69735 Mon Sep 17 00:00:00 2001 From: Copilot Date: Mon, 2 Feb 2026 11:37:23 +0100 Subject: [PATCH] [UIKit] Enable nullability and clean up UICollectionViewLayoutAttributes. * Enable nullability (#nullable enable). * Use ArgumentNullException.ThrowIfNull() instead of manual null checks. * Improve XML documentation comments: fix formatting (remove extra whitespace), fix order (summary first, then typeparam, param, returns, remarks), add 'see cref' references, fix incomplete sentences, use for code references. Contributes towards https://github.com/dotnet/macios/issues/17285. --- src/UIKit/UICollectionViewLayoutAttributes.cs | 70 +++++++++---------- 1 file changed, 32 insertions(+), 38 deletions(-) diff --git a/src/UIKit/UICollectionViewLayoutAttributes.cs b/src/UIKit/UICollectionViewLayoutAttributes.cs index 2a0ef9865ce9..9b76048e4e35 100644 --- a/src/UIKit/UICollectionViewLayoutAttributes.cs +++ b/src/UIKit/UICollectionViewLayoutAttributes.cs @@ -12,62 +12,56 @@ using System.Runtime.CompilerServices; using CoreGraphics; -// Disable until we get around to enable + fix any issues. -#nullable disable +#nullable enable namespace UIKit { public partial class UICollectionViewLayoutAttributes : NSObject { + /// Creates a layout attributes object of the specified type for the cell at the specified index path. /// The type of the layout attributes object to return. - /// The index path describing the cell to create a layout attributes object for. - /// Creates a layout attributes object of the specified type for the cell at the specified index path. - /// A layout attributes object representing the cell at the specified index path. - /// Use this method to create a layout attributes object of a UICollectionViewLayoutAttributes subclass. + /// The index path describing the cell to create a layout attributes object for. + /// A layout attributes object representing the cell at the specified index path. + /// Use this method to create a layout attributes object of a subclass. [CompilerGenerated] public static T CreateForCell (NSIndexPath indexPath) where T : UICollectionViewLayoutAttributes { global::UIKit.UIApplication.EnsureUIThread (); - if (indexPath is null) - throw new ArgumentNullException ("indexPath"); - T result = (T) Runtime.GetNSObject (ObjCRuntime.Messaging.IntPtr_objc_msgSend_IntPtr (Class.GetHandle (typeof (T)), Selector.GetHandle ("layoutAttributesForCellWithIndexPath:"), indexPath.Handle)); + ArgumentNullException.ThrowIfNull (indexPath); + T result = (T) Runtime.GetNSObject (ObjCRuntime.Messaging.IntPtr_objc_msgSend_IntPtr (Class.GetHandle (typeof (T)), Selector.GetHandle ("layoutAttributesForCellWithIndexPath:"), indexPath.Handle))!; GC.KeepAlive (indexPath); return result; } + /// Creates a layout attributes object of a specific type representing the decoration view. /// The type of the layout attributes object to return. - /// The kind identifier for the decoration view. - /// An index path related to the decoration view. - /// Creates a layout attributes object of a specific type representing the decoration view. - /// A layout attributes object of a specific type that represents the decoration view. - /// Use this method to create a layout attributes object of a specific type representing a decoration view of a specific kind. + /// The kind identifier for the decoration view. + /// An index path related to the decoration view. + /// A layout attributes object of a specific type that represents the decoration view. + /// Use this method to create a layout attributes object of a specific type representing a decoration view of a specific kind. [CompilerGenerated] public static T CreateForDecorationView (NSString kind, NSIndexPath indexPath) where T : UICollectionViewLayoutAttributes { global::UIKit.UIApplication.EnsureUIThread (); - if (kind is null) - throw new ArgumentNullException ("kind"); - if (indexPath is null) - throw new ArgumentNullException ("indexPath"); - T result = (T) Runtime.GetNSObject (ObjCRuntime.Messaging.IntPtr_objc_msgSend_IntPtr_IntPtr (Class.GetHandle (typeof (T)), Selector.GetHandle ("layoutAttributesForDecorationViewOfKind:withIndexPath:"), kind.Handle, indexPath.Handle)); + ArgumentNullException.ThrowIfNull (kind); + ArgumentNullException.ThrowIfNull (indexPath); + T result = (T) Runtime.GetNSObject (ObjCRuntime.Messaging.IntPtr_objc_msgSend_IntPtr_IntPtr (Class.GetHandle (typeof (T)), Selector.GetHandle ("layoutAttributesForDecorationViewOfKind:withIndexPath:"), kind.Handle, indexPath.Handle))!; GC.KeepAlive (kind); GC.KeepAlive (indexPath); return result; } + /// Creates a layout attributes object of a specific type representing the supplementary view. /// The type of the layout attributes object to return. - /// The kind identifier for the supplementary view. - /// An index path for the supplementary view. - /// Creates a layout attributes object of a specific type representing the supplementary view. - /// A layout attributes object of a specific type that represents the supplementary view. - /// Use this method to create a layout attributes object of a specific type representing a supplementary view of the specified. + /// The kind identifier for the supplementary view. + /// An index path for the supplementary view. + /// A layout attributes object of a specific type that represents the supplementary view. + /// Use this method to create a layout attributes object of a specific type representing a supplementary view of the specified kind. [CompilerGenerated] public static T CreateForSupplementaryView (NSString kind, NSIndexPath indexPath) where T : UICollectionViewLayoutAttributes { global::UIKit.UIApplication.EnsureUIThread (); - if (kind is null) - throw new ArgumentNullException ("kind"); - if (indexPath is null) - throw new ArgumentNullException ("indexPath"); - T result = (T) Runtime.GetNSObject (ObjCRuntime.Messaging.IntPtr_objc_msgSend_IntPtr_IntPtr (Class.GetHandle (typeof (T)), Selector.GetHandle ("layoutAttributesForSupplementaryViewOfKind:withIndexPath:"), kind.Handle, indexPath.Handle)); + ArgumentNullException.ThrowIfNull (kind); + ArgumentNullException.ThrowIfNull (indexPath); + T result = (T) Runtime.GetNSObject (ObjCRuntime.Messaging.IntPtr_objc_msgSend_IntPtr_IntPtr (Class.GetHandle (typeof (T)), Selector.GetHandle ("layoutAttributesForSupplementaryViewOfKind:withIndexPath:"), kind.Handle, indexPath.Handle))!; GC.KeepAlive (kind); GC.KeepAlive (indexPath); return result; @@ -85,22 +79,22 @@ static NSString GetKindForSection (UICollectionElementKindSection section) } } + /// Creates a layout attributes object representing the supplementary view. /// The supplementary view kind. - /// An index path for the supplementary view. - /// Creates a layout attributes object representing the supplementary view. - /// A layout attributes object that represents the supplementary view. - /// Use this method to create a layout attributes object representing a supplementary view of a specific kind. If you've subclassed UICollectionViewLayoutAttributes and need to return an instance of the subclass, use instead. This method is equivalent to calling CreateForSupplementaryView<UICollectionViewLayoutAttributes>. + /// An index path for the supplementary view. + /// A layout attributes object that represents the supplementary view. + /// Use this method to create a layout attributes object representing a supplementary view of a specific kind. If you've subclassed and need to return an instance of the subclass, use instead. This method is equivalent to calling CreateForSupplementaryView<UICollectionViewLayoutAttributes>. public static UICollectionViewLayoutAttributes CreateForSupplementaryView (UICollectionElementKindSection section, NSIndexPath indexPath) { return CreateForSupplementaryView (GetKindForSection (section), indexPath); } + /// Creates a layout attributes object representing the supplementary view. /// The type of the layout attributes object to return. - /// The supplementary view kind. - /// An index path for the supplementary view. - /// Creates a layout attributes object representing the supplementary view. - /// A layout attributes object that represents the supplementary view. - /// Use this method to create a layout attributes object of a specific type representing a supplementary view of the specified. + /// The supplementary view kind. + /// An index path for the supplementary view. + /// A layout attributes object that represents the supplementary view. + /// Use this method to create a layout attributes object of a specific type representing a supplementary view of the specified kind. public static T CreateForSupplementaryView (UICollectionElementKindSection section, NSIndexPath indexPath) where T : UICollectionViewLayoutAttributes { return CreateForSupplementaryView (GetKindForSection (section), indexPath);