Skip to content

Commit e2b1b20

Browse files
Add doc strings for public APIs in Http.Abstractions and Routing.Abstractions (#26468)
* Add doc strings to Http.Abstractions and Routing.Abstractions * Address feedback from peer review * Update src/Http/Http.Abstractions/src/ConnectionInfo.cs Co-authored-by: James Newton-King <[email protected]> Co-authored-by: James Newton-King <[email protected]>
1 parent a218c3b commit e2b1b20

15 files changed

+456
-24
lines changed

src/Http/Http.Abstractions/src/ConnectionInfo.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,45 @@
88

99
namespace Microsoft.AspNetCore.Http
1010
{
11+
/// <summary>
12+
/// Represents the underlying connection for a request.
13+
/// </summary>
1114
public abstract class ConnectionInfo
1215
{
1316
/// <summary>
1417
/// Gets or sets a unique identifier to represent this connection.
1518
/// </summary>
1619
public abstract string Id { get; set; }
1720

21+
/// <summary>
22+
/// Gets or sets the IP address of the remote target. Can be null.
23+
/// </summary>
1824
public abstract IPAddress? RemoteIpAddress { get; set; }
1925

26+
/// <summary>
27+
/// Gets or sets the port of the remote target.
28+
/// </summary>
2029
public abstract int RemotePort { get; set; }
2130

31+
/// <summary>
32+
/// Gets or sets the IP address of the local host.
33+
/// </summary>
2234
public abstract IPAddress? LocalIpAddress { get; set; }
2335

36+
/// <summary>
37+
/// Gets or sets the port of the local host.
38+
/// </summary>
2439
public abstract int LocalPort { get; set; }
2540

41+
/// <summary>
42+
/// Gets or sets the client certificate.
43+
/// </summary>
2644
public abstract X509Certificate2? ClientCertificate { get; set; }
2745

46+
/// <summary>
47+
/// Retrieves the client certificate.
48+
/// </summary>
49+
/// <returns>Asynchronously returns an <see cref="X509Certificate2" />. Can be null.</returns>
2850
public abstract Task<X509Certificate2?> GetClientCertificateAsync(CancellationToken cancellationToken = new CancellationToken());
2951
}
3052
}

src/Http/Http.Abstractions/src/Extensions/HeaderDictionaryExtensions.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
77
{
8+
/// <summary>
9+
/// Contains extension methods for modifying an <see cref="IHeaderDictionary"/> instance.
10+
/// </summary>
811
public static class HeaderDictionaryExtensions
912
{
1013
/// <summary>

src/Http/Http.Abstractions/src/Extensions/ResponseTrailerExtensions.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

99
namespace Microsoft.AspNetCore.Http
1010
{
11+
/// <summary>
12+
/// Contains extension methods for modifying the `Trailer` response header
13+
/// and trailing headers in an <see cref="HttpResponse" />.
14+
/// </summary>
1115
public static class ResponseTrailerExtensions
1216
{
1317
/// <summary>

src/Http/Http.Abstractions/src/FragmentString.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ public static FragmentString FromUriComponent(Uri uri)
105105
return new FragmentString(fragmentValue);
106106
}
107107

108+
/// <summary>
109+
/// Evaluates if the current fragment is equal to another fragment <paramref name="other"/>.
110+
/// </summary>
111+
/// <param name="other">A <see cref="FragmentString" /> to compare.</param>
112+
/// <returns><see langword="true" /> if the fragments are equal.</returns>
108113
public bool Equals(FragmentString other)
109114
{
110115
if (!HasValue && !other.HasValue)
@@ -114,6 +119,11 @@ public bool Equals(FragmentString other)
114119
return string.Equals(_value, other._value, StringComparison.Ordinal);
115120
}
116121

122+
/// <summary>
123+
/// Evaluates if the current fragment is equal to an object <paramref name="obj"/>.
124+
/// </summary>
125+
/// <param name="obj">An object to compare.</param>
126+
/// <returns><see langword="true" /> if the fragments are equal.</returns>
117127
public override bool Equals(object? obj)
118128
{
119129
if (ReferenceEquals(null, obj))
@@ -123,16 +133,32 @@ public override bool Equals(object? obj)
123133
return obj is FragmentString && Equals((FragmentString)obj);
124134
}
125135

136+
/// <summary>
137+
/// Gets a hash code for the value.
138+
/// </summary>
139+
/// <returns>The hash code as an <see cref="int"/>.</returns>
126140
public override int GetHashCode()
127141
{
128142
return (HasValue ? _value.GetHashCode() : 0);
129143
}
130144

145+
/// <summary>
146+
/// Evaluates if one fragment is equal to another.
147+
/// </summary>
148+
/// <param name="left">A <see cref="FragmentString"/> instance.</param>
149+
/// <param name="right">A <see cref="FragmentString"/> instance.</param>
150+
/// <returns><see langword="true" /> if the fragments are equal.</returns>
131151
public static bool operator ==(FragmentString left, FragmentString right)
132152
{
133153
return left.Equals(right);
134154
}
135155

156+
/// <summary>
157+
/// Evalutes if one framgent is not equal to another.
158+
/// </summary>
159+
/// <param name="left">A <see cref="FragmentString"/> instance.</param>
160+
/// <param name="right">A <see cref="FragmentString"/> instance.</param>
161+
/// <returns><see langword="true" /> if the fragments are not equal.</returns>
136162
public static bool operator !=(FragmentString left, FragmentString right)
137163
{
138164
return !left.Equals(right);

src/Http/Http.Abstractions/src/HostString.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ public string Value
6565
get { return _value; }
6666
}
6767

68+
/// <summary>
69+
/// Returns true if the host is set.
70+
/// </summary>
6871
public bool HasValue
6972
{
7073
get { return !string.IsNullOrEmpty(_value); }

src/Http/Http.Abstractions/src/HttpMethods.cs

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace Microsoft.AspNetCore.Http
77
{
88
/// <summary>
9-
/// Contains methods to verify the request method of an HTTP request.
9+
/// Contains methods to verify the request method of an HTTP request.
1010
/// </summary>
1111
public static class HttpMethods
1212
{
@@ -18,18 +18,45 @@ public static class HttpMethods
1818
// and allow us to optimize comparisons when these constants are used.
1919

2020
// Please do NOT change these to 'const'
21+
/// <summary>
22+
/// HTTP "CONNECT" method.
23+
/// </summary>
2124
public static readonly string Connect = "CONNECT";
25+
/// <summary>
26+
/// HTTP "DELETE" method.
27+
/// </summary>
2228
public static readonly string Delete = "DELETE";
29+
/// <summary>
30+
/// HTTP "GET" method.
31+
/// </summary>
2332
public static readonly string Get = "GET";
33+
/// <summary>
34+
/// HTTP "HEAD" method.
35+
/// </summary>
2436
public static readonly string Head = "HEAD";
37+
/// <summary>
38+
/// HTTP "OPTIONS" method.
39+
/// </summary>
2540
public static readonly string Options = "OPTIONS";
41+
/// <summary>
42+
/// HTTP "PATCH" method.
43+
/// </summary>
2644
public static readonly string Patch = "PATCH";
45+
/// <summary>
46+
/// HTTP "POST" method.
47+
/// </summary>
2748
public static readonly string Post = "POST";
49+
/// <summary>
50+
/// HTTP "PUT" method.
51+
/// </summary>
2852
public static readonly string Put = "PUT";
53+
/// <summary>
54+
/// HTTP "TRACE" method.
55+
/// </summary>
2956
public static readonly string Trace = "TRACE";
3057

3158
/// <summary>
32-
/// Returns a value that indicates if the HTTP request method is CONNECT.
59+
/// Returns a value that indicates if the HTTP request method is CONNECT.
3360
/// </summary>
3461
/// <param name="method">The HTTP request method.</param>
3562
/// <returns>
@@ -41,7 +68,7 @@ public static bool IsConnect(string method)
4168
}
4269

4370
/// <summary>
44-
/// Returns a value that indicates if the HTTP request method is DELETE.
71+
/// Returns a value that indicates if the HTTP request method is DELETE.
4572
/// </summary>
4673
/// <param name="method">The HTTP request method.</param>
4774
/// <returns>
@@ -53,7 +80,7 @@ public static bool IsDelete(string method)
5380
}
5481

5582
/// <summary>
56-
/// Returns a value that indicates if the HTTP request method is GET.
83+
/// Returns a value that indicates if the HTTP request method is GET.
5784
/// </summary>
5885
/// <param name="method">The HTTP request method.</param>
5986
/// <returns>
@@ -65,7 +92,7 @@ public static bool IsGet(string method)
6592
}
6693

6794
/// <summary>
68-
/// Returns a value that indicates if the HTTP request method is HEAD.
95+
/// Returns a value that indicates if the HTTP request method is HEAD.
6996
/// </summary>
7097
/// <param name="method">The HTTP request method.</param>
7198
/// <returns>
@@ -77,7 +104,7 @@ public static bool IsHead(string method)
77104
}
78105

79106
/// <summary>
80-
/// Returns a value that indicates if the HTTP request method is OPTIONS.
107+
/// Returns a value that indicates if the HTTP request method is OPTIONS.
81108
/// </summary>
82109
/// <param name="method">The HTTP request method.</param>
83110
/// <returns>
@@ -89,7 +116,7 @@ public static bool IsOptions(string method)
89116
}
90117

91118
/// <summary>
92-
/// Returns a value that indicates if the HTTP request method is PATCH.
119+
/// Returns a value that indicates if the HTTP request method is PATCH.
93120
/// </summary>
94121
/// <param name="method">The HTTP request method.</param>
95122
/// <returns>
@@ -101,7 +128,7 @@ public static bool IsPatch(string method)
101128
}
102129

103130
/// <summary>
104-
/// Returns a value that indicates if the HTTP request method is POST.
131+
/// Returns a value that indicates if the HTTP request method is POST.
105132
/// </summary>
106133
/// <param name="method">The HTTP request method.</param>
107134
/// <returns>
@@ -113,7 +140,7 @@ public static bool IsPost(string method)
113140
}
114141

