Skip to content

Commit 659532b

Browse files
BrennanConroyhalter73pranavkm
authored
API docs for SignalR (#26445)
* API docs for SignalR * Apply suggestions from code review Co-authored-by: Stephen Halter <[email protected]> Co-authored-by: Pranav K <[email protected]> Co-authored-by: Stephen Halter <[email protected]> Co-authored-by: Pranav K <[email protected]>
1 parent cd94cd6 commit 659532b

File tree

40 files changed

+354
-4
lines changed

40 files changed

+354
-4
lines changed

src/SignalR/clients/csharp/Client.Core/src/HubConnection.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,19 @@ namespace Microsoft.AspNetCore.SignalR.Client
3535
/// </remarks>
3636
public partial class HubConnection : IAsyncDisposable
3737
{
38+
/// <summary>
39+
/// The default timeout which specifies how long to wait for a message before closing the connection. Default is 30 seconds.
40+
/// </summary>
3841
public static readonly TimeSpan DefaultServerTimeout = TimeSpan.FromSeconds(30); // Server ping rate is 15 sec, this is 2 times that.
42+
43+
/// <summary>
44+
/// The default timeout which specifies how long to wait for the handshake to respond before closing the connection. Default is 15 seconds.
45+
/// </summary>
3946
public static readonly TimeSpan DefaultHandshakeTimeout = TimeSpan.FromSeconds(15);
47+
48+
/// <summary>
49+
/// The default interval that the client will send keep alive messages to let the server know to not close the connection. Default is 15 second interval.
50+
/// </summary>
4051
public static readonly TimeSpan DefaultKeepAliveInterval = TimeSpan.FromSeconds(15);
4152

4253
// This lock protects the connection state.

src/SignalR/clients/csharp/Client.Core/src/HubConnectionBuilder.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ public override string ToString()
8080
}
8181

8282
// Prevents from being displayed in intellisense
83+
/// <summary>
84+
/// Gets the <see cref="Type"/> of the current instance.
85+
/// </summary>
8386
[EditorBrowsable(EditorBrowsableState.Never)]
8487
public new Type GetType()
8588
{

src/SignalR/clients/csharp/Client.Core/src/Microsoft.AspNetCore.SignalR.Client.Core.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<Description>Client for ASP.NET Core SignalR</Description>
55
<TargetFrameworks>$(DefaultNetFxTargetFramework);netstandard2.0;netstandard2.1</TargetFrameworks>
66
<RootNamespace>Microsoft.AspNetCore.SignalR.Client</RootNamespace>
7+
<NoWarn>$(NoWarn.Replace('1591', ''))</NoWarn>
78
</PropertyGroup>
89

910
<ItemGroup>

src/SignalR/clients/csharp/Client/src/Microsoft.AspNetCore.SignalR.Client.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<Description>Client for ASP.NET Core SignalR</Description>
55
<TargetFrameworks>$(DefaultNetFxTargetFramework);netstandard2.0</TargetFrameworks>
6+
<NoWarn>$(NoWarn.Replace('1591', ''))</NoWarn>
67
</PropertyGroup>
78

89
<ItemGroup>

src/SignalR/clients/csharp/Http.Connections.Client/src/Microsoft.AspNetCore.Http.Connections.Client.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<Description>Client for ASP.NET Core Connection Handlers</Description>
55
<TargetFrameworks>$(DefaultNetFxTargetFramework);netstandard2.0;netstandard2.1</TargetFrameworks>
6+
<NoWarn>$(NoWarn.Replace('1591', ''))</NoWarn>
67
</PropertyGroup>
78

89
<ItemGroup>

src/SignalR/clients/csharp/Http.Connections.Client/src/NoTransportSupportedException.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ namespace Microsoft.AspNetCore.Http.Connections.Client
1010
/// </summary>
1111
public class NoTransportSupportedException : Exception
1212
{
13+
/// <summary>
14+
/// Constructs the <see cref="NoTransportSupportedException"/> exception with the provided <paramref name="message"/>.
15+
/// </summary>
16+
/// <param name="message">Message of the exception.</param>
1317
public NoTransportSupportedException(string message)
1418
: base(message)
1519
{

src/SignalR/clients/csharp/Http.Connections.Client/src/TransportFailedException.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,17 @@ namespace Microsoft.AspNetCore.Http.Connections.Client
1010
/// </summary>
1111
public class TransportFailedException : Exception
1212
{
13+
/// <summary>
14+
/// The name of the transport that failed to connect.
15+
/// </summary>
1316
public string TransportType { get; }
1417

18+
/// <summary>
19+
/// Constructs a <see cref="TransportFailedException"/>.
20+
/// </summary>
21+
/// <param name="transportType">The name of the transport that failed to connect.</param>
22+
/// <param name="message">The reason the transport failed.</param>
23+
/// <param name="innerException">An optional extra exception if one was thrown while trying to connect.</param>
1524
public TransportFailedException(string transportType, string message, Exception innerException = null)
1625
: base($"{transportType} failed: {message}", innerException)
1726
{

src/SignalR/common/Http.Connections.Common/src/AvailableTransport.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,19 @@
55

66
namespace Microsoft.AspNetCore.Http.Connections
77
{
8+
/// <summary>
9+
/// Part of the <see cref="NegotiationResponse"/> that represents an individual transport and the trasfer formats the transport supports.
10+
/// </summary>
811
public class AvailableTransport
912
{
13+
/// <summary>
14+
/// A transport available on the server.
15+
/// </summary>
1016
public string Transport { get; set; }
17+
18+
/// <summary>
19+
/// A list of formats supported by the transport. Examples include "Text" and "Binary".
20+
/// </summary>
1121
public IList<string> TransferFormats { get; set; }
1222
}
1323
}

src/SignalR/common/Http.Connections.Common/src/Microsoft.AspNetCore.Http.Connections.Common.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<IsAspNetCoreApp>true</IsAspNetCoreApp>
88
<RootNamespace>Microsoft.AspNetCore.Http.Connections</RootNamespace>
99
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
10+
<NoWarn>$(NoWarn.Replace('1591', ''))</NoWarn>
1011
</PropertyGroup>
1112

1213
<ItemGroup>

src/SignalR/common/Http.Connections.Common/src/NegotiateProtocol.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111

1212
namespace Microsoft.AspNetCore.Http.Connections
1313
{
14+
/// <summary>
15+
/// The protocol for reading and writing negotiate requests and responses.
16+
/// </summary>
1417
public static class NegotiateProtocol
1518
{
1619
private const string ConnectionIdPropertyName = "connectionId";
@@ -36,6 +39,11 @@ public static class NegotiateProtocol
3639
// Used to detect ASP.NET SignalR Server connection attempt
3740
private static ReadOnlySpan<byte> ProtocolVersionPropertyNameBytes => new byte[] { (byte)'P', (byte)'r', (byte)'o', (byte)'t', (byte)'o', (byte)'c', (byte)'o', (byte)'l', (byte)'V', (byte)'e', (byte)'r', (byte)'s', (byte)'i', (byte)'o', (byte)'n' };
3841

42+
/// <summary>
43+
/// Writes the <paramref name="response"/> to the <paramref name="output"/>.
44+
/// </summary>
45+
/// <param name="response">The negotiation response generated in response to a negotiation request.</param>
46+
/// <param name="output">Where the <paramref name="response"/> is written to as Json.</param>
3947
public static void WriteResponse(NegotiationResponse response, IBufferWriter<byte> output)
4048
{
4149
var reusableWriter = ReusableUtf8JsonWriter.Get(output);
@@ -124,6 +132,11 @@ public static void WriteResponse(NegotiationResponse response, IBufferWriter<byt
124132
}
125133
}
126134

135+
/// <summary>
136+
/// Parses a <see cref="NegotiationResponse"/> from the <paramref name="content"/> as Json.
137+
/// </summary>
138+
/// <param name="content">The bytes of a Json payload that represents a <see cref="NegotiationResponse"/>.</param>
139+
/// <returns>The parsed <see cref="NegotiationResponse"/>.</returns>
127140
public static NegotiationResponse ParseResponse(ReadOnlySpan<byte> content)
128141
{
129142
try

src/SignalR/common/Http.Connections.Common/src/NegotiationResponse.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,44 @@
55

66
namespace Microsoft.AspNetCore.Http.Connections
77
{
8+
/// <summary>
9+
/// A response to a '/negotiate' request.
10+
/// </summary>
811
public class NegotiationResponse
912
{
13+
/// <summary>
14+
/// An optional Url to redirect the client to another endpoint.
15+
/// </summary>
1016
public string Url { get; set; }
17+
18+
/// <summary>
19+
/// An optional access token to go along with the Url.
20+
/// </summary>
1121
public string AccessToken { get; set; }
22+
23+
/// <summary>
24+
/// The public ID for the connection.
25+
/// </summary>
1226
public string ConnectionId { get; set; }
27+
28+
/// <summary>
29+
/// The private ID for the connection.
30+
/// </summary>
1331
public string ConnectionToken { get; set; }
32+
33+
/// <summary>
34+
/// The minimum value between the version the client sends and the maximum version the server supports.
35+
/// </summary>
1436
public int Version { get; set; }
37+
38+
/// <summary>
39+
/// A list of transports the server supports.
40+
/// </summary>
1541
public IList<AvailableTransport> AvailableTransports { get; set; }
42+
43+
/// <summary>
44+
/// An optional error during the negotiate. If this is not null the other properties on the response can be ignored.
45+
/// </summary>
1646
public string Error { get; set; }
1747
}
1848
}

src/SignalR/common/Http.Connections/src/ConnectionEndpointRouteBuilderExtensions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111

1212
namespace Microsoft.AspNetCore.Builder
1313
{
14+
/// <summary>
15+
/// Extension methods on <see cref="IEndpointRouteBuilder"/> that add routes for <see cref="ConnectionHandler"/>s.
16+
/// </summary>
1417
public static class ConnectionEndpointRouteBuilderExtensions
1518
{
1619
/// <summary>

src/SignalR/common/Http.Connections/src/ConnectionOptions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55

66
namespace Microsoft.AspNetCore.Http.Connections
77
{
8+
/// <summary>
9+
/// Options used to change behavior of how connections are handled.
10+
/// </summary>
811
public class ConnectionOptions
912
{
1013
/// <summary>

src/SignalR/common/Http.Connections/src/ConnectionOptionsSetup.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,20 @@
66

77
namespace Microsoft.AspNetCore.Http.Connections
88
{
9+
/// <summary>
10+
/// Sets up <see cref="ConnectionOptions"/>.
11+
/// </summary>
912
public class ConnectionOptionsSetup : IConfigureOptions<ConnectionOptions>
1013
{
14+
/// <summary>
15+
/// Default timeout value for disconnecting idle connections.
16+
/// </summary>
1117
public static TimeSpan DefaultDisconectTimeout = TimeSpan.FromSeconds(15);
1218

19+
/// <summary>
20+
/// Sets default values for options if they have not been set yet.
21+
/// </summary>
22+
/// <param name="options">The <see cref="ConnectionOptions"/>.</param>
1323
public void Configure(ConnectionOptions options)
1424
{
1525
if (options.DisconnectTimeout == null)
Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,27 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
1+
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System;
55
using System.Collections.Generic;
66
using System.Text;
7+
using Microsoft.AspNetCore.Connections;
78
using Microsoft.AspNetCore.Http;
89

910
namespace Microsoft.AspNetCore.Http.Connections.Features
1011
{
12+
/// <summary>
13+
/// Feature set on the <see cref="ConnectionContext"/> that provides access to the underlying <see cref="Http.HttpContext"/>
14+
/// associated with the connection if there is one.
15+
/// </summary>
1116
public interface IHttpContextFeature
1217
{
18+
/// <summary>
19+
/// The <see cref="Http.HttpContext"/> associated with the connection if available.
20+
/// </summary>
21+
/// <remarks>
22+
/// Connections can run on top of HTTP transports like WebSockets or Long Polling, or other non-HTTP transports. As a result,
23+
/// this API can sometimes return <see langword="null"/> depending on the configuration of your application.
24+
/// </remarks>
1325
HttpContext HttpContext { get; set; }
1426
}
1527
}

src/SignalR/common/Http.Connections/src/Features/IHttpTransportFeature.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,20 @@
44
using System;
55
using System.Collections.Generic;
66
using System.Text;
7+
using Microsoft.AspNetCore.Connections;
78
using Microsoft.AspNetCore.Http;
89

910
namespace Microsoft.AspNetCore.Http.Connections.Features
1011
{
12+
/// <summary>
13+
/// Feature set on the <see cref="ConnectionContext"/> that exposes the <see cref="HttpTransportType"/>
14+
/// the connection is using.
15+
/// </summary>
1116
public interface IHttpTransportFeature
1217
{
18+
/// <summary>
19+
/// The <see cref="HttpTransportType"/> the connection is using.
20+
/// </summary>
1321
HttpTransportType TransportType { get; }
1422
}
1523
}

src/SignalR/common/Http.Connections/src/HttpConnectionContextExtensions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
namespace Microsoft.AspNetCore.Http.Connections
99
{
10+
/// <summary>
11+
/// Extension method to get the underlying <see cref="HttpContext"/> of the connection if there is one.
12+
/// </summary>
1013
public static class HttpConnectionContextExtensions
1114
{
1215
/// <summary>

src/SignalR/common/Http.Connections/src/Microsoft.AspNetCore.Http.Connections.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<IsAspNetCoreApp>true</IsAspNetCoreApp>
77
<IsPackable>false</IsPackable>
88
<Nullable>enable</Nullable>
9+
<NoWarn>$(NoWarn.Replace('1591', ''))</NoWarn>
910
</PropertyGroup>
1011

1112
<ItemGroup>

src/SignalR/common/Http.Connections/src/WebSocketOptions.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,15 @@
66

77
namespace Microsoft.AspNetCore.Http.Connections
88
{
9+
/// <summary>
10+
/// Options used by the WebSockets transport to modify the transports behavior.
11+
/// </summary>
912
public class WebSocketOptions
1013
{
14+
/// <summary>
15+
/// Gets or sets the amount of time the WebSocket transport will wait for a graceful close before starting an ungraceful close.
16+
/// </summary>
17+
/// <value>Defaults to 5 seconds</value>
1118
public TimeSpan CloseTimeout { get; set; } = TimeSpan.FromSeconds(5);
1219

1320
/// <summary>

src/SignalR/common/Protocols.Json/src/Microsoft.AspNetCore.SignalR.Protocols.Json.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<RootNamespace>Microsoft.AspNetCore.SignalR</RootNamespace>
99
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
1010
<Nullable>enable</Nullable>
11+
<NoWarn>$(NoWarn.Replace('1591', ''))</NoWarn>
1112
</PropertyGroup>
1213

1314
<ItemGroup>

src/SignalR/common/Protocols.MessagePack/src/MessagePackHubProtocolOptions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
namespace Microsoft.AspNetCore.SignalR
88
{
9+
/// <summary>
10+
/// The <see cref="MessagePackHubProtocol"/> options.
11+
/// </summary>
912
public class MessagePackHubProtocolOptions
1013
{
1114
private MessagePackSerializerOptions? _messagePackSerializerOptions;

src/SignalR/common/Protocols.MessagePack/src/Microsoft.AspNetCore.SignalR.Protocols.MessagePack.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<RootNamespace>Microsoft.AspNetCore.SignalR</RootNamespace>
77
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
88
<Nullable>enable</Nullable>
9+
<NoWarn>$(NoWarn.Replace('1591', ''))</NoWarn>
910
</PropertyGroup>
1011

1112
<ItemGroup>

src/SignalR/common/Protocols.NewtonsoftJson/src/Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<RootNamespace>Microsoft.AspNetCore.SignalR</RootNamespace>
77
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
88
<Nullable>enable</Nullable>
9+
<NoWarn>$(NoWarn.Replace('1591', ''))</NoWarn>
910
</PropertyGroup>
1011

1112
<ItemGroup>

src/SignalR/common/SignalR.Common/src/IInvocationBinder.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,34 @@
33

44
using System;
55
using System.Collections.Generic;
6+
using Microsoft.AspNetCore.SignalR.Protocol;
67

78
namespace Microsoft.AspNetCore.SignalR
89
{
10+
/// <summary>
11+
/// Class used by <see cref="IHubProtocol"/>s to get the <see cref="Type"/>(s) expected by the hub message being deserialized.
12+
/// </summary>
913
public interface IInvocationBinder
1014
{
15+
/// <summary>
16+
/// Gets the <see cref="Type"/> the invocation represented by the <paramref name="invocationId"/> is expected to contain.
17+
/// </summary>
18+
/// <param name="invocationId">The ID of the invocation being received.</param>
19+
/// <returns>The <see cref="Type"/> the invocation is expected to contain.</returns>
1120
Type GetReturnType(string invocationId);
21+
22+
/// <summary>
23+
/// Gets the list of <see cref="Type"/>s the method represented by <paramref name="methodName"/> takes as arguments.
24+
/// </summary>
25+
/// <param name="methodName">The name of the method being called.</param>
26+
/// <returns>A list of <see cref="Type"/>s the method takes as arguments.</returns>
1227
IReadOnlyList<Type> GetParameterTypes(string methodName);
28+
29+
/// <summary>
30+
/// Gets the <see cref="Type"/> the stream item is expected to contain.
31+
/// </summary>
32+
/// <param name="streamId">The ID of the stream the stream item is a part of.</param>
33+
/// <returns>The <see cref="Type"/> of the item the stream contains.</returns>
1334
Type GetStreamItemType(string streamId);
1435
}
1536
}

src/SignalR/common/SignalR.Common/src/Microsoft.AspNetCore.SignalR.Common.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<RootNamespace>Microsoft.AspNetCore.SignalR</RootNamespace>
99
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
1010
<Nullable>enable</Nullable>
11+
<NoWarn>$(NoWarn.Replace('1591', ''))</NoWarn>
1112
</PropertyGroup>
1213

1314
<ItemGroup>

0 commit comments

Comments
 (0)