This commit is contained in:
Ryan Nowak 2018-08-27 17:35:38 -07:00
parent 10e1b619c3
commit 96b77c8663
2 changed files with 18 additions and 11 deletions

View File

@ -174,7 +174,8 @@ namespace Microsoft.AspNetCore.Mvc.Internal
endpointInfo.Defaults, endpointInfo.Defaults,
++conventionalRouteOrder, ++conventionalRouteOrder,
endpointInfo, endpointInfo,
suppressLinkGeneration: false); suppressLinkGeneration: false,
suppressPathMatching: false);
endpoints.Add(subEndpoint); endpoints.Add(subEndpoint);
} }
@ -213,7 +214,8 @@ namespace Microsoft.AspNetCore.Mvc.Internal
endpointInfo.Defaults, endpointInfo.Defaults,
++conventionalRouteOrder, ++conventionalRouteOrder,
endpointInfo, endpointInfo,
suppressLinkGeneration: false); suppressLinkGeneration: false,
suppressPathMatching: false);
endpoints.Add(endpoint); endpoints.Add(endpoint);
} }
} }
@ -227,7 +229,8 @@ namespace Microsoft.AspNetCore.Mvc.Internal
nonInlineDefaults: null, nonInlineDefaults: null,
action.AttributeRouteInfo.Order, action.AttributeRouteInfo.Order,
action.AttributeRouteInfo, action.AttributeRouteInfo,
suppressLinkGeneration: action.AttributeRouteInfo.SuppressLinkGeneration); suppressLinkGeneration: action.AttributeRouteInfo.SuppressLinkGeneration,
suppressPathMatching: action.AttributeRouteInfo.SuppressPathMatching);
endpoints.Add(endpoint); endpoints.Add(endpoint);
} }
} }
@ -375,7 +378,8 @@ namespace Microsoft.AspNetCore.Mvc.Internal
object nonInlineDefaults, object nonInlineDefaults,
int order, int order,
object source, object source,
bool suppressLinkGeneration) bool suppressLinkGeneration,
bool suppressPathMatching)
{ {
RequestDelegate requestDelegate = (context) => RequestDelegate requestDelegate = (context) =>
{ {
@ -403,7 +407,8 @@ namespace Microsoft.AspNetCore.Mvc.Internal
routeName, routeName,
new RouteValueDictionary(action.RouteValues), new RouteValueDictionary(action.RouteValues),
source, source,
suppressLinkGeneration); suppressLinkGeneration,
suppressPathMatching);
var endpoint = new RouteEndpoint( var endpoint = new RouteEndpoint(
requestDelegate, requestDelegate,
@ -420,12 +425,11 @@ namespace Microsoft.AspNetCore.Mvc.Internal
string routeName, string routeName,
RouteValueDictionary requiredValues, RouteValueDictionary requiredValues,
object source, object source,
bool suppressLinkGeneration) bool suppressLinkGeneration,
bool suppressPathMatching)
{ {
var metadata = new List<object> var metadata = new List<object>
{ {
// REVIEW: Used for debugging. Consider removing before release
source,
action action
}; };
@ -475,6 +479,11 @@ namespace Microsoft.AspNetCore.Mvc.Internal
metadata.Add(new SuppressLinkGenerationMetadata()); metadata.Add(new SuppressLinkGenerationMetadata());
} }
if (suppressPathMatching)
{
metadata.Add(new SuppressMatchingMetadata());
}
var metadataCollection = new EndpointMetadataCollection(metadata); var metadataCollection = new EndpointMetadataCollection(metadata);
return metadataCollection; return metadataCollection;
} }
@ -500,7 +509,5 @@ namespace Microsoft.AspNetCore.Mvc.Internal
defaults[kvp.Key] = kvp.Value; defaults[kvp.Key] = kvp.Value;
} }
} }
private class SuppressLinkGenerationMetadata : ISuppressLinkGenerationMetadata { }
} }
} }

View File

@ -128,7 +128,7 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
Assert.Equal("From Header - HelloWorld", body); Assert.Equal("From Header - HelloWorld", body);
} }
[Fact(Skip = "https://github.com/aspnet/Routing/issues/721")] [Fact]
public async Task ActionModelSuppressedForPathMatching_CannotBeRouted() public async Task ActionModelSuppressedForPathMatching_CannotBeRouted()
{ {
// Arrange & Act // Arrange & Act