Skip to content

Commit

Permalink
RouteValuesAddressMetadata ctors and XML docs (#818)
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesNK committed Sep 29, 2018
1 parent 3044cc8 commit d1f3b90
Show file tree
Hide file tree
Showing 17 changed files with 86 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public sealed class EndpointMetadataCollection : IReadOnlyList<object>
private readonly ConcurrentDictionary<Type, object[]> _cache;

/// <summary>
/// Creates a new <see cref="EndpointMetadataCollection"/>.
/// Creates a new instance of <see cref="EndpointMetadataCollection"/>.
/// </summary>
/// <param name="items">The metadata items.</param>
public EndpointMetadataCollection(IEnumerable<object> items)
Expand All @@ -44,7 +44,7 @@ public EndpointMetadataCollection(IEnumerable<object> items)
}

/// <summary>
/// Creates a new <see cref="EndpointMetadataCollection"/>.
/// Creates a new instance of <see cref="EndpointMetadataCollection"/>.
/// </summary>
/// <param name="items">The metadata items.</param>
public EndpointMetadataCollection(params object[] items)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class RouteContext
private RouteData _routeData;

/// <summary>
/// Creates a new <see cref="RouteContext"/> for the provided <paramref name="httpContext"/>.
/// Creates a new instance of <see cref="RouteContext"/> for the provided <paramref name="httpContext"/>.
/// </summary>
/// <param name="httpContext">The <see cref="Http.HttpContext"/> associated with the current request.</param>
public RouteContext(HttpContext httpContext)
Expand Down
8 changes: 4 additions & 4 deletions src/Microsoft.AspNetCore.Routing.Abstractions/RouteData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ public class RouteData
private RouteValueDictionary _values;

/// <summary>
/// Creates a new <see cref="RouteData"/> instance.
/// Creates a new instance of <see cref="RouteData"/> instance.
/// </summary>
public RouteData()
{
// Perf: Avoid allocating collections unless needed.
}

/// <summary>
/// Creates a new <see cref="RouteData"/> instance with values copied from <paramref name="other"/>.
/// Creates a new instance of <see cref="RouteData"/> instance with values copied from <paramref name="other"/>.
/// </summary>
/// <param name="other">The other <see cref="RouteData"/> instance to copy.</param>
public RouteData(RouteData other)
Expand Down Expand Up @@ -52,7 +52,7 @@ public RouteData(RouteData other)
}

/// <summary>
/// Creates a new <see cref="RouteData"/> instance with the specified values.
/// Creates a new instance of <see cref="RouteData"/> instance with the specified values.
/// </summary>
/// <param name="values">The <see cref="RouteValueDictionary"/> values.</param>
public RouteData(RouteValueDictionary values)
Expand Down Expand Up @@ -197,7 +197,7 @@ public struct RouteDataSnapshot
private readonly RouteValueDictionary _values;

/// <summary>
/// Creates a new <see cref="RouteDataSnapshot"/> for <paramref name="routeData"/>.
/// Creates a new instance of <see cref="RouteDataSnapshot"/> for <paramref name="routeData"/>.
/// </summary>
/// <param name="routeData">The <see cref="RouteData"/>.</param>
/// <param name="dataTokens">The data tokens.</param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class RouteValueDictionary : IDictionary<string, object>, IReadOnlyDictio
private int _count;