115142
/// <summary>
116-
/// Returns a value that indicates if the HTTP request method is PUT.
143+
/// Returns a value that indicates if the HTTP request method is PUT.
117144
/// </summary>
118145
/// <param name="method">The HTTP request method.</param>
119146
/// <returns>
@@ -125,7 +152,7 @@ public static bool IsPut(string method)
125152
}
126153

127154
/// <summary>
128-
/// Returns a value that indicates if the HTTP request method is TRACE.
155+
/// Returns a value that indicates if the HTTP request method is TRACE.
129156
/// </summary>
130157
/// <param name="method">The HTTP request method.</param>
131158
/// <returns>
@@ -156,7 +183,7 @@ string _ when IsConnect(method) => Connect,
156183
};
157184

158185
/// <summary>
159-
/// Returns a value that indicates if the HTTP methods are the same.
186+
/// Returns a value that indicates if the HTTP methods are the same.
160187
/// </summary>
161188
/// <param name="methodA">The first HTTP request method to compare.</param>
162189
/// <param name="methodB">The second HTTP request method to compare.</param>

src/Http/Http.Abstractions/src/HttpProtocol.cs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace Microsoft.AspNetCore.Http
77
{
88
/// <summary>
9-
/// Contains methods to verify the request protocol version of an HTTP request.
9+
/// Contains methods to verify the request protocol version of an HTTP request.
1010
/// </summary>
1111
public static class HttpProtocol
1212
{
@@ -18,13 +18,26 @@ public static class HttpProtocol
1818
// and allow us to optimize comparisons when these constants are used.
1919

2020
// Please do NOT change these to 'const'
21+
22+
/// <summary>
23+
/// HTTP protocol version 1.0.
24+
/// </summary>
2125
public static readonly string Http10 = "HTTP/1.0";
26+
/// <summary>
27+
/// HTTP protocol version 1.1.
28+
/// </summary>
2229
public static readonly string Http11 = "HTTP/1.1";
30+
/// <summary>
31+
/// HTTP protocol version 2.
32+
/// </summary>
2333
public static readonly string Http2 = "HTTP/2";
34+
/// <summary>
35+
/// HTTP protcol version 3.
36+
/// </summary>
2437
public static readonly string Http3 = "HTTP/3";
2538

2639
/// <summary>
27-
/// Returns a value that indicates if the HTTP request protocol is HTTP/1.0.
40+
/// Returns a value that indicates if the HTTP request protocol is HTTP/1.0.
2841
/// </summary>
2942
/// <param name="protocol">The HTTP request protocol.</param>
3043
/// <returns>
@@ -36,7 +49,7 @@ public static bool IsHttp10(string protocol)
3649
}
3750

3851
/// <summary>
39-
/// Returns a value that indicates if the HTTP request protocol is HTTP/1.1.
52+
/// Returns a value that indicates if the HTTP request protocol is HTTP/1.1.
4053
/// </summary>
4154
/// <param name="protocol">The HTTP request protocol.</param>
4255
/// <returns>
@@ -48,7 +61,7 @@ public static bool IsHttp11(string protocol)
4861
}
4962

