Skip to content

Commit d1f3b90

Browse files
authored
RouteValuesAddressMetadata ctors and XML docs (#818)
1 parent 3044cc8 commit d1f3b90

17 files changed

+86
-36
lines changed

src/Microsoft.AspNetCore.Routing.Abstractions/EndpointMetadataCollection.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public sealed class EndpointMetadataCollection : IReadOnlyList<object>
2929
private readonly ConcurrentDictionary<Type, object[]> _cache;
3030

3131
/// <summary>
32-
/// Creates a new <see cref="EndpointMetadataCollection"/>.
32+
/// Creates a new instance of <see cref="EndpointMetadataCollection"/>.
3333
/// </summary>
3434
/// <param name="items">The metadata items.</param>
3535
public EndpointMetadataCollection(IEnumerable<object> items)
@@ -44,7 +44,7 @@ public EndpointMetadataCollection(IEnumerable<object> items)
4444
}
4545

4646
/// <summary>
47-
/// Creates a new <see cref="EndpointMetadataCollection"/>.
47+
/// Creates a new instance of <see cref="EndpointMetadataCollection"/>.
4848
/// </summary>
4949
/// <param name="items">The metadata items.</param>
5050
public EndpointMetadataCollection(params object[] items)

src/Microsoft.AspNetCore.Routing.Abstractions/RouteContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class RouteContext
1414
private RouteData _routeData;
1515

1616
/// <summary>
17-
/// Creates a new <see cref="RouteContext"/> for the provided <paramref name="httpContext"/>.
17+
/// Creates a new instance of <see cref="RouteContext"/> for the provided <paramref name="httpContext"/>.
1818
/// </summary>
1919
/// <param name="httpContext">The <see cref="Http.HttpContext"/> associated with the current request.</param>
2020
public RouteContext(HttpContext httpContext)

src/Microsoft.AspNetCore.Routing.Abstractions/RouteData.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ public class RouteData
1616
private RouteValueDictionary _values;
1717

1818
/// <summary>
19-
/// Creates a new <see cref="RouteData"/> instance.
19+
/// Creates a new instance of <see cref="RouteData"/> instance.
2020
/// </summary>
2121
public RouteData()
2222
{
2323
// Perf: Avoid allocating collections unless needed.
2424
}
2525

2626
/// <summary>
27-
/// Creates a new <see cref="RouteData"/> instance with values copied from <paramref name="other"/>.
27+
/// Creates a new instance of <see cref="RouteData"/> instance with values copied from <paramref name="other"/>.
2828
/// </summary>
2929
/// <param name="other">The other <see cref="RouteData"/> instance to copy.</param>
3030
public RouteData(RouteData other)
@@ -52,7 +52,7 @@ public RouteData(RouteData other)
5252
}
5353

5454
/// <summary>
55-
/// Creates a new <see cref="RouteData"/> instance with the specified values.
55+
/// Creates a new instance of <see cref="RouteData"/> instance with the specified values.
5656
/// </summary>
5757
/// <param name="values">The <see cref="RouteValueDictionary"/> values.</param>
5858
public RouteData(RouteValueDictionary values)
@@ -197,7 +197,7 @@ public struct RouteDataSnapshot
197197
private readonly RouteValueDictionary _values;
198198

199199
/// <summary>
200-
/// Creates a new <see cref="RouteDataSnapshot"/> for <paramref name="routeData"/>.
200+
/// Creates a new instance of <see cref="RouteDataSnapshot"/> for <paramref name="routeData"/>.
201201
/// </summary>
202202
/// <param name="routeData">The <see cref="RouteData"/>.</param>
203203
/// <param name="dataTokens">The data tokens.</param>

src/Microsoft.AspNetCore.Routing.Abstractions/RouteValueDictionary.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class RouteValueDictionary : IDictionary<string, object>, IReadOnlyDictio
2525
private int _count;
2626

2727
/// <summary>
28-
/// Creates a new <see cref="RouteValueDictionary"/> from the provided array.
28+
/// Creates a new instance of <see cref="RouteValueDictionary"/> from the provided array.
2929
/// The new instance will take ownership of the array, and may mutate it.
3030
/// </summary>
3131
/// <param name="items">The items array.</param>

