diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Builder/MvcApplicationBuilderExtensions.cs b/src/Microsoft.AspNetCore.Mvc.Core/Builder/MvcApplicationBuilderExtensions.cs index 0b190b0231..ab4b465492 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/Builder/MvcApplicationBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/Builder/MvcApplicationBuilderExtensions.cs @@ -18,8 +18,8 @@ namespace Microsoft.AspNetCore.Builder /// public static class MvcApplicationBuilderExtensions { - // Property key set in routing package by UseGlobalRouting to indicate middleware is registered - private const string GlobalRoutingRegisteredKey = "__GlobalRoutingMiddlewareRegistered"; + // Property key set in routing package by UseEndpointRouting to indicate middleware is registered + private const string EndpointRoutingRegisteredKey = "__EndpointRoutingMiddlewareRegistered"; /// /// Adds MVC to the request execution pipeline. @@ -86,7 +86,7 @@ namespace Microsoft.AspNetCore.Builder var options = app.ApplicationServices.GetRequiredService>(); - if (options.Value.EnableGlobalRouting) + if (options.Value.EnableEndpointRouting) { var mvcEndpointDataSource = app.ApplicationServices .GetRequiredService>() @@ -121,7 +121,7 @@ namespace Microsoft.AspNetCore.Builder } } - if (!app.Properties.TryGetValue(GlobalRoutingRegisteredKey, out _)) + if (!app.Properties.TryGetValue(EndpointRoutingRegisteredKey, out _)) { // Matching middleware has not been registered yet // For back-compat register middleware so an endpoint is matched and then immediately used diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Infrastructure/MvcOptionsConfigureCompatibilityOptions.cs b/src/Microsoft.AspNetCore.Mvc.Core/Infrastructure/MvcOptionsConfigureCompatibilityOptions.cs index 28fd0605e7..76e3a16916 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/Infrastructure/MvcOptionsConfigureCompatibilityOptions.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/Infrastructure/MvcOptionsConfigureCompatibilityOptions.cs @@ -34,7 +34,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure if (Version >= CompatibilityVersion.Version_2_2) { - values[nameof(MvcOptions.EnableGlobalRouting)] = true; + values[nameof(MvcOptions.EnableEndpointRouting)] = true; } return values; diff --git a/src/Microsoft.AspNetCore.Mvc.Core/MvcOptions.cs b/src/Microsoft.AspNetCore.Mvc.Core/MvcOptions.cs index e87ddb2678..b3fa3e3745 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/MvcOptions.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/MvcOptions.cs @@ -30,7 +30,7 @@ namespace Microsoft.AspNetCore.Mvc private readonly CompatibilitySwitch _allowValidatingTopLevelNodes; private readonly CompatibilitySwitch _inputFormatterExceptionPolicy; private readonly CompatibilitySwitch _suppressBindingUndefinedValueToEnumType; - private readonly CompatibilitySwitch _enableGlobalRouting; + private readonly CompatibilitySwitch _enableEndpointRouting; private readonly ICompatibilitySwitch[] _switches; /// @@ -55,7 +55,7 @@ namespace Microsoft.AspNetCore.Mvc _allowValidatingTopLevelNodes = new CompatibilitySwitch(nameof(AllowValidatingTopLevelNodes)); _inputFormatterExceptionPolicy = new CompatibilitySwitch(nameof(InputFormatterExceptionPolicy), InputFormatterExceptionPolicy.AllExceptions); _suppressBindingUndefinedValueToEnumType = new CompatibilitySwitch(nameof(SuppressBindingUndefinedValueToEnumType)); - _enableGlobalRouting = new CompatibilitySwitch(nameof(EnableGlobalRouting)); + _enableEndpointRouting = new CompatibilitySwitch(nameof(EnableEndpointRouting)); _switches = new ICompatibilitySwitch[] { @@ -64,15 +64,22 @@ namespace Microsoft.AspNetCore.Mvc _allowValidatingTopLevelNodes, _inputFormatterExceptionPolicy, _suppressBindingUndefinedValueToEnumType, - _enableGlobalRouting, + _enableEndpointRouting, }; } - // REVIEW: Add documentation + // REVIEW: Remove once web hooks is using EnableEndpointRouting public bool EnableGlobalRouting { - get => _enableGlobalRouting.Value; - set => _enableGlobalRouting.Value = value; + get => EnableEndpointRouting; + set => EnableEndpointRouting = value; + } + + // REVIEW: Add documentation + public bool EnableEndpointRouting + { + get => _enableEndpointRouting.Value; + set => _enableEndpointRouting.Value = value; } /// diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Routing/GlobalRoutingUrlHelper.cs b/src/Microsoft.AspNetCore.Mvc.Core/Routing/EndpointRoutingUrlHelper.cs similarity index 94% rename from src/Microsoft.AspNetCore.Mvc.Core/Routing/GlobalRoutingUrlHelper.cs rename to src/Microsoft.AspNetCore.Mvc.Core/Routing/EndpointRoutingUrlHelper.cs index 13dd697fce..27590902e9 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/Routing/GlobalRoutingUrlHelper.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/Routing/EndpointRoutingUrlHelper.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 GlobalRoutingUrlHelper : UrlHelperBase + internal class EndpointRoutingUrlHelper : 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 GlobalRoutingUrlHelper( + public EndpointRoutingUrlHelper( 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 6db7f35638..b6c5acfdf4 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 GlobalRoutingUrlHelper( + urlHelper = new EndpointRoutingUrlHelper( context, routeValuesBasedEndpointFinder, linkGenerator, diff --git a/test/Microsoft.AspNetCore.Mvc.Core.Test/Builder/MvcApplicationBuilderExtensionsTest.cs b/test/Microsoft.AspNetCore.Mvc.Core.Test/Builder/MvcApplicationBuilderExtensionsTest.cs index 8e4c7820f6..39fd3847db 100644 --- a/test/Microsoft.AspNetCore.Mvc.Core.Test/Builder/MvcApplicationBuilderExtensionsTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Core.Test/Builder/MvcApplicationBuilderExtensionsTest.cs @@ -58,13 +58,13 @@ namespace Microsoft.AspNetCore.Mvc.Core.Builder } [Fact] - public void UseMvc_GlobalRoutingDisabled_NoEndpointInfos() + public void UseMvc_EndpointRoutingDisabled_NoEndpointInfos() { // Arrange var services = new ServiceCollection(); services.AddSingleton(new DiagnosticListener("Microsoft.AspNetCore")); services.AddLogging(); - services.AddMvcCore(o => o.EnableGlobalRouting = false); + services.AddMvcCore(o => o.EnableEndpointRouting = false); var serviceProvider = services.BuildServiceProvider(); var appBuilder = new ApplicationBuilder(serviceProvider); @@ -85,13 +85,13 @@ namespace Microsoft.AspNetCore.Mvc.Core.Builder } [Fact] - public void UseMvc_GlobalRoutingEnabled_NoEndpointInfos() + public void UseMvc_EndpointRoutingEnabled_NoEndpointInfos() { // Arrange var services = new ServiceCollection(); services.AddSingleton(new DiagnosticListener("Microsoft.AspNetCore")); services.AddLogging(); - services.AddMvcCore(o => o.EnableGlobalRouting = true); + services.AddMvcCore(o => o.EnableEndpointRouting = true); var serviceProvider = services.BuildServiceProvider(); var appBuilder = new ApplicationBuilder(serviceProvider); diff --git a/test/Microsoft.AspNetCore.Mvc.Core.Test/Routing/GlobalRoutingUrlHelperTest.cs b/test/Microsoft.AspNetCore.Mvc.Core.Test/Routing/EndpointRoutingUrlHelperTest.cs similarity index 99% rename from test/Microsoft.AspNetCore.Mvc.Core.Test/Routing/GlobalRoutingUrlHelperTest.cs rename to test/Microsoft.AspNetCore.Mvc.Core.Test/Routing/EndpointRoutingUrlHelperTest.cs index 4c59c5b104..faa0eebf0c 100644 --- a/test/Microsoft.AspNetCore.Mvc.Core.Test/Routing/GlobalRoutingUrlHelperTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Core.Test/Routing/EndpointRoutingUrlHelperTest.cs @@ -14,7 +14,7 @@ using Xunit; namespace Microsoft.AspNetCore.Mvc.Routing { - public class GlobalRoutingUrlHelperTest : UrlHelperTestBase + public class EndpointRoutingUrlHelperTest : UrlHelperTestBase { [Fact] public void RouteUrl_WithRouteName_GeneratesUrl_UsingDefaults() @@ -155,7 +155,7 @@ namespace Microsoft.AspNetCore.Mvc.Routing var urlHelperFactory = httpContext.RequestServices.GetRequiredService(); var urlHelper = urlHelperFactory.GetUrlHelper(actionContext); - Assert.IsType(urlHelper); + Assert.IsType(urlHelper); return urlHelper; } diff --git a/test/Microsoft.AspNetCore.Mvc.FunctionalTests/ConsumesAttributeGlobalRoutingTests.cs b/test/Microsoft.AspNetCore.Mvc.FunctionalTests/ConsumesAttributeEndpointRoutingTests.cs similarity index 77% rename from test/Microsoft.AspNetCore.Mvc.FunctionalTests/ConsumesAttributeGlobalRoutingTests.cs rename to test/Microsoft.AspNetCore.Mvc.FunctionalTests/ConsumesAttributeEndpointRoutingTests.cs index 1683864c17..7377442ac6 100644 --- a/test/Microsoft.AspNetCore.Mvc.FunctionalTests/ConsumesAttributeGlobalRoutingTests.cs +++ b/test/Microsoft.AspNetCore.Mvc.FunctionalTests/ConsumesAttributeEndpointRoutingTests.cs @@ -8,9 +8,9 @@ using Xunit; namespace Microsoft.AspNetCore.Mvc.FunctionalTests { - public class ConsumesAttributeGlobalRoutingTests : ConsumesAttributeTestsBase + public class ConsumesAttributeEndpointRoutingTests : ConsumesAttributeTestsBase { - public ConsumesAttributeGlobalRoutingTests(MvcTestFixture fixture) + public ConsumesAttributeEndpointRoutingTests(MvcTestFixture fixture) : base(fixture) { } diff --git a/test/Microsoft.AspNetCore.Mvc.FunctionalTests/CorsDispatchingTests.cs b/test/Microsoft.AspNetCore.Mvc.FunctionalTests/CorsEndpointRoutingTests.cs similarity index 84% rename from test/Microsoft.AspNetCore.Mvc.FunctionalTests/CorsDispatchingTests.cs rename to test/Microsoft.AspNetCore.Mvc.FunctionalTests/CorsEndpointRoutingTests.cs index f5281eee9e..b64655c4d9 100644 --- a/test/Microsoft.AspNetCore.Mvc.FunctionalTests/CorsDispatchingTests.cs +++ b/test/Microsoft.AspNetCore.Mvc.FunctionalTests/CorsEndpointRoutingTests.cs @@ -9,9 +9,9 @@ using Xunit; namespace Microsoft.AspNetCore.Mvc.FunctionalTests { - public class CorsGlobalRoutingTests : CorsTestsBase + public class CorsEndpointRoutingTests : CorsTestsBase { - public CorsGlobalRoutingTests(MvcTestFixture fixture) + public CorsEndpointRoutingTests(MvcTestFixture fixture) : base(fixture) { } diff --git a/test/Microsoft.AspNetCore.Mvc.FunctionalTests/GlobalRoutingTest.cs b/test/Microsoft.AspNetCore.Mvc.FunctionalTests/EndpointRoutingTest.cs similarity index 96% rename from test/Microsoft.AspNetCore.Mvc.FunctionalTests/GlobalRoutingTest.cs rename to test/Microsoft.AspNetCore.Mvc.FunctionalTests/EndpointRoutingTest.cs index 6266e2b9b2..f6b03f55cf 100644 --- a/test/Microsoft.AspNetCore.Mvc.FunctionalTests/GlobalRoutingTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.FunctionalTests/EndpointRoutingTest.cs @@ -10,9 +10,9 @@ using Xunit; namespace Microsoft.AspNetCore.Mvc.FunctionalTests { - public class GlobalRoutingTest : RoutingTestsBase + public class EndpointRoutingTest : RoutingTestsBase { - public GlobalRoutingTest(MvcTestFixture fixture) + public EndpointRoutingTest(MvcTestFixture fixture) : base(fixture) { } diff --git a/test/Microsoft.AspNetCore.Mvc.FunctionalTests/RequestServicesGlobalRoutingTest.cs b/test/Microsoft.AspNetCore.Mvc.FunctionalTests/RequestServicesEndpointRoutingTest.cs similarity index 78% rename from test/Microsoft.AspNetCore.Mvc.FunctionalTests/RequestServicesGlobalRoutingTest.cs rename to test/Microsoft.AspNetCore.Mvc.FunctionalTests/RequestServicesEndpointRoutingTest.cs index 0ca18c250e..91cba5aeb5 100644 --- a/test/Microsoft.AspNetCore.Mvc.FunctionalTests/RequestServicesGlobalRoutingTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.FunctionalTests/RequestServicesEndpointRoutingTest.cs @@ -8,9 +8,9 @@ using Xunit; namespace Microsoft.AspNetCore.Mvc.FunctionalTests { - public class RequestServicesGlobalRoutingTest : RequestServicesTestBase + public class RequestServicesEndpointRoutingTest : RequestServicesTestBase { - public RequestServicesGlobalRoutingTest(MvcTestFixture fixture) + public RequestServicesEndpointRoutingTest(MvcTestFixture fixture) : base(fixture) { } diff --git a/test/Microsoft.AspNetCore.Mvc.FunctionalTests/VersioningGlobalRoutingTests.cs b/test/Microsoft.AspNetCore.Mvc.FunctionalTests/VersioningEndpointRoutingTests.cs similarity index 92% rename from test/Microsoft.AspNetCore.Mvc.FunctionalTests/VersioningGlobalRoutingTests.cs rename to test/Microsoft.AspNetCore.Mvc.FunctionalTests/VersioningEndpointRoutingTests.cs index 69af08c14b..2aeb0d2490 100644 --- a/test/Microsoft.AspNetCore.Mvc.FunctionalTests/VersioningGlobalRoutingTests.cs +++ b/test/Microsoft.AspNetCore.Mvc.FunctionalTests/VersioningEndpointRoutingTests.cs @@ -9,9 +9,9 @@ using Xunit; namespace Microsoft.AspNetCore.Mvc.FunctionalTests { - public class VersioningGlobalRoutingTests : VersioningTestsBase + public class VersioningEndpointRoutingTests : VersioningTestsBase { - public VersioningGlobalRoutingTests(MvcTestFixture fixture) + public VersioningEndpointRoutingTests(MvcTestFixture fixture) : base(fixture) { } diff --git a/test/Microsoft.AspNetCore.Mvc.Test/IntegrationTest/CompatibilitySwitchIntegrationTest.cs b/test/Microsoft.AspNetCore.Mvc.Test/IntegrationTest/CompatibilitySwitchIntegrationTest.cs index 78f8ddb4ae..858dcdf26d 100644 --- a/test/Microsoft.AspNetCore.Mvc.Test/IntegrationTest/CompatibilitySwitchIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Test/IntegrationTest/CompatibilitySwitchIntegrationTest.cs @@ -39,7 +39,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTest Assert.Equal(InputFormatterExceptionPolicy.AllExceptions, mvcOptions.InputFormatterExceptionPolicy); Assert.False(jsonOptions.AllowInputFormatterExceptionMessages); Assert.False(razorPagesOptions.AllowAreas); - Assert.False(mvcOptions.EnableGlobalRouting); + Assert.False(mvcOptions.EnableEndpointRouting); } [Fact] @@ -64,7 +64,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTest Assert.Equal(InputFormatterExceptionPolicy.MalformedInputExceptions, mvcOptions.InputFormatterExceptionPolicy); Assert.True(jsonOptions.AllowInputFormatterExceptionMessages); Assert.True(razorPagesOptions.AllowAreas); - Assert.False(mvcOptions.EnableGlobalRouting); + Assert.False(mvcOptions.EnableEndpointRouting); } [Fact] @@ -89,7 +89,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTest Assert.Equal(InputFormatterExceptionPolicy.MalformedInputExceptions, mvcOptions.InputFormatterExceptionPolicy); Assert.True(jsonOptions.AllowInputFormatterExceptionMessages); Assert.True(razorPagesOptions.AllowAreas); - Assert.True(mvcOptions.EnableGlobalRouting); + Assert.True(mvcOptions.EnableEndpointRouting); } [Fact] @@ -114,7 +114,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTest Assert.Equal(InputFormatterExceptionPolicy.MalformedInputExceptions, mvcOptions.InputFormatterExceptionPolicy); Assert.True(jsonOptions.AllowInputFormatterExceptionMessages); Assert.True(razorPagesOptions.AllowAreas); - Assert.True(mvcOptions.EnableGlobalRouting); + Assert.True(mvcOptions.EnableEndpointRouting); } // This just does the minimum needed to be able to resolve these options. diff --git a/test/WebSites/BasicWebSite/Startup.cs b/test/WebSites/BasicWebSite/Startup.cs index c6e406fb34..1c3218266e 100644 --- a/test/WebSites/BasicWebSite/Startup.cs +++ b/test/WebSites/BasicWebSite/Startup.cs @@ -28,7 +28,7 @@ namespace BasicWebSite options.Filters.Add(new TraceResourceFilter()); // Remove when all URL generation tests are passing - https://github.com/aspnet/Routing/issues/590 - options.EnableGlobalRouting = false; + options.EnableEndpointRouting = false; }) .SetCompatibilityVersion(CompatibilityVersion.Latest) .AddXmlDataContractSerializerFormatters(); diff --git a/test/WebSites/BasicWebSite/StartupWithGlobalRouting.cs b/test/WebSites/BasicWebSite/StartupWithEndpointRouting.cs similarity index 94% rename from test/WebSites/BasicWebSite/StartupWithGlobalRouting.cs rename to test/WebSites/BasicWebSite/StartupWithEndpointRouting.cs index d3a540a86c..fca926df52 100644 --- a/test/WebSites/BasicWebSite/StartupWithGlobalRouting.cs +++ b/test/WebSites/BasicWebSite/StartupWithEndpointRouting.cs @@ -7,7 +7,7 @@ using Microsoft.Extensions.DependencyInjection; namespace BasicWebSite { - public class StartupWithGlobalRouting + public class StartupWithEndpointRouting { // Set up application services public void ConfigureServices(IServiceCollection services) @@ -29,8 +29,6 @@ namespace BasicWebSite // Initializes the RequestId service for each request app.UseMiddleware(); - app.UseGlobalRouting(); - app.UseMvc(routes => { routes.MapRoute( diff --git a/test/WebSites/CorsWebSite/StartupWithGlobalRouting.cs b/test/WebSites/CorsWebSite/StartupWithEndpointRouting.cs similarity index 95% rename from test/WebSites/CorsWebSite/StartupWithGlobalRouting.cs rename to test/WebSites/CorsWebSite/StartupWithEndpointRouting.cs index f9e2a744c7..c620d62a58 100644 --- a/test/WebSites/CorsWebSite/StartupWithGlobalRouting.cs +++ b/test/WebSites/CorsWebSite/StartupWithEndpointRouting.cs @@ -9,11 +9,11 @@ using Microsoft.Extensions.DependencyInjection; namespace CorsWebSite { - public class StartupWithGlobalRouting + public class StartupWithEndpointRouting { public void ConfigureServices(IServiceCollection services) { - services.AddMvc(options => options.EnableGlobalRouting = true); + services.AddMvc(options => options.EnableEndpointRouting = true); services.Configure(options => { options.AddPolicy( diff --git a/test/WebSites/RoutingWebSite/StartupWithGlobalRouting.cs b/test/WebSites/RoutingWebSite/StartupWithEndpointRouting.cs similarity index 91% rename from test/WebSites/RoutingWebSite/StartupWithGlobalRouting.cs rename to test/WebSites/RoutingWebSite/StartupWithEndpointRouting.cs index 62a84f5ecb..16bc62d81f 100644 --- a/test/WebSites/RoutingWebSite/StartupWithGlobalRouting.cs +++ b/test/WebSites/RoutingWebSite/StartupWithEndpointRouting.cs @@ -7,13 +7,13 @@ using Microsoft.Extensions.DependencyInjection; namespace RoutingWebSite { - public class StartupWithGlobalRouting + public class StartupWithEndpointRouting { // Set up application services public void ConfigureServices(IServiceCollection services) { services.AddMvc() - .AddMvcOptions(options => options.EnableGlobalRouting = true); + .AddMvcOptions(options => options.EnableEndpointRouting = true); services.AddScoped(); services.AddSingleton(); diff --git a/test/WebSites/VersioningWebSite/StartupWithGlobalRouting.cs b/test/WebSites/VersioningWebSite/StartupWithEndpointRouting.cs similarity index 86% rename from test/WebSites/VersioningWebSite/StartupWithGlobalRouting.cs rename to test/WebSites/VersioningWebSite/StartupWithEndpointRouting.cs index 249aefabd4..9c72888db9 100644 --- a/test/WebSites/VersioningWebSite/StartupWithGlobalRouting.cs +++ b/test/WebSites/VersioningWebSite/StartupWithEndpointRouting.cs @@ -9,13 +9,13 @@ using Microsoft.Extensions.DependencyInjection; namespace VersioningWebSite { - public class StartupWithGlobalRouting + public class StartupWithEndpointRouting { public void ConfigureServices(IServiceCollection services) { // Add MVC services to the services container services.AddMvc() - .AddMvcOptions(options => options.EnableGlobalRouting = true); + .AddMvcOptions(options => options.EnableEndpointRouting = true); services.AddScoped(); services.AddSingleton();