Skip to content

Commit e2575d4

Browse files
web-flowrolfbjarne
authored andcommitted
[Foundation] Fix nullability in NSConnection.
This is file 39 of 47 files with nullability disabled in Foundation. Changes: - Enabled nullability - Added proper XML documentation for all public members, replacing "To be added" placeholders - Added ArgumentNullException.ThrowIfNull checks for string and NSPortNameServer parameters - Added see cref attributes for better documentation cross-referencing - Added paramref attributes for parameter references in remarks - Fixed XML formatting and removed unnecessary whitespace - Documented the relationship between instance and static GetRootProxy methods Contributes towards #17285.
1 parent e96e769 commit e2575d4

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

src/Foundation/NSConnection.cs

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,41 +30,45 @@
3030

3131
using System.Diagnostics.CodeAnalysis;
3232

33-
// Disable until we get around to enable + fix any issues.
34-
#nullable disable
33+
#nullable enable
3534

3635
namespace Foundation {
3736
public partial class NSConnection {
3837

39-
/// <typeparam name="TProxy">To be added.</typeparam>
40-
/// <summary>To be added.</summary>
41-
/// <returns>To be added.</returns>
42-
/// <remarks>To be added.</remarks>
38+
/// <summary>Gets the root proxy object for this connection.</summary>
39+
/// <typeparam name="TProxy">The type of the proxy object to return.</typeparam>
40+
/// <returns>The root proxy object, cast to the specified type.</returns>
41+
/// <remarks>This method retrieves the root object provided by the receiver's peer. The returned object is a proxy that represents the root object on the remote side of the connection.</remarks>
4342
public TProxy GetRootProxy<TProxy> () where TProxy : NSObject
4443
{
4544
return GetRootProxy<TProxy> (_GetRootProxy ());
4645
}
4746

48-
/// <typeparam name="TProxy">To be added.</typeparam>
49-
/// <param name="name">To be added.</param>
50-
/// <param name="hostName">To be added.</param>
51-
/// <summary>To be added.</summary>
52-
/// <returns>To be added.</returns>
53-
/// <remarks>To be added.</remarks>
47+
/// <summary>Gets the root proxy object for the connection identified by name and host.</summary>
48+
/// <typeparam name="TProxy">The type of the proxy object to return.</typeparam>
49+
/// <param name="name">The name of the connection.</param>
50+
/// <param name="hostName">The name of the host on which the connection is registered.</param>
51+
/// <returns>The root proxy object for the specified connection, cast to the specified type.</returns>
52+
/// <remarks>This method retrieves the root object from a connection identified by <paramref name="name" /> on the specified <paramref name="hostName" />.</remarks>
5453
public static TProxy GetRootProxy<TProxy> (string name, string hostName) where TProxy : NSObject
5554
{
55+
ArgumentNullException.ThrowIfNull (name);
56+
ArgumentNullException.ThrowIfNull (hostName);
5657
return GetRootProxy<TProxy> (_GetRootProxy (name, hostName));
5758
}
5859

59-
/// <typeparam name="TProxy">To be added.</typeparam>
60-
/// <param name="name">To be added.</param>
61-
/// <param name="hostName">To be added.</param>
62-
/// <param name="server">To be added.</param>
63-
/// <summary>To be added.</summary>
64-
/// <returns>To be added.</returns>
65-
/// <remarks>To be added.</remarks>
60+
/// <summary>Gets the root proxy object for the connection identified by name, host, and port name server.</summary>
61+
/// <typeparam name="TProxy">The type of the proxy object to return.</typeparam>
62+
/// <param name="name">The name of the connection.</param>
63+
/// <param name="hostName">The name of the host on which the connection is registered.</param>
64+
/// <param name="server">The <see cref="NSPortNameServer" /> to use for looking up the connection.</param>
65+
/// <returns>The root proxy object for the specified connection, cast to the specified type.</returns>
66+
/// <remarks>This method retrieves the root object from a connection identified by <paramref name="name" /> on the specified <paramref name="hostName" /> using the given port name server.</remarks>
6667
public static TProxy GetRootProxy<TProxy> (string name, string hostName, NSPortNameServer server) where TProxy : NSObject
6768
{
69+
ArgumentNullException.ThrowIfNull (name);
70+
ArgumentNullException.ThrowIfNull (hostName);
71+
ArgumentNullException.ThrowIfNull (server);
6872
return GetRootProxy<TProxy> (_GetRootProxy (name, hostName, server));
6973
}
7074

@@ -73,7 +77,7 @@ public static TProxy GetRootProxy<TProxy> (string name, string hostName, NSPortN
7377
var result = Runtime.TryGetNSObject (handle) as TProxy;
7478

7579
if (result is null)
76-
result = (TProxy) Activator.CreateInstance (typeof (TProxy), new object [] { handle });
80+
result = (TProxy) Activator.CreateInstance (typeof (TProxy), new object [] { handle })!;
7781

7882
return result;
7983
}

0 commit comments

Comments
 (0)