Skip to content

Commit cd94cd6

Browse files
Add documentation for Routing surface area (#26513)
* Add documentation for Routing surface area * Apply suggestions from code review Co-authored-by: James Newton-King <james@newtonking.com> * Fix up some doc strings Co-authored-by: James Newton-King <james@newtonking.com>
1 parent 63baa06 commit cd94cd6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+515
-32
lines changed

src/Http/Http.Abstractions/src/StatusCodes.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
namespace Microsoft.AspNetCore.Http
55
{
66
/// <summary>
7-
/// A collection of contants for HTTP status codes.
7+
/// A collection of constants for HTTP status codes.
88
///
99
/// Status Codes listed at http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
1010
/// </summary>

src/Http/Routing.Abstractions/src/IRouteHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace Microsoft.AspNetCore.Routing
77
{
88
/// <summary>
9-
/// Defines a contract for a handler of a route.
9+
/// Defines a contract for a handler of a route.
1010
/// </summary>
1111
public interface IRouteHandler
1212
{

src/Http/Routing.Abstractions/src/IRouter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace Microsoft.AspNetCore.Routing
77
{
88
/// <summary>
9-
///
9+
/// Interface for implementing a router.
1010
/// </summary>
1111
public interface IRouter
1212
{

src/Http/Routing/perf/Matching/MatcherBuilderMultipleEntryBenchmark.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,4 +205,4 @@ public int Compare(Endpoint x, Endpoint y)
205205
}
206206
}
207207
}
208-
}
208+
}

src/Http/Routing/src/Builder/EndpointRoutingApplicationBuilderExtensions.cs

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

1010
namespace Microsoft.AspNetCore.Builder
1111
{
12+
/// <summary>
13+
/// Constains extensions for configuring routing on an <see cref="IApplicationBuilder"/>.
14+
/// </summary>
1215
public static class EndpointRoutingApplicationBuilderExtensions
1316
{
1417
private const string EndpointRouteBuilder = "__EndpointRouteBuilder";

src/Http/Routing/src/CompositeEndpointDataSource.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ internal CompositeEndpointDataSource(ObservableCollection<EndpointDataSource> da
4040
_dataSources = dataSources;
4141
}
4242

43+
/// <summary>
44+
/// Instantiates a <see cref="CompositeEndpointDataSource"/> object from <paramref name="endpointDataSources"/>.
45+
/// </summary>
46+
/// <param name="endpointDataSources">An collection of <see cref="EndpointDataSource" /> objects.</param>
47+
/// <returns>A <see cref="CompositeEndpointDataSource"/> </returns>
4348
public CompositeEndpointDataSource(IEnumerable<EndpointDataSource> endpointDataSources) : this()
4449
{
4550
_dataSources = new List<EndpointDataSource>();
@@ -62,6 +67,9 @@ private void OnDataSourcesChanged(object? sender, NotifyCollectionChangedEventAr
6267
}
6368
}
6469

70+
/// <summary>
71+
/// Returns the collection of <see cref="EndpointDataSource"/> instances associated with the object.
72+
/// </summary>
6573
public IEnumerable<EndpointDataSource> DataSources => _dataSources;
6674

6775
/// <summary>
@@ -123,12 +131,12 @@ private void HandleChange()
123131
// Refresh the endpoints from datasource so that callbacks can get the latest endpoints
124132
_endpoints = _dataSources.SelectMany(d => d.Endpoints).ToArray();
125133

126-
// Prevent consumers from re-registering callback to inflight events as that can
134+
// Prevent consumers from re-registering callback to inflight events as that can
127135
// cause a stackoverflow
128136
// Example:
129137
// 1. B registers A
130138
// 2. A fires event causing B's callback to get called
131-
// 3. B executes some code in its callback, but needs to re-register callback
139+
// 3. B executes some code in its callback, but needs to re-register callback
132140
// in the same callback
133141
var oldTokenSource = _cts;
134142
var oldToken = _consumerChangeToken;

src/Http/Routing/src/Constraints/OptionalRouteConstraint.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@
77
namespace Microsoft.AspNetCore.Routing.Constraints
88
{
99
/// <summary>
10-
/// Defines a constraint on an optional parameter. If the parameter is present, then it is constrained by InnerConstraint.
10+
/// Defines a constraint on an optional parameter. If the parameter is present, then it is constrained by InnerConstraint.
1111
/// </summary>
1212
public class OptionalRouteConstraint : IRouteConstraint
1313
{
14+
/// <summary>
15+
/// Creates a new <see cref="OptionalRouteConstraint"/> instance given the <paramref name="innerConstraint"/>.
16+
/// </summary>
17+
/// <param name="innerConstraint"></param>
1418
public OptionalRouteConstraint(IRouteConstraint innerConstraint)
1519
{
1620
if (innerConstraint == null)
@@ -21,8 +25,12 @@ public OptionalRouteConstraint(IRouteConstraint innerConstraint)
2125
InnerConstraint = innerConstraint;
2226
}
2327

28+
/// <summary>
29+
/// Gets the <see cref="IRouteConstraint"/> associated with the optional parameter.
30+
/// </summary>
2431
public IRouteConstraint InnerConstraint { get; }
2532

33+
/// <inheritdoc />
2634
public bool Match(
2735
HttpContext? httpContext,
2836
IRouter? route,

src/Http/Routing/src/Constraints/RegexRouteConstraint.cs

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

99
namespace Microsoft.AspNetCore.Routing.Constraints
1010
{
11+
/// <summary>
12+
/// Constrains a route parameter to match a regular expression.
13+
/// </summary>
1114
public class RegexRouteConstraint : IRouteConstraint
1215
{
1316
private static readonly TimeSpan RegexMatchTimeout = TimeSpan.FromSeconds(10);
1417

18+
/// <summary>
19+
/// Constructor for a <see cref="RegexRouteConstraint"/> given a <paramref name="regex"/>.
20+
/// </summary>
21+
/// <param name="regex">A <see cref="Regex"/> instance to use as a constraint.</param>
1522
public RegexRouteConstraint(Regex regex)
1623
{
1724
if (regex == null)
@@ -22,6 +29,10 @@ public RegexRouteConstraint(Regex regex)
2229
Constraint = regex;
2330
}
2431

32+
/// <summary>
33+
/// Constructor for a <see cref="RegexRouteConstraint"/> given a <paramref name="regexPattern"/>.
34+
/// </summary>
35+
/// <param name="regexPattern">A string containing the regex pattern.</param>
2536
public RegexRouteConstraint(string regexPattern)
2637
{
2738
if (regexPattern == null)
@@ -35,8 +46,12 @@ public RegexRouteConstraint(string regexPattern)
3546
RegexMatchTimeout);
3647
}
3748

49+
/// <summary>
50+
/// Gets the regular expression used in the route constraint.
51+
/// </summary>
3852
public Regex Constraint { get; private set; }
3953

54+
/// <inheritdoc />
4055
public bool Match(
4156
HttpContext? httpContext,
4257
IRouter? route,

src/Http/Routing/src/DataTokensMetadata.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ namespace Microsoft.AspNetCore.Routing
1414
/// </summary>
1515
public sealed class DataTokensMetadata : IDataTokensMetadata
1616
{
17+
/// <summary>
18+
/// Constructor for a new <see cref="DataTokensMetadata"/> given <paramref name="dataTokens"/>.
19+
/// </summary>
20+
/// <param name="dataTokens">The data tokens.</param>
1721
public DataTokensMetadata(IReadOnlyDictionary<string, object> dataTokens)
1822
{
1923
if (dataTokens == null)

src/Http/Routing/src/INamedRouter.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,14 @@
33

44
namespace Microsoft.AspNetCore.Routing
55
{
6+
/// <summary>
7+
/// An interface for an <see cref="IRouter"/> with a name.
8+
/// </summary>
69
public interface INamedRouter : IRouter
710
{
11+
/// <summary>
12+
/// The name of the router. Can be null.
13+
/// </summary>
814
string? Name { get; }
915
}
1016
}

0 commit comments

Comments
 (0)