From e937a993fbe26d0e895bc4a59e24b2241be862c7 Mon Sep 17 00:00:00 2001 From: Artak Mkrtchyan Date: Thu, 30 Jan 2025 11:14:36 -0800 Subject: [PATCH] Reuse the InertEndpointBuilder defined in the ApplicationEndpointFactory --- .../DefaultApplicationModelProvider.cs | 9 --------- .../Mvc.Core/src/Routing/ActionEndpointFactory.cs | 8 -------- .../Mvc.Core/src/Routing/InertEndpointBuilder.cs | 15 +++++++++++++++ 3 files changed, 15 insertions(+), 17 deletions(-) create mode 100644 src/Mvc/Mvc.Core/src/Routing/InertEndpointBuilder.cs diff --git a/src/Mvc/Mvc.Core/src/ApplicationModels/DefaultApplicationModelProvider.cs b/src/Mvc/Mvc.Core/src/ApplicationModels/DefaultApplicationModelProvider.cs index d299c6802f6c6..49a162ca31ec0 100644 --- a/src/Mvc/Mvc.Core/src/ApplicationModels/DefaultApplicationModelProvider.cs +++ b/src/Mvc/Mvc.Core/src/ApplicationModels/DefaultApplicationModelProvider.cs @@ -3,7 +3,6 @@ using System.Linq; using System.Reflection; -using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Metadata; using Microsoft.AspNetCore.Mvc.ActionConstraints; @@ -709,12 +708,4 @@ private static void AddRange(IList list, IEnumerable items) list.Add(item); } } - - private sealed class InertEndpointBuilder : EndpointBuilder - { - public override Endpoint Build() - { - return new Endpoint(RequestDelegate, new EndpointMetadataCollection(Metadata), DisplayName); - } - } } diff --git a/src/Mvc/Mvc.Core/src/Routing/ActionEndpointFactory.cs b/src/Mvc/Mvc.Core/src/Routing/ActionEndpointFactory.cs index 6b46d0a62bca4..3b803e72e340c 100644 --- a/src/Mvc/Mvc.Core/src/Routing/ActionEndpointFactory.cs +++ b/src/Mvc/Mvc.Core/src/Routing/ActionEndpointFactory.cs @@ -543,12 +543,4 @@ private static RequestDelegate CreateRequestDelegate() return invoker!.InvokeAsync(); }; } - - private sealed class InertEndpointBuilder : EndpointBuilder - { - public override Endpoint Build() - { - return new Endpoint(RequestDelegate, new EndpointMetadataCollection(Metadata), DisplayName); - } - } } diff --git a/src/Mvc/Mvc.Core/src/Routing/InertEndpointBuilder.cs b/src/Mvc/Mvc.Core/src/Routing/InertEndpointBuilder.cs new file mode 100644 index 0000000000000..b37312e5be924 --- /dev/null +++ b/src/Mvc/Mvc.Core/src/Routing/InertEndpointBuilder.cs @@ -0,0 +1,15 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; + +namespace Microsoft.AspNetCore.Mvc.Routing; + +internal sealed class InertEndpointBuilder : EndpointBuilder +{ + public override Endpoint Build() + { + return new Endpoint(RequestDelegate, new EndpointMetadataCollection(Metadata), DisplayName); + } +}