/// <summary>
/// Creates a new <see cref="RouteValueDictionary"/> from the provided array.
/// Creates a new instance of <see cref="RouteValueDictionary"/> from the provided array.
/// The new instance will take ownership of the array, and may mutate it.
/// </summary>
/// <param name="items">The items array.</param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Microsoft.AspNetCore.Routing
public class VirtualPathContext
{
/// <summary>
/// Creates a new <see cref="VirtualPathContext"/>.
/// Creates a new instance of <see cref="VirtualPathContext"/>.
/// </summary>
/// <param name="httpContext">The <see cref="Http.HttpContext"/> associated with the current request.</param>
/// <param name="ambientValues">The set of route values associated with the current request.</param>
Expand All @@ -25,7 +25,7 @@ public VirtualPathContext(
}

/// <summary>
/// Creates a new <see cref="VirtualPathContext"/>.
/// Creates a new instance of <see cref="VirtualPathContext"/>.
/// </summary>
/// <param name="httpContext">The <see cref="Http.HttpContext"/> associated with the current request.</param>
/// <param name="ambientValues">The set of route values associated with the current request.</param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Microsoft.AspNetCore.Routing.Constraints
public class HttpMethodRouteConstraint : IRouteConstraint
{
/// <summary>
/// Creates a new <see cref="HttpMethodRouteConstraint"/> that accepts the HTTP methods specified
/// Creates a new instance of <see cref="HttpMethodRouteConstraint"/> that accepts the HTTP methods specified
/// by <paramref name="allowedMethods"/>.
/// </summary>
/// <param name="allowedMethods">The allowed HTTP methods.</param>
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.AspNetCore.Routing/EndpointNameMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Microsoft.AspNetCore.Routing
public class EndpointNameMetadata : IEndpointNameMetadata
{
/// <summary>
/// Creates a new <see cref="EndpointNameMetadata"/> with the provided endpoint name.
/// Creates a new instance of <see cref="EndpointNameMetadata"/> with the provided endpoint name.
/// </summary>
/// <param name="endpointName">The endpoint name.</param>
public EndpointNameMetadata(string endpointName)
Expand Down
11 changes: 11 additions & 0 deletions src/Microsoft.AspNetCore.Routing/IRouteValuesAddressMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,20 @@

namespace Microsoft.AspNetCore.Routing
{
/// <summary>
/// Represents metadata used during link generation to find
/// the associated endpoint using route values.
/// </summary>
public interface IRouteValuesAddressMetadata
{
/// <summary>
/// Gets the route name. Can be null.
/// </summary>
string RouteName { get; }

/// <summary>
/// Gets the required route values.
/// </summary>
IReadOnlyDictionary<string, object> RequiredValues { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ private RoutePatternException(SerializationInfo info, StreamingContext context)
}

/// <summary>
/// Creates a new <see cref="RoutePatternException"/>.
/// Creates a new instance of <see cref="RoutePatternException"/>.
/// </summary>
/// <param name="pattern">The route pattern as raw text.</param>
/// <param name="message">The exception message.</param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static RoutePattern Parse(string pattern, object defaults, object paramet
}

/// <summary>
/// Creates a new <see cref="RoutePattern"/> from a collection of segments.
/// Creates a new instance of <see cref="RoutePattern"/> from a collection of segments.
/// </summary>
/// <param name="segments">The collection of segments.</param>
/// <returns>The <see cref="RoutePattern"/>.</returns>
Expand All @@ -82,7 +82,7 @@ public static RoutePattern Pattern(IEnumerable<RoutePatternPathSegment> segments
}

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

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

/// <summary>
/// Creates a new <see cref="RoutePattern"/> from a collection of segments.
/// Creates a new instance of <see cref="RoutePattern"/> from a collection of segments.
/// </summary>
/// <param name="rawText">The raw text to associate with the route pattern. May be null.</param>
/// <param name="segments">The collection of segments.</param>
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.AspNetCore.Routing/RouteConstraintBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class RouteConstraintBuilder
private readonly Dictionary<string, List<IRouteConstraint>> _constraints;
private readonly HashSet<string> _optionalParameters;
/// <summary>
/// Creates a new <see cref="RouteConstraintBuilder"/> instance.
/// Creates a new instance of <see cref="RouteConstraintBuilder"/> instance.
/// </summary>
/// <param name="inlineConstraintResolver">The <see cref="IInlineConstraintResolver"/>.</param>
/// <param name="displayName">The display name (for use in error messages).</param>
Expand Down
39 changes: 39 additions & 0 deletions src/Microsoft.AspNetCore.Routing/RouteValuesAddressMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,61 @@

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq;

namespace Microsoft.AspNetCore.Routing
{
/// <summary>
/// Metadata used during link generation to find the associated endpoint using route values.
/// </summary>
[DebuggerDisplay("{DebuggerToString(),nq}")]
public sealed class RouteValuesAddressMetadata : IRouteValuesAddressMetadata
{
private static readonly IReadOnlyDictionary<string, object> EmptyRouteValues =
new ReadOnlyDictionary<string, object>(new Dictionary<string, object>());

/// <summary>
/// Creates a new instance of <see cref="RouteValuesAddressMetadata"/> with the provided route name.
/// </summary>
/// <param name="routeName">The route name. Can be null.</param>
public RouteValuesAddressMetadata(string routeName) : this(routeName, EmptyRouteValues)
{
}

/// <summary>
/// Creates a new instance of <see cref="RouteValuesAddressMetadata"/> with the provided required route values.
/// </summary>
/// <param name="requiredValues">The required route values.</param>
public RouteValuesAddressMetadata(IReadOnlyDictionary<string, object> requiredValues) : this(null, requiredValues)
{
}

/// <summary>
/// Creates a new instance of <see cref="RouteValuesAddressMetadata"/> with the provided route name and required route values.
/// </summary>
/// <param name="routeName">The route name. Can be null.</param>
/// <param name="requiredValues">The required route values.</param>
public RouteValuesAddressMetadata(string routeName, IReadOnlyDictionary<string, object> requiredValues)
{
if (requiredValues == null)
{
throw new ArgumentNullException(nameof(requiredValues));
}

RouteName = routeName;
RequiredValues = requiredValues;
}

/// <summary>
/// Gets the route name. Can be null.
/// </summary>
public string RouteName { get; }

/// <summary>
/// Gets the required route values.
/// </summary>
public IReadOnlyDictionary<string, object> RequiredValues { get; }

internal string DebuggerToString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Microsoft.AspNetCore.Routing.Template
public class InlineConstraint
{
/// <summary>
/// Creates a new <see cref="InlineConstraint"/>.
/// Creates a new instance of <see cref="InlineConstraint"/>.
/// </summary>
/// <param name="constraint">The constraint text.</param>
public InlineConstraint(string constraint)
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.AspNetCore.Routing/Tree/TreeRouter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class TreeRouter : IRouter
private readonly ILogger _constraintLogger;

/// <summary>
/// Creates a new <see cref="TreeRouter"/>.
/// Creates a new instance of <see cref="TreeRouter"/>.
/// </summary>
/// <param name="trees">The list of <see cref="UrlMatchingTree"/> that contains the route entries.</param>
/// <param name="linkGenerationEntries">The set of <see cref="OutboundRouteEntry"/>.</param>
Expand Down
2 changes: 1 addition & 1 deletion test/Microsoft.AspNetCore.Routing.Tests/EndpointFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static RouteEndpoint CreateRouteEndpoint(
var d = new List<object>(metadata ?? Array.Empty<object>());
if (requiredValues != null)
{
d.Add(new RouteValuesAddressMetadata(null, new RouteValueDictionary(requiredValues)));
d.Add(new RouteValuesAddressMetadata(new RouteValueDictionary(requiredValues)));
}

return new RouteEndpoint(
Expand Down
Loading

0 comments on commit d1f3b90

Please sign in to comment.