src/Microsoft.AspNetCore.Routing.Abstractions/VirtualPathContext.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace Microsoft.AspNetCore.Routing
1111
public class VirtualPathContext
1212
{
1313
/// <summary>
14-
/// Creates a new <see cref="VirtualPathContext"/>.
14+
/// Creates a new instance of <see cref="VirtualPathContext"/>.
1515
/// </summary>
1616
/// <param name="httpContext">The <see cref="Http.HttpContext"/> associated with the current request.</param>
1717
/// <param name="ambientValues">The set of route values associated with the current request.</param>
@@ -25,7 +25,7 @@ public VirtualPathContext(
2525
}
2626

2727
/// <summary>
28-
/// Creates a new <see cref="VirtualPathContext"/>.
28+
/// Creates a new instance of <see cref="VirtualPathContext"/>.
2929
/// </summary>
3030
/// <param name="httpContext">The <see cref="Http.HttpContext"/> associated with the current request.</param>
3131
/// <param name="ambientValues">The set of route values associated with the current request.</param>

src/Microsoft.AspNetCore.Routing/Constraints/HttpMethodRouteConstraint.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace Microsoft.AspNetCore.Routing.Constraints
1414
public class HttpMethodRouteConstraint : IRouteConstraint
1515
{
1616
/// <summary>
17-
/// Creates a new <see cref="HttpMethodRouteConstraint"/> that accepts the HTTP methods specified
17+
/// Creates a new instance of <see cref="HttpMethodRouteConstraint"/> that accepts the HTTP methods specified
1818
/// by <paramref name="allowedMethods"/>.
1919
/// </summary>
2020
/// <param name="allowedMethods">The allowed HTTP methods.</param>

src/Microsoft.AspNetCore.Routing/EndpointNameMetadata.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace Microsoft.AspNetCore.Routing
1616
public class EndpointNameMetadata : IEndpointNameMetadata
1717
{
1818
/// <summary>
19-
/// Creates a new <see cref="EndpointNameMetadata"/> with the provided endpoint name.
19+
/// Creates a new instance of <see cref="EndpointNameMetadata"/> with the provided endpoint name.
2020
/// </summary>
2121
/// <param name="endpointName">The endpoint name.</param>
2222
public EndpointNameMetadata(string endpointName)

src/Microsoft.AspNetCore.Routing/IRouteValuesAddressMetadata.cs

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

66
namespace Microsoft.AspNetCore.Routing
77
{
8+
/// <summary>
9+
/// Represents metadata used during link generation to find
10+
/// the associated endpoint using route values.
11+
/// </summary>
812
public interface IRouteValuesAddressMetadata
913
{
14+
/// <summary>
15+
/// Gets the route name. Can be null.
16+
/// </summary>
1017
string RouteName { get; }
18+
19+
/// <summary>
20+
/// Gets the required route values.
21+
/// </summary>
1122
IReadOnlyDictionary<string, object> RequiredValues { get; }
1223
}
1324
}

src/Microsoft.AspNetCore.Routing/Patterns/RoutePatternException.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ private RoutePatternException(SerializationInfo info, StreamingContext context)
1919
}
2020

2121
/// <summary>
22-
/// Creates a new <see cref="RoutePatternException"/>.
22+
/// Creates a new instance of <see cref="RoutePatternException"/>.
2323
/// </summary>
2424
/// <param name="pattern">The route pattern as raw text.</param>
2525
/// <param name="message">The exception message.</param>

src/Microsoft.AspNetCore.Routing/Patterns/RoutePatternFactory.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public static RoutePattern Parse(string pattern, object defaults, object paramet
6767
}
6868

6969
/// <summary>
70-
/// Creates a new <see cref="RoutePattern"/> from a collection of segments.
70+
/// Creates a new instance of <see cref="RoutePattern"/> from a collection of segments.
7171
/// </summary>
7272
/// <param name="segments">The collection of segments.</param>
7373
/// <returns>The <see cref="RoutePattern"/>.</returns>
@@ -82,7 +82,7 @@ public static RoutePattern Pattern(IEnumerable<RoutePatternPathSegment> segments
8282
}
8383

8484
/// <summary>
85-
/// Creates a new <see cref="RoutePattern"/> from a collection of segments.
85+
/// Creates a new instance of <see cref="RoutePattern"/> from a collection of segments.
8686
/// </summary>
8787
/// <param name="rawText">The raw text to associate with the route pattern. May be null.</param>
8888
/// <param name="segments">The collection of segments.</param>
@@ -158,7 +158,7 @@ public static RoutePattern Pattern(
158158
}
159159

160160
/// <summary>
161-
/// Creates a new <see cref="RoutePattern"/> from a collection of segments.
161+
/// Creates a new instance of <see cref="RoutePattern"/> from a collection of segments.
162162
/// </summary>
163163
/// <param name="segments">The collection of segments.</param>
164164
/// <returns>The <see cref="RoutePattern"/>.</returns>
@@ -173,7 +173,7 @@ public static RoutePattern Pattern(params RoutePatternPathSegment[] segments)
173173
}
174174

175175
/// <summary>
176-
/// Creates a new <see cref="RoutePattern"/> from a collection of segments.
176+
/// Creates a new instance of <see cref="RoutePattern"/> from a collection of segments.
177177
/// </summary>
178178
/// <param name="rawText">The raw text to associate with the route pattern. May be null.</param>
179179
/// <param name="segments">The collection of segments.</param>

src/Microsoft.AspNetCore.Routing/RouteConstraintBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class RouteConstraintBuilder
2323
private readonly Dictionary<string, List<IRouteConstraint>> _constraints;
2424
private readonly HashSet<string> _optionalParameters;
2525
/// <summary>
26-
/// Creates a new <see cref="RouteConstraintBuilder"/> instance.
26+
/// Creates a new instance of <see cref="RouteConstraintBuilder"/> instance.
2727
/// </summary>
2828
/// <param name="inlineConstraintResolver">The <see cref="IInlineConstraintResolver"/>.</param>
2929
/// <param name="displayName">The display name (for use in error messages).</param>

src/Microsoft.AspNetCore.Routing/RouteValuesAddressMetadata.cs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,61 @@
33

44
using System;
55
using System.Collections.Generic;
6+
using System.Collections.ObjectModel;
67
using System.Diagnostics;
78
using System.Linq;
89

910
namespace Microsoft.AspNetCore.Routing
1011
{
12+
/// <summary>
13+
/// Metadata used during link generation to find the associated endpoint using route values.
14+
/// </summary>
1115
[DebuggerDisplay("{DebuggerToString(),nq}")]
1216
public sealed class RouteValuesAddressMetadata : IRouteValuesAddressMetadata
1317
{
18+
private static readonly IReadOnlyDictionary<string, object> EmptyRouteValues =
19+
new ReadOnlyDictionary<string, object>(new Dictionary<string, object>());
20+
21+
/// <summary>
22+
/// Creates a new instance of <see cref="RouteValuesAddressMetadata"/> with the provided route name.
23+
/// </summary>
24+
/// <param name="routeName">The route name. Can be null.</param>
25+
public RouteValuesAddressMetadata(string routeName) : this(routeName, EmptyRouteValues)
26+
{
27+
}
28+
29+
/// <summary>
30+
/// Creates a new instance of <see cref="RouteValuesAddressMetadata"/> with the provided required route values.
31+
/// </summary>
32+
/// <param name="requiredValues">The required route values.</param>
33+
public RouteValuesAddressMetadata(IReadOnlyDictionary<string, object> requiredValues) : this(null, requiredValues)
34+
{
35+
}
36+
37+
/// <summary>
38+
/// Creates a new instance of <see cref="RouteValuesAddressMetadata"/> with the provided route name and required route values.
39+
/// </summary>
40+
/// <param name="routeName">The route name. Can be null.</param>
41+
/// <param name="requiredValues">The required route values.</param>
1442
public RouteValuesAddressMetadata(string routeName, IReadOnlyDictionary<string, object> requiredValues)
1543
{
44+
if (requiredValues == null)
45+
{
46+
throw new ArgumentNullException(nameof(requiredValues));
47+
}
48+
1649
RouteName = routeName;
1750
RequiredValues = requiredValues;
1851
}
1952

53+
/// <summary>
54+
/// Gets the route name. Can be null.
55+
/// </summary>
2056
public string RouteName { get; }
2157

58+
/// <summary>
59+
/// Gets the required route values.
60+
/// </summary>
2261
public IReadOnlyDictionary<string, object> RequiredValues { get; }
2362

2463
internal string DebuggerToString()

src/Microsoft.AspNetCore.Routing/Template/InlineConstraint.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace Microsoft.AspNetCore.Routing.Template
1212
public class InlineConstraint
1313
{
1414
/// <summary>
15-
/// Creates a new <see cref="InlineConstraint"/>.
15+
/// Creates a new instance of <see cref="InlineConstraint"/>.
1616
/// </summary>
1717
/// <param name="constraint">The constraint text.</param>
1818
public InlineConstraint(string constraint)

src/Microsoft.AspNetCore.Routing/Tree/TreeRouter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class TreeRouter : IRouter
3030
private readonly ILogger _constraintLogger;
3131

3232
/// <summary>
33-
/// Creates a new <see cref="TreeRouter"/>.
33+
/// Creates a new instance of <see cref="TreeRouter"/>.
3434
/// </summary>
3535
/// <param name="trees">The list of <see cref="UrlMatchingTree"/> that contains the route entries.</param>
3636
/// <param name="linkGenerationEntries">The set of <see cref="OutboundRouteEntry"/>.</param>

test/Microsoft.AspNetCore.Routing.Tests/EndpointFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public static RouteEndpoint CreateRouteEndpoint(
2222
var d = new List<object>(metadata ?? Array.Empty<object>());
2323
if (requiredValues != null)
2424
{
25-
d.Add(new RouteValuesAddressMetadata(null, new RouteValueDictionary(requiredValues)));
25+
d.Add(new RouteValuesAddressMetadata(new RouteValueDictionary(requiredValues)));
2626
}
2727

2828
return new RouteEndpoint(

0 commit comments

Comments
 (0)