diff --git a/src/Microsoft.AspNetCore.Mvc.Core/DependencyInjection/MvcCoreServiceCollectionExtensions.cs b/src/Microsoft.AspNetCore.Mvc.Core/DependencyInjection/MvcCoreServiceCollectionExtensions.cs index 2f48bbedb0..3d50285d76 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/DependencyInjection/MvcCoreServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/DependencyInjection/MvcCoreServiceCollectionExtensions.cs @@ -261,7 +261,7 @@ namespace Microsoft.Extensions.DependencyInjection services.TryAddTransient(); // Many per app // - // Dispatching + // Global Routing / Endpoints // services.TryAddEnumerable( ServiceDescriptor.Singleton()); diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Internal/MvcEndpointDataSource.cs b/src/Microsoft.AspNetCore.Mvc.Core/Internal/MvcEndpointDataSource.cs index c8738bb20e..f725da108b 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/Internal/MvcEndpointDataSource.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/Internal/MvcEndpointDataSource.cs @@ -79,7 +79,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal // up the endpoints too. // // Start with an order of '1' for conventional routes as attribute routes have a default order of '0'. - // This is for scenarios dealing with migrating existing Routing based code to Dispatcher world. + // This is for scenarios dealing with migrating existing Router based code to Global Routing world. var conventionalRouteOrder = 0; // Check each of the conventional templates to see if the action would be reachable diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Routing/DispatcherUrlHelper.cs b/src/Microsoft.AspNetCore.Mvc.Core/Routing/GlobalRoutingUrlHelper.cs similarity index 93% rename from src/Microsoft.AspNetCore.Mvc.Core/Routing/DispatcherUrlHelper.cs rename to src/Microsoft.AspNetCore.Mvc.Core/Routing/GlobalRoutingUrlHelper.cs index 8b0efc4c38..e77274c3cd 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/Routing/DispatcherUrlHelper.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/Routing/GlobalRoutingUrlHelper.cs @@ -12,14 +12,14 @@ namespace Microsoft.AspNetCore.Mvc.Routing /// An implementation of that uses to build URLs /// for ASP.NET MVC within an application. /// - internal class DispatcherUrlHelper : UrlHelperBase + internal class GlobalRoutingUrlHelper : UrlHelperBase { - private readonly ILogger _logger; + private readonly ILogger _logger; private readonly LinkGenerator _linkGenerator; private readonly IEndpointFinder _routeValuesBasedEndpointFinder; /// - /// Initializes a new instance of the class using the specified + /// Initializes a new instance of the class using the specified /// . /// /// The for the current request. @@ -28,11 +28,11 @@ namespace Microsoft.AspNetCore.Mvc.Routing /// /// The used to generate the link. /// The . - public DispatcherUrlHelper( + public GlobalRoutingUrlHelper( ActionContext actionContext, IEndpointFinder routeValuesBasedEndpointFinder, LinkGenerator linkGenerator, - ILogger logger) + ILogger logger) : base(actionContext) { if (linkGenerator == null) diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Routing/UrlHelperFactory.cs b/src/Microsoft.AspNetCore.Mvc.Core/Routing/UrlHelperFactory.cs index 9d464aafa3..6db7f35638 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/Routing/UrlHelperFactory.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/Routing/UrlHelperFactory.cs @@ -53,9 +53,9 @@ namespace Microsoft.AspNetCore.Mvc.Routing var services = httpContext.RequestServices; var linkGenerator = services.GetRequiredService(); var routeValuesBasedEndpointFinder = services.GetRequiredService>(); - var logger = services.GetRequiredService>(); + var logger = services.GetRequiredService>(); - urlHelper = new DispatcherUrlHelper( + urlHelper = new GlobalRoutingUrlHelper( context, routeValuesBasedEndpointFinder, linkGenerator, diff --git a/src/Microsoft.AspNetCore.Mvc.TagHelpers/ValidationMessageTagHelper.cs b/src/Microsoft.AspNetCore.Mvc.TagHelpers/ValidationMessageTagHelper.cs index 8858623013..85d8d07837 100644 --- a/src/Microsoft.AspNetCore.Mvc.TagHelpers/ValidationMessageTagHelper.cs +++ b/src/Microsoft.AspNetCore.Mvc.TagHelpers/ValidationMessageTagHelper.cs @@ -71,11 +71,24 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers }; } + string message = null; + if (!output.IsContentModified) + { + var tagHelperContent = await output.GetChildContentAsync(); + + // We check for whitespace to detect scenarios such as: + // + // + if (!tagHelperContent.IsEmptyOrWhiteSpace) + { + message = tagHelperContent.GetContent(); + } + } var tagBuilder = Generator.GenerateValidationMessage( ViewContext, For.ModelExplorer, For.Name, - message: null, + message: message, tag: null, htmlAttributes: htmlAttributes); @@ -84,27 +97,12 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers output.MergeAttributes(tagBuilder); // Do not update the content if another tag helper targeting this element has already done so. - if (!output.IsContentModified) + if (!output.IsContentModified && tagBuilder.HasInnerHtml) { - // We check for whitespace to detect scenarios such as: - // - // - var childContent = await output.GetChildContentAsync(); - if (childContent.IsEmptyOrWhiteSpace) - { - // Provide default message text (if any) since there was nothing useful in the Razor source. - if (tagBuilder.HasInnerHtml) - { - output.Content.SetHtmlContent(tagBuilder.InnerHtml); - } - } - else - { - output.Content.SetHtmlContent(childContent); - } + output.Content.SetHtmlContent(tagBuilder.InnerHtml); } } } } } -} \ No newline at end of file +} diff --git a/test/Microsoft.AspNetCore.Mvc.Core.Test/Routing/DispatcherUrlHelperTest.cs b/test/Microsoft.AspNetCore.Mvc.Core.Test/Routing/GlobalRoutingUrlHelperTest.cs similarity index 97% rename from test/Microsoft.AspNetCore.Mvc.Core.Test/Routing/DispatcherUrlHelperTest.cs rename to test/Microsoft.AspNetCore.Mvc.Core.Test/Routing/GlobalRoutingUrlHelperTest.cs index b069feabc6..78c7551c43 100644 --- a/test/Microsoft.AspNetCore.Mvc.Core.Test/Routing/DispatcherUrlHelperTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Core.Test/Routing/GlobalRoutingUrlHelperTest.cs @@ -14,7 +14,7 @@ using Xunit; namespace Microsoft.AspNetCore.Mvc.Routing { - public class DispatcherUrlHelperTest : UrlHelperTestBase + public class GlobalRoutingUrlHelperTest : UrlHelperTestBase { protected override IUrlHelper CreateUrlHelper(string appRoot, string host, string protocol) { @@ -60,7 +60,7 @@ namespace Microsoft.AspNetCore.Mvc.Routing var urlHelperFactory = httpContext.RequestServices.GetRequiredService(); var urlHelper = urlHelperFactory.GetUrlHelper(actionContext); - Assert.IsType(urlHelper); + Assert.IsType(urlHelper); return urlHelper; } @@ -136,7 +136,7 @@ namespace Microsoft.AspNetCore.Mvc.Routing } var services = GetCommonServices(); - services.AddDispatcher(); + services.AddRouting(); services.TryAddEnumerable( ServiceDescriptor.Singleton(new DefaultEndpointDataSource(endpoints))); services.TryAddSingleton(); diff --git a/test/Microsoft.AspNetCore.Mvc.FunctionalTests/ConsumesAttributeDispatchingTests.cs b/test/Microsoft.AspNetCore.Mvc.FunctionalTests/ConsumesAttributeGlobalRoutingTests.cs similarity index 54% rename from test/Microsoft.AspNetCore.Mvc.FunctionalTests/ConsumesAttributeDispatchingTests.cs rename to test/Microsoft.AspNetCore.Mvc.FunctionalTests/ConsumesAttributeGlobalRoutingTests.cs index ced707f674..889e77e80b 100644 --- a/test/Microsoft.AspNetCore.Mvc.FunctionalTests/ConsumesAttributeDispatchingTests.cs +++ b/test/Microsoft.AspNetCore.Mvc.FunctionalTests/ConsumesAttributeGlobalRoutingTests.cs @@ -3,9 +3,9 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests { - public class ConsumesAttributeDispatchingTests : ConsumesAttributeTestsBase + public class ConsumesAttributeGlobalRoutingTests : ConsumesAttributeTestsBase { - public ConsumesAttributeDispatchingTests(MvcTestFixture fixture) + public ConsumesAttributeGlobalRoutingTests(MvcTestFixture fixture) : base(fixture) { } diff --git a/test/Microsoft.AspNetCore.Mvc.FunctionalTests/DispatchingTests.cs b/test/Microsoft.AspNetCore.Mvc.FunctionalTests/GlobalRoutingTest.cs similarity index 63% rename from test/Microsoft.AspNetCore.Mvc.FunctionalTests/DispatchingTests.cs rename to test/Microsoft.AspNetCore.Mvc.FunctionalTests/GlobalRoutingTest.cs index 05525fc755..1ab9950d68 100644 --- a/test/Microsoft.AspNetCore.Mvc.FunctionalTests/DispatchingTests.cs +++ b/test/Microsoft.AspNetCore.Mvc.FunctionalTests/GlobalRoutingTest.cs @@ -4,39 +4,25 @@ using System; using System.Net; using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc.Internal; -using Microsoft.AspNetCore.Routing; using Newtonsoft.Json; using Xunit; namespace Microsoft.AspNetCore.Mvc.FunctionalTests { - public class DispatchingTests : RoutingTestsBase + public class GlobalRoutingTest : RoutingTestsBase { - public DispatchingTests(MvcTestFixture fixture) + public GlobalRoutingTest(MvcTestFixture fixture) : base(fixture) { } - [Fact(Skip = "Link generation issue in dispatching. Need to fix - https://github.com/aspnet/Routing/issues/590")] - public override Task AttributeRoutedAction_InArea_ExplicitLeaveArea() - { - return Task.CompletedTask; - } - - [Fact(Skip = "Link generation issue in dispatching. Need to fix - https://github.com/aspnet/Routing/issues/590")] + [Fact(Skip = "Link generation issue in global routing. Need to fix - https://github.com/aspnet/Routing/issues/590")] public override Task AttributeRoutedAction_InArea_StaysInArea_ActionDoesntExist() { return Task.CompletedTask; } - [Fact(Skip = "Link generation issue in dispatching. Need to fix - https://github.com/aspnet/Routing/issues/590")] - public override Task ConventionalRoutedAction_InArea_ExplicitLeaveArea() - { - return Task.CompletedTask; - } - - [Fact(Skip = "Link generation issue in dispatching. Need to fix - https://github.com/aspnet/Routing/issues/590")] + [Fact(Skip = "Link generation issue in global routing. Need to fix - https://github.com/aspnet/Routing/issues/590")] public override Task ConventionalRoutedAction_InArea_StaysInArea() { return Task.CompletedTask; diff --git a/test/Microsoft.AspNetCore.Mvc.FunctionalTests/VersioningDispatchingTests.cs b/test/Microsoft.AspNetCore.Mvc.FunctionalTests/RequestServicesGlobalRoutingTest.cs similarity index 55% rename from test/Microsoft.AspNetCore.Mvc.FunctionalTests/VersioningDispatchingTests.cs rename to test/Microsoft.AspNetCore.Mvc.FunctionalTests/RequestServicesGlobalRoutingTest.cs index ff0c8e700c..0c1471df03 100644 --- a/test/Microsoft.AspNetCore.Mvc.FunctionalTests/VersioningDispatchingTests.cs +++ b/test/Microsoft.AspNetCore.Mvc.FunctionalTests/RequestServicesGlobalRoutingTest.cs @@ -3,9 +3,9 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests { - public class VersioningDispatchingTests : VersioningTestsBase + public class RequestServicesGlobalRoutingTest : RequestServicesTestBase { - public VersioningDispatchingTests(MvcTestFixture fixture) + public RequestServicesGlobalRoutingTest(MvcTestFixture fixture) : base(fixture) { } diff --git a/test/Microsoft.AspNetCore.Mvc.FunctionalTests/RequestServicesDispatchingTest.cs b/test/Microsoft.AspNetCore.Mvc.FunctionalTests/VersioningGlobalRoutingTests.cs similarity index 55% rename from test/Microsoft.AspNetCore.Mvc.FunctionalTests/RequestServicesDispatchingTest.cs rename to test/Microsoft.AspNetCore.Mvc.FunctionalTests/VersioningGlobalRoutingTests.cs index f725d9ed92..8c022a076c 100644 --- a/test/Microsoft.AspNetCore.Mvc.FunctionalTests/RequestServicesDispatchingTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.FunctionalTests/VersioningGlobalRoutingTests.cs @@ -3,9 +3,9 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests { - public class RequestServicesDispatchingTest : RequestServicesTestBase + public class VersioningGlobalRoutingTests : VersioningTestsBase { - public RequestServicesDispatchingTest(MvcTestFixture fixture) + public VersioningGlobalRoutingTests(MvcTestFixture fixture) : base(fixture) { } diff --git a/test/Microsoft.AspNetCore.Mvc.TagHelpers.Test/ValidationMessageTagHelperTest.cs b/test/Microsoft.AspNetCore.Mvc.TagHelpers.Test/ValidationMessageTagHelperTest.cs index 69522655cb..1c919635be 100644 --- a/test/Microsoft.AspNetCore.Mvc.TagHelpers.Test/ValidationMessageTagHelperTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.TagHelpers.Test/ValidationMessageTagHelperTest.cs @@ -357,10 +357,11 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers } [Theory] - [InlineData("Content of validation message", "Content of validation message")] - [InlineData("\r\n \r\n", "New HTML")] + [InlineData("Content of validation message", "Content of validation message", "New HTML")] + [InlineData("\r\n \r\n", null, "New HTML")] public async Task ProcessAsync_MergesTagBuilderFromGenerateValidationMessage( string childContent, + string expectedMessage, string expectedOutputContent) { // Arrange @@ -375,7 +376,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers It.IsAny(), It.IsAny(), It.IsAny(), - It.IsAny(), + expectedMessage, It.IsAny(), It.IsAny())) .Returns(tagBuilder); diff --git a/test/WebSites/BasicWebSite/StartupWithDispatching.cs b/test/WebSites/BasicWebSite/StartupWithGlobalRouting.cs similarity index 91% rename from test/WebSites/BasicWebSite/StartupWithDispatching.cs rename to test/WebSites/BasicWebSite/StartupWithGlobalRouting.cs index eb122b7290..037a5312f8 100644 --- a/test/WebSites/BasicWebSite/StartupWithDispatching.cs +++ b/test/WebSites/BasicWebSite/StartupWithGlobalRouting.cs @@ -7,12 +7,12 @@ using Microsoft.Extensions.DependencyInjection; namespace BasicWebSite { - public class StartupWithDispatching + public class StartupWithGlobalRouting { // Set up application services public void ConfigureServices(IServiceCollection services) { - services.AddDispatcher(); + services.AddRouting(); services.AddMvc() .SetCompatibilityVersion(CompatibilityVersion.Latest) @@ -29,7 +29,7 @@ namespace BasicWebSite // Initializes the RequestId service for each request app.UseMiddleware(); - app.UseDispatcher(); + app.UseGlobalRouting(); app.UseMvcWithEndpoint(routes => { diff --git a/test/WebSites/RoutingWebSite/StartupWithDispatching.cs b/test/WebSites/RoutingWebSite/StartupWithGlobalRouting.cs similarity index 77% rename from test/WebSites/RoutingWebSite/StartupWithDispatching.cs rename to test/WebSites/RoutingWebSite/StartupWithGlobalRouting.cs index 670ec5497d..abc0abf4fb 100644 --- a/test/WebSites/RoutingWebSite/StartupWithDispatching.cs +++ b/test/WebSites/RoutingWebSite/StartupWithGlobalRouting.cs @@ -1,27 +1,18 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System; -using System.IO; -using System.Text; using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc.Infrastructure; -using Microsoft.AspNetCore.Mvc.Internal; -using Microsoft.AspNetCore.Routing; -using Microsoft.AspNetCore.Routing.Matchers; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.DependencyInjection.Extensions; -using Microsoft.Extensions.Logging; namespace RoutingWebSite { - public class StartupWithDispatching + public class StartupWithGlobalRouting { // Set up application services public void ConfigureServices(IServiceCollection services) { - services.AddDispatcher(); + services.AddRouting(); services.AddMvc(); @@ -31,7 +22,7 @@ namespace RoutingWebSite public void Configure(IApplicationBuilder app) { - app.UseDispatcher(); + app.UseGlobalRouting(); app.UseMvcWithEndpoint(routes => { diff --git a/test/WebSites/VersioningWebSite/StartupWithDispatching.cs b/test/WebSites/VersioningWebSite/StartupWithGlobalRouting.cs similarity index 89% rename from test/WebSites/VersioningWebSite/StartupWithDispatching.cs rename to test/WebSites/VersioningWebSite/StartupWithGlobalRouting.cs index 164f86550b..c7ea9739f7 100644 --- a/test/WebSites/VersioningWebSite/StartupWithDispatching.cs +++ b/test/WebSites/VersioningWebSite/StartupWithGlobalRouting.cs @@ -9,11 +9,11 @@ using Microsoft.Extensions.DependencyInjection; namespace VersioningWebSite { - public class StartupWithDispatching + public class StartupWithGlobalRouting { public void ConfigureServices(IServiceCollection services) { - services.AddDispatcher(); + services.AddRouting(); // Add MVC services to the services container services.AddMvc(); @@ -24,7 +24,7 @@ namespace VersioningWebSite public void Configure(IApplicationBuilder app) { - app.UseDispatcher(); + app.UseGlobalRouting(); app.UseMvcWithEndpoint(endpoints => {