5063
/// <summary>
51-
/// Returns a value that indicates if the HTTP request protocol is HTTP/2.
64+
/// Returns a value that indicates if the HTTP request protocol is HTTP/2.
5265
/// </summary>
5366
/// <param name="protocol">The HTTP request protocol.</param>
5467
/// <returns>
@@ -60,7 +73,7 @@ public static bool IsHttp2(string protocol)
6073
}
6174

6275
/// <summary>
63-
/// Returns a value that indicates if the HTTP request protocol is HTTP/3.
76+
/// Returns a value that indicates if the HTTP request protocol is HTTP/3.
6477
/// </summary>
6578
/// <param name="protocol">The HTTP request protocol.</param>
6679
/// <returns>

src/Http/Http.Abstractions/src/Microsoft.AspNetCore.Http.Abstractions.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Microsoft.AspNetCore.Http.HttpResponse</Description>
1212
<IsAspNetCoreApp>true</IsAspNetCoreApp>
1313
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1414
<PackageTags>aspnetcore</PackageTags>
15-
<NoWarn>$(NoWarn);CS1591</NoWarn>
15+
<NoWarn>$(NoWarn.Replace('1591', ''))</NoWarn>
1616
<IsPackable>false</IsPackable>
1717
<Nullable>enable</Nullable>
1818
</PropertyGroup>

0 commit comments

Comments
 (0)