diff --git a/Mvc.NoFun.sln b/Mvc.NoFun.sln index b80ac4f973..315456d9e6 100644 --- a/Mvc.NoFun.sln +++ b/Mvc.NoFun.sln @@ -99,6 +99,12 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "LocalizationSample.Web", "s EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ActionConstraintSample.Web", "samples\ActionConstraintSample.Web\ActionConstraintSample.Web.xproj", "{EE0BD773-4D47-4AA8-8472-5A938A3953BA}" 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 GlobalSection(SolutionConfigurationPlatforms) = preSolution 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|x86.ActiveCfg = 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 GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/global.json b/global.json index fad3dfeab0..2c65fcd5f2 100644 --- a/global.json +++ b/global.json @@ -1,3 +1,3 @@ { - "projects": ["src", "test/WebSites", "samples"] + "projects": ["src", "test/WebSites", "samples", "d:\\k\\Routing\\src"] } diff --git a/src/Microsoft.AspNet.Mvc.Core/Routing/AttributeRoute.cs b/src/Microsoft.AspNet.Mvc.Core/Routing/AttributeRoute.cs index 6f423e0991..500cd5c470 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Routing/AttributeRoute.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Routing/AttributeRoute.cs @@ -10,9 +10,11 @@ using Microsoft.AspNet.Mvc.Abstractions; using Microsoft.AspNet.Mvc.Core; using Microsoft.AspNet.Mvc.Infrastructure; using Microsoft.AspNet.Routing; +using Microsoft.AspNet.Routing.Internal; using Microsoft.AspNet.Routing.Template; using Microsoft.AspNet.Routing.Tree; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.ObjectPool; namespace Microsoft.AspNet.Mvc.Routing { @@ -21,6 +23,7 @@ namespace Microsoft.AspNet.Mvc.Routing private readonly IRouter _target; private readonly IActionDescriptorsCollectionProvider _actionDescriptorsCollectionProvider; private readonly IInlineConstraintResolver _constraintResolver; + private readonly ObjectPool _contextPool; private readonly UrlEncoder _urlEncoder; private readonly ILoggerFactory _loggerFactory; @@ -30,6 +33,7 @@ namespace Microsoft.AspNet.Mvc.Routing IRouter target, IActionDescriptorsCollectionProvider actionDescriptorsCollectionProvider, IInlineConstraintResolver constraintResolver, + ObjectPool contextPool, UrlEncoder urlEncoder, ILoggerFactory loggerFactory) { @@ -48,6 +52,11 @@ namespace Microsoft.AspNet.Mvc.Routing throw new ArgumentNullException(nameof(constraintResolver)); } + if (contextPool == null) + { + throw new ArgumentNullException(nameof(contextPool)); + } + if (urlEncoder == null) { throw new ArgumentNullException(nameof(urlEncoder)); @@ -61,6 +70,7 @@ namespace Microsoft.AspNet.Mvc.Routing _target = target; _actionDescriptorsCollectionProvider = actionDescriptorsCollectionProvider; _constraintResolver = constraintResolver; + _contextPool = contextPool; _urlEncoder = urlEncoder; _loggerFactory = loggerFactory; } @@ -104,7 +114,7 @@ namespace Microsoft.AspNet.Mvc.Routing { routeBuilder.Add(new TreeRouteLinkGenerationEntry() { - Binder = new TemplateBinder(routeInfo.ParsedTemplate, _urlEncoder, routeInfo.Defaults), + Binder = new TemplateBinder(_urlEncoder, _contextPool, routeInfo.ParsedTemplate, routeInfo.Defaults), Defaults = routeInfo.Defaults, Constraints = routeInfo.Constraints, Order = routeInfo.Order, diff --git a/src/Microsoft.AspNet.Mvc.Core/Routing/AttributeRouting.cs b/src/Microsoft.AspNet.Mvc.Core/Routing/AttributeRouting.cs index ab7683daf8..5b52c9629f 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Routing/AttributeRouting.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Routing/AttributeRouting.cs @@ -5,8 +5,10 @@ using System; using System.Text.Encodings.Web; using Microsoft.AspNet.Mvc.Infrastructure; using Microsoft.AspNet.Routing; +using Microsoft.AspNet.Routing.Internal; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.ObjectPool; namespace Microsoft.AspNet.Mvc.Routing { @@ -32,6 +34,7 @@ namespace Microsoft.AspNet.Mvc.Routing var actionDescriptorProvider = services.GetRequiredService(); var inlineConstraintResolver = services.GetRequiredService(); + var pool = services.GetRequiredService>(); var urlEncoder = services.GetRequiredService(); var loggerFactory = services.GetRequiredService(); @@ -39,6 +42,7 @@ namespace Microsoft.AspNet.Mvc.Routing target, actionDescriptorProvider, inlineConstraintResolver, + pool, urlEncoder, loggerFactory); } diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/Routing/AttributeRouteTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/Routing/AttributeRouteTest.cs index b5b88eba78..caf6a46f9e 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/Routing/AttributeRouteTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/Routing/AttributeRouteTest.cs @@ -9,9 +9,11 @@ using Microsoft.AspNet.Http.Internal; using Microsoft.AspNet.Mvc.Abstractions; using Microsoft.AspNet.Mvc.Infrastructure; using Microsoft.AspNet.Routing; +using Microsoft.AspNet.Routing.Internal; using Microsoft.AspNet.Routing.Tree; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Testing; +using Microsoft.Extensions.ObjectPool; using Microsoft.Extensions.WebEncoders.Testing; using Moq; using Xunit; @@ -67,10 +69,14 @@ namespace Microsoft.AspNet.Mvc.Routing .SetupGet(ad => ad.ActionDescriptors) .Returns(new ActionDescriptorsCollection(actionDescriptors, version: 1)); + var policy = new UriBuilderContextPooledObjectPolicy(new UrlTestEncoder()); + var pool = new DefaultObjectPool(policy); + var route = new AttributeRoute( handler.Object, actionDescriptorsProvider.Object, Mock.Of(), + pool, new UrlTestEncoder(), NullLoggerFactory.Instance); diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/Routing/AttributeRoutingTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/Routing/AttributeRoutingTest.cs index 9f8748b1e8..bcb2560a84 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/Routing/AttributeRoutingTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/Routing/AttributeRoutingTest.cs @@ -193,10 +193,11 @@ namespace Microsoft.AspNet.Mvc.Routing .Returns(new RouteOptions()); return new ServiceCollection() - .AddSingleton(actionDescriptorProvider.Object) .AddSingleton(new DefaultInlineConstraintResolver(routeOptions.Object)) - .AddSingleton(NullLoggerFactory.Instance) .AddSingleton(new UrlTestEncoder()) + .AddRouting() + .AddSingleton(actionDescriptorProvider.Object) + .AddSingleton(NullLoggerFactory.Instance) .BuildServiceProvider(); } diff --git a/test/Microsoft.AspNet.Mvc.FunctionalTests/compiler/resources/HtmlGenerationWebSite.HtmlGeneration_Home.Index.Encoded.html b/test/Microsoft.AspNet.Mvc.FunctionalTests/compiler/resources/HtmlGenerationWebSite.HtmlGeneration_Home.Index.Encoded.html index d292ddbab7..5d696d4c25 100644 --- a/test/Microsoft.AspNet.Mvc.FunctionalTests/compiler/resources/HtmlGenerationWebSite.HtmlGeneration_Home.Index.Encoded.html +++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/compiler/resources/HtmlGenerationWebSite.HtmlGeneration_Home.Index.Encoded.html @@ -64,7 +64,7 @@
Non-existent Area diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/RemoteAttributeTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/RemoteAttributeTest.cs index bd658ef7e3..d7b844f0ac 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/RemoteAttributeTest.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/RemoteAttributeTest.cs @@ -576,6 +576,7 @@ namespace Microsoft.AspNet.Mvc .Returns(routeOptions); serviceCollection.AddSingleton>(accessor.Object); + serviceCollection.AddRouting(); serviceCollection.AddSingleton( new DefaultInlineConstraintResolver(accessor.Object));