Skip to content

Commit cbcd3f9

Browse files
Copilotrolfbjarne
authored andcommitted
[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 <c> for code references. Contributes towards #17285.
1 parent c098811 commit cbcd3f9

File tree

1 file changed

+32
-38
lines changed

1 file changed

+32
-38
lines changed

src/UIKit/UICollectionViewLayoutAttributes.cs

Lines changed: 32 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -12,62 +12,56 @@
1212
using System.Runtime.CompilerServices;
1313
using CoreGraphics;
1414

15-
// Disable until we get around to enable + fix any issues.
16-
#nullable disable
15+
#nullable enable
1716

1817
namespace UIKit {
1918
public partial class UICollectionViewLayoutAttributes : NSObject {
19+
/// <summary>Creates a layout attributes object of the specified type for the cell at the specified index path.</summary>
2020
/// <typeparam name="T">The type of the layout attributes object to return.</typeparam>
21-
/// <param name="indexPath">The index path describing the cell to create a layout attributes object for.</param>
22-
/// <summary>Creates a layout attributes object of the specified type for the cell at the specified index path.</summary>
23-
/// <returns>A layout attributes object representing the cell at the specified index path.</returns>
24-
/// <remarks>Use this method to create a layout attributes object of a UICollectionViewLayoutAttributes subclass.</remarks>
21+
/// <param name="indexPath">The index path describing the cell to create a layout attributes object for.</param>
22+
/// <returns>A layout attributes object representing the cell at the specified index path.</returns>
23+
/// <remarks>Use this method to create a layout attributes object of a <see cref="UICollectionViewLayoutAttributes" /> subclass.</remarks>
2524
[CompilerGenerated]
2625
public static T CreateForCell<T> (NSIndexPath indexPath) where T : UICollectionViewLayoutAttributes
2726
{
2827
global::UIKit.UIApplication.EnsureUIThread ();
29-
if (indexPath is null)
30-
throw new ArgumentNullException ("indexPath");
31-
T result = (T) Runtime.GetNSObject (ObjCRuntime.Messaging.IntPtr_objc_msgSend_IntPtr (Class.GetHandle (typeof (T)), Selector.GetHandle ("layoutAttributesForCellWithIndexPath:"), indexPath.Handle));
28+
ArgumentNullException.ThrowIfNull (indexPath);
29+
T result = (T) Runtime.GetNSObject (ObjCRuntime.Messaging.IntPtr_objc_msgSend_IntPtr (Class.GetHandle (typeof (T)), Selector.GetHandle ("layoutAttributesForCellWithIndexPath:"), indexPath.Handle))!;
3230
GC.KeepAlive (indexPath);
3331
return result;
3432
}
3533

34+
/// <summary>Creates a layout attributes object of a specific type representing the decoration view.</summary>
3635
/// <typeparam name="T">The type of the layout attributes object to return.</typeparam>
37-
/// <param name="kind">The kind identifier for the decoration view.</param>
38-
/// <param name="indexPath">An index path related to the decoration view.</param>
39-
/// <summary>Creates a layout attributes object of a specific type representing the decoration view.</summary>
40-
/// <returns>A layout attributes object of a specific type that represents the decoration view.</returns>
41-
/// <remarks>Use this method to create a layout attributes object of a specific type representing a decoration view of a specific kind.</remarks>
36+
/// <param name="kind">The kind identifier for the decoration view.</param>
37+
/// <param name="indexPath">An index path related to the decoration view.</param>
38+
/// <returns>A layout attributes object of a specific type that represents the decoration view.</returns>
39+
/// <remarks>Use this method to create a layout attributes object of a specific type representing a decoration view of a specific kind.</remarks>
4240
[CompilerGenerated]
4341
public static T CreateForDecorationView<T> (NSString kind, NSIndexPath indexPath) where T : UICollectionViewLayoutAttributes
4442
{
4543
global::UIKit.UIApplication.EnsureUIThread ();
46-
if (kind is null)
47-
throw new ArgumentNullException ("kind");
48-
if (indexPath is null)
49-
throw new ArgumentNullException ("indexPath");
50-
T result = (T) Runtime.GetNSObject (ObjCRuntime.Messaging.IntPtr_objc_msgSend_IntPtr_IntPtr (Class.GetHandle (typeof (T)), Selector.GetHandle ("layoutAttributesForDecorationViewOfKind:withIndexPath:"), kind.Handle, indexPath.Handle));
44+
ArgumentNullException.ThrowIfNull (kind);
45+
ArgumentNullException.ThrowIfNull (indexPath);
46+
T result = (T) Runtime.GetNSObject (ObjCRuntime.Messaging.IntPtr_objc_msgSend_IntPtr_IntPtr (Class.GetHandle (typeof (T)), Selector.GetHandle ("layoutAttributesForDecorationViewOfKind:withIndexPath:"), kind.Handle, indexPath.Handle))!;
5147
GC.KeepAlive (kind);
5248
GC.KeepAlive (indexPath);
5349
return result;
5450
}
5551

52+
/// <summary>Creates a layout attributes object of a specific type representing the supplementary view.</summary>
5653
/// <typeparam name="T">The type of the layout attributes object to return.</typeparam>
57-
/// <param name="kind">The kind identifier for the supplementary view.</param>
58-
/// <param name="indexPath">An index path for the supplementary view.</param>
59-
/// <summary>Creates a layout attributes object of a specific type representing the supplementary view.</summary>
60-
/// <returns>A layout attributes object of a specific type that represents the supplementary view.</returns>
61-
/// <remarks>Use this method to create a layout attributes object of a specific type representing a supplementary view of the specified.</remarks>
54+
/// <param name="kind">The kind identifier for the supplementary view.</param>
55+
/// <param name="indexPath">An index path for the supplementary view.</param>
56+
/// <returns>A layout attributes object of a specific type that represents the supplementary view.</returns>
57+
/// <remarks>Use this method to create a layout attributes object of a specific type representing a supplementary view of the specified kind.</remarks>
6258
[CompilerGenerated]
6359
public static T CreateForSupplementaryView<T> (NSString kind, NSIndexPath indexPath) where T : UICollectionViewLayoutAttributes
6460
{
6561
global::UIKit.UIApplication.EnsureUIThread ();
66-
if (kind is null)
67-
throw new ArgumentNullException ("kind");
68-
if (indexPath is null)
69-
throw new ArgumentNullException ("indexPath");
70-
T result = (T) Runtime.GetNSObject (ObjCRuntime.Messaging.IntPtr_objc_msgSend_IntPtr_IntPtr (Class.GetHandle (typeof (T)), Selector.GetHandle ("layoutAttributesForSupplementaryViewOfKind:withIndexPath:"), kind.Handle, indexPath.Handle));
62+
ArgumentNullException.ThrowIfNull (kind);
63+
ArgumentNullException.ThrowIfNull (indexPath);
64+
T result = (T) Runtime.GetNSObject (ObjCRuntime.Messaging.IntPtr_objc_msgSend_IntPtr_IntPtr (Class.GetHandle (typeof (T)), Selector.GetHandle ("layoutAttributesForSupplementaryViewOfKind:withIndexPath:"), kind.Handle, indexPath.Handle))!;
7165
GC.KeepAlive (kind);
7266
GC.KeepAlive (indexPath);
7367
return result;
@@ -85,22 +79,22 @@ static NSString GetKindForSection (UICollectionElementKindSection section)
8579
}
8680
}
8781

82+
/// <summary>Creates a layout attributes object representing the supplementary view.</summary>
8883
/// <param name="section">The supplementary view kind.</param>
89-
/// <param name="indexPath">An index path for the supplementary view.</param>
90-
/// <summary>Creates a layout attributes object representing the supplementary view.</summary>
91-
/// <returns>A layout attributes object that represents the supplementary view.</returns>
92-
/// <remarks>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 <see cref="UIKit.UICollectionViewLayoutAttributes.CreateForSupplementaryView(Foundation.NSString,Foundation.NSIndexPath)" /> instead. This method is equivalent to calling CreateForSupplementaryView&lt;UICollectionViewLayoutAttributes&gt;.</remarks>
84+
/// <param name="indexPath">An index path for the supplementary view.</param>
85+
/// <returns>A layout attributes object that represents the supplementary view.</returns>
86+
/// <remarks>Use this method to create a layout attributes object representing a supplementary view of a specific kind. If you've subclassed <see cref="UICollectionViewLayoutAttributes" /> and need to return an instance of the subclass, use <see cref="CreateForSupplementaryView{T}(NSString, NSIndexPath)" /> instead. This method is equivalent to calling <c>CreateForSupplementaryView&lt;UICollectionViewLayoutAttributes&gt;</c>.</remarks>
9387
public static UICollectionViewLayoutAttributes CreateForSupplementaryView (UICollectionElementKindSection section, NSIndexPath indexPath)
9488
{
9589
return CreateForSupplementaryView (GetKindForSection (section), indexPath);
9690
}
9791

92+
/// <summary>Creates a layout attributes object representing the supplementary view.</summary>
9893
/// <typeparam name="T">The type of the layout attributes object to return.</typeparam>
99-
/// <param name="section">The supplementary view kind.</param>
100-
/// <param name="indexPath">An index path for the supplementary view.</param>
101-
/// <summary>Creates a layout attributes object representing the supplementary view.</summary>
102-
/// <returns>A layout attributes object that represents the supplementary view.</returns>
103-
/// <remarks>Use this method to create a layout attributes object of a specific type representing a supplementary view of the specified.</remarks>
94+
/// <param name="section">The supplementary view kind.</param>
95+
/// <param name="indexPath">An index path for the supplementary view.</param>
96+
/// <returns>A layout attributes object that represents the supplementary view.</returns>
97+
/// <remarks>Use this method to create a layout attributes object of a specific type representing a supplementary view of the specified kind.</remarks>
10498
public static T CreateForSupplementaryView<T> (UICollectionElementKindSection section, NSIndexPath indexPath) where T : UICollectionViewLayoutAttributes
10599
{
106100
return CreateForSupplementaryView<T> (GetKindForSection (section), indexPath);

0 commit comments

Comments
 (0)