React to changes in routing
This commit is contained in:
parent
51e74c2eba
commit
85a4c7edc5
|
|
@ -99,6 +99,12 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "LocalizationSample.Web", "s
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ActionConstraintSample.Web", "samples\ActionConstraintSample.Web\ActionConstraintSample.Web.xproj", "{EE0BD773-4D47-4AA8-8472-5A938A3953BA}"
|
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ActionConstraintSample.Web", "samples\ActionConstraintSample.Web\ActionConstraintSample.Web.xproj", "{EE0BD773-4D47-4AA8-8472-5A938A3953BA}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Routing.Abstractions", "..\Routing\src\Microsoft.AspNet.Routing.Abstractions\Microsoft.AspNet.Routing.Abstractions.xproj", "{ED253B01-24F1-43D1-AA0B-079391E105A9}"
|
||||||
|
EndProject
|
||||||
|
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Routing", "..\Routing\src\Microsoft.AspNet.Routing\Microsoft.AspNet.Routing.xproj", "{1EE54D32-6CED-4206-ACF5-3DC1DD39D228}"
|
||||||
|
EndProject
|
||||||
|
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Routing.DecisionTree.Sources", "..\Routing\src\Microsoft.AspNet.Routing.DecisionTree.Sources\Microsoft.AspNet.Routing.DecisionTree.Sources.xproj", "{ABD5AA59-6000-4A3D-A54F-4B636F725AE8}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
|
@ -591,6 +597,42 @@ Global
|
||||||
{EE0BD773-4D47-4AA8-8472-5A938A3953BA}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
{EE0BD773-4D47-4AA8-8472-5A938A3953BA}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||||
{EE0BD773-4D47-4AA8-8472-5A938A3953BA}.Release|x86.ActiveCfg = Release|Any CPU
|
{EE0BD773-4D47-4AA8-8472-5A938A3953BA}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{EE0BD773-4D47-4AA8-8472-5A938A3953BA}.Release|x86.Build.0 = Release|Any CPU
|
{EE0BD773-4D47-4AA8-8472-5A938A3953BA}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{ED253B01-24F1-43D1-AA0B-079391E105A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{ED253B01-24F1-43D1-AA0B-079391E105A9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{ED253B01-24F1-43D1-AA0B-079391E105A9}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||||
|
{ED253B01-24F1-43D1-AA0B-079391E105A9}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||||
|
{ED253B01-24F1-43D1-AA0B-079391E105A9}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{ED253B01-24F1-43D1-AA0B-079391E105A9}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{ED253B01-24F1-43D1-AA0B-079391E105A9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{ED253B01-24F1-43D1-AA0B-079391E105A9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{ED253B01-24F1-43D1-AA0B-079391E105A9}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||||
|
{ED253B01-24F1-43D1-AA0B-079391E105A9}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||||
|
{ED253B01-24F1-43D1-AA0B-079391E105A9}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{ED253B01-24F1-43D1-AA0B-079391E105A9}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{1EE54D32-6CED-4206-ACF5-3DC1DD39D228}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{1EE54D32-6CED-4206-ACF5-3DC1DD39D228}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{1EE54D32-6CED-4206-ACF5-3DC1DD39D228}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||||
|
{1EE54D32-6CED-4206-ACF5-3DC1DD39D228}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||||
|
{1EE54D32-6CED-4206-ACF5-3DC1DD39D228}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{1EE54D32-6CED-4206-ACF5-3DC1DD39D228}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{1EE54D32-6CED-4206-ACF5-3DC1DD39D228}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{1EE54D32-6CED-4206-ACF5-3DC1DD39D228}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{1EE54D32-6CED-4206-ACF5-3DC1DD39D228}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||||
|
{1EE54D32-6CED-4206-ACF5-3DC1DD39D228}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||||
|
{1EE54D32-6CED-4206-ACF5-3DC1DD39D228}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{1EE54D32-6CED-4206-ACF5-3DC1DD39D228}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{ABD5AA59-6000-4A3D-A54F-4B636F725AE8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{ABD5AA59-6000-4A3D-A54F-4B636F725AE8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{ABD5AA59-6000-4A3D-A54F-4B636F725AE8}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||||
|
{ABD5AA59-6000-4A3D-A54F-4B636F725AE8}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||||
|
{ABD5AA59-6000-4A3D-A54F-4B636F725AE8}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{ABD5AA59-6000-4A3D-A54F-4B636F725AE8}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{ABD5AA59-6000-4A3D-A54F-4B636F725AE8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{ABD5AA59-6000-4A3D-A54F-4B636F725AE8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{ABD5AA59-6000-4A3D-A54F-4B636F725AE8}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||||
|
{ABD5AA59-6000-4A3D-A54F-4B636F725AE8}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||||
|
{ABD5AA59-6000-4A3D-A54F-4B636F725AE8}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{ABD5AA59-6000-4A3D-A54F-4B636F725AE8}.Release|x86.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
{
|
{
|
||||||
"projects": ["src", "test/WebSites", "samples"]
|
"projects": ["src", "test/WebSites", "samples", "d:\\k\\Routing\\src"]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,11 @@ using Microsoft.AspNet.Mvc.Abstractions;
|
||||||
using Microsoft.AspNet.Mvc.Core;
|
using Microsoft.AspNet.Mvc.Core;
|
||||||
using Microsoft.AspNet.Mvc.Infrastructure;
|
using Microsoft.AspNet.Mvc.Infrastructure;
|
||||||
using Microsoft.AspNet.Routing;
|
using Microsoft.AspNet.Routing;
|
||||||
|
using Microsoft.AspNet.Routing.Internal;
|
||||||
using Microsoft.AspNet.Routing.Template;
|
using Microsoft.AspNet.Routing.Template;
|
||||||
using Microsoft.AspNet.Routing.Tree;
|
using Microsoft.AspNet.Routing.Tree;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Microsoft.Extensions.ObjectPool;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.Routing
|
namespace Microsoft.AspNet.Mvc.Routing
|
||||||
{
|
{
|
||||||
|
|
@ -21,6 +23,7 @@ namespace Microsoft.AspNet.Mvc.Routing
|
||||||
private readonly IRouter _target;
|
private readonly IRouter _target;
|
||||||
private readonly IActionDescriptorsCollectionProvider _actionDescriptorsCollectionProvider;
|
private readonly IActionDescriptorsCollectionProvider _actionDescriptorsCollectionProvider;
|
||||||
private readonly IInlineConstraintResolver _constraintResolver;
|
private readonly IInlineConstraintResolver _constraintResolver;
|
||||||
|
private readonly ObjectPool<UriBuildingContext> _contextPool;
|
||||||
private readonly UrlEncoder _urlEncoder;
|
private readonly UrlEncoder _urlEncoder;
|
||||||
private readonly ILoggerFactory _loggerFactory;
|
private readonly ILoggerFactory _loggerFactory;
|
||||||
|
|
||||||
|
|
@ -30,6 +33,7 @@ namespace Microsoft.AspNet.Mvc.Routing
|
||||||
IRouter target,
|
IRouter target,
|
||||||
IActionDescriptorsCollectionProvider actionDescriptorsCollectionProvider,
|
IActionDescriptorsCollectionProvider actionDescriptorsCollectionProvider,
|
||||||
IInlineConstraintResolver constraintResolver,
|
IInlineConstraintResolver constraintResolver,
|
||||||
|
ObjectPool<UriBuildingContext> contextPool,
|
||||||
UrlEncoder urlEncoder,
|
UrlEncoder urlEncoder,
|
||||||
ILoggerFactory loggerFactory)
|
ILoggerFactory loggerFactory)
|
||||||
{
|
{
|
||||||
|
|
@ -48,6 +52,11 @@ namespace Microsoft.AspNet.Mvc.Routing
|
||||||
throw new ArgumentNullException(nameof(constraintResolver));
|
throw new ArgumentNullException(nameof(constraintResolver));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (contextPool == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(contextPool));
|
||||||
|
}
|
||||||
|
|
||||||
if (urlEncoder == null)
|
if (urlEncoder == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(urlEncoder));
|
throw new ArgumentNullException(nameof(urlEncoder));
|
||||||
|
|
@ -61,6 +70,7 @@ namespace Microsoft.AspNet.Mvc.Routing
|
||||||
_target = target;
|
_target = target;
|
||||||
_actionDescriptorsCollectionProvider = actionDescriptorsCollectionProvider;
|
_actionDescriptorsCollectionProvider = actionDescriptorsCollectionProvider;
|
||||||
_constraintResolver = constraintResolver;
|
_constraintResolver = constraintResolver;
|
||||||
|
_contextPool = contextPool;
|
||||||
_urlEncoder = urlEncoder;
|
_urlEncoder = urlEncoder;
|
||||||
_loggerFactory = loggerFactory;
|
_loggerFactory = loggerFactory;
|
||||||
}
|
}
|
||||||
|
|
@ -104,7 +114,7 @@ namespace Microsoft.AspNet.Mvc.Routing
|
||||||
{
|
{
|
||||||
routeBuilder.Add(new TreeRouteLinkGenerationEntry()
|
routeBuilder.Add(new TreeRouteLinkGenerationEntry()
|
||||||
{
|
{
|
||||||
Binder = new TemplateBinder(routeInfo.ParsedTemplate, _urlEncoder, routeInfo.Defaults),
|
Binder = new TemplateBinder(_urlEncoder, _contextPool, routeInfo.ParsedTemplate, routeInfo.Defaults),
|
||||||
Defaults = routeInfo.Defaults,
|
Defaults = routeInfo.Defaults,
|
||||||
Constraints = routeInfo.Constraints,
|
Constraints = routeInfo.Constraints,
|
||||||
Order = routeInfo.Order,
|
Order = routeInfo.Order,
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,10 @@ using System;
|
||||||
using System.Text.Encodings.Web;
|
using System.Text.Encodings.Web;
|
||||||
using Microsoft.AspNet.Mvc.Infrastructure;
|
using Microsoft.AspNet.Mvc.Infrastructure;
|
||||||
using Microsoft.AspNet.Routing;
|
using Microsoft.AspNet.Routing;
|
||||||
|
using Microsoft.AspNet.Routing.Internal;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Microsoft.Extensions.ObjectPool;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.Routing
|
namespace Microsoft.AspNet.Mvc.Routing
|
||||||
{
|
{
|
||||||
|
|
@ -32,6 +34,7 @@ namespace Microsoft.AspNet.Mvc.Routing
|
||||||
|
|
||||||
var actionDescriptorProvider = services.GetRequiredService<IActionDescriptorsCollectionProvider>();
|
var actionDescriptorProvider = services.GetRequiredService<IActionDescriptorsCollectionProvider>();
|
||||||
var inlineConstraintResolver = services.GetRequiredService<IInlineConstraintResolver>();
|
var inlineConstraintResolver = services.GetRequiredService<IInlineConstraintResolver>();
|
||||||
|
var pool = services.GetRequiredService<ObjectPool<UriBuildingContext>>();
|
||||||
var urlEncoder = services.GetRequiredService<UrlEncoder>();
|
var urlEncoder = services.GetRequiredService<UrlEncoder>();
|
||||||
var loggerFactory = services.GetRequiredService<ILoggerFactory>();
|
var loggerFactory = services.GetRequiredService<ILoggerFactory>();
|
||||||
|
|
||||||
|
|
@ -39,6 +42,7 @@ namespace Microsoft.AspNet.Mvc.Routing
|
||||||
target,
|
target,
|
||||||
actionDescriptorProvider,
|
actionDescriptorProvider,
|
||||||
inlineConstraintResolver,
|
inlineConstraintResolver,
|
||||||
|
pool,
|
||||||
urlEncoder,
|
urlEncoder,
|
||||||
loggerFactory);
|
loggerFactory);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,11 @@ using Microsoft.AspNet.Http.Internal;
|
||||||
using Microsoft.AspNet.Mvc.Abstractions;
|
using Microsoft.AspNet.Mvc.Abstractions;
|
||||||
using Microsoft.AspNet.Mvc.Infrastructure;
|
using Microsoft.AspNet.Mvc.Infrastructure;
|
||||||
using Microsoft.AspNet.Routing;
|
using Microsoft.AspNet.Routing;
|
||||||
|
using Microsoft.AspNet.Routing.Internal;
|
||||||
using Microsoft.AspNet.Routing.Tree;
|
using Microsoft.AspNet.Routing.Tree;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.Logging.Testing;
|
using Microsoft.Extensions.Logging.Testing;
|
||||||
|
using Microsoft.Extensions.ObjectPool;
|
||||||
using Microsoft.Extensions.WebEncoders.Testing;
|
using Microsoft.Extensions.WebEncoders.Testing;
|
||||||
using Moq;
|
using Moq;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
@ -67,10 +69,14 @@ namespace Microsoft.AspNet.Mvc.Routing
|
||||||
.SetupGet(ad => ad.ActionDescriptors)
|
.SetupGet(ad => ad.ActionDescriptors)
|
||||||
.Returns(new ActionDescriptorsCollection(actionDescriptors, version: 1));
|
.Returns(new ActionDescriptorsCollection(actionDescriptors, version: 1));
|
||||||
|
|
||||||
|
var policy = new UriBuilderContextPooledObjectPolicy(new UrlTestEncoder());
|
||||||
|
var pool = new DefaultObjectPool<UriBuildingContext>(policy);
|
||||||
|
|
||||||
var route = new AttributeRoute(
|
var route = new AttributeRoute(
|
||||||
handler.Object,
|
handler.Object,
|
||||||
actionDescriptorsProvider.Object,
|
actionDescriptorsProvider.Object,
|
||||||
Mock.Of<IInlineConstraintResolver>(),
|
Mock.Of<IInlineConstraintResolver>(),
|
||||||
|
pool,
|
||||||
new UrlTestEncoder(),
|
new UrlTestEncoder(),
|
||||||
NullLoggerFactory.Instance);
|
NullLoggerFactory.Instance);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -193,10 +193,11 @@ namespace Microsoft.AspNet.Mvc.Routing
|
||||||
.Returns(new RouteOptions());
|
.Returns(new RouteOptions());
|
||||||
|
|
||||||
return new ServiceCollection()
|
return new ServiceCollection()
|
||||||
.AddSingleton(actionDescriptorProvider.Object)
|
|
||||||
.AddSingleton<IInlineConstraintResolver>(new DefaultInlineConstraintResolver(routeOptions.Object))
|
.AddSingleton<IInlineConstraintResolver>(new DefaultInlineConstraintResolver(routeOptions.Object))
|
||||||
.AddSingleton<ILoggerFactory>(NullLoggerFactory.Instance)
|
|
||||||
.AddSingleton<UrlEncoder>(new UrlTestEncoder())
|
.AddSingleton<UrlEncoder>(new UrlTestEncoder())
|
||||||
|
.AddRouting()
|
||||||
|
.AddSingleton(actionDescriptorProvider.Object)
|
||||||
|
.AddSingleton<ILoggerFactory>(NullLoggerFactory.Instance)
|
||||||
.BuildServiceProvider();
|
.BuildServiceProvider();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<a href="HtmlEncode[[/UrlEncode[[Product]]/UrlEncode[[Submit]]?area=NonExistentArea&id=1#fragment]]">Product Route Non-existent Area Parameter</a>
|
<a href="HtmlEncode[[/UrlEncode[[Product]]/UrlEncode[[Submit]]?UrlEncode[[area]]=UrlEncode[[NonExistentArea]]&UrlEncode[[id]]=UrlEncode[[1]]#fragment]]">Product Route Non-existent Area Parameter</a>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<a href="">Non-existent Area</a>
|
<a href="">Non-existent Area</a>
|
||||||
|
|
|
||||||
|
|
@ -576,6 +576,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
.Returns(routeOptions);
|
.Returns(routeOptions);
|
||||||
|
|
||||||
serviceCollection.AddSingleton<IOptions<RouteOptions>>(accessor.Object);
|
serviceCollection.AddSingleton<IOptions<RouteOptions>>(accessor.Object);
|
||||||
|
serviceCollection.AddRouting();
|
||||||
|
|
||||||
serviceCollection.AddSingleton<IInlineConstraintResolver>(
|
serviceCollection.AddSingleton<IInlineConstraintResolver>(
|
||||||
new DefaultInlineConstraintResolver(accessor.Object));
|
new DefaultInlineConstraintResolver(accessor.Object));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue