Skip to content

Commit 039cf9e

Browse files
committed
Make RequestDelegateBuilder public
- Formerly known as MapActionExpressionTreeBuilder
1 parent 7fb760f commit 039cf9e

6 files changed

+52
-43
lines changed

src/Http/Http.Extensions/src/Microsoft.AspNetCore.Http.Extensions.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
</PropertyGroup>
1212

1313
<ItemGroup>
14+
<Compile Include="$(SharedSourceRoot)ObjectMethodExecutor\**\*.cs" />
1415
<Compile Include="..\..\Shared\StreamCopyOperationInternal.cs" Link="StreamCopyOperationInternal.cs" />
1516
</ItemGroup>
1617

src/Http/Http.Extensions/src/PublicAPI.Unshipped.txt

+2
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ Microsoft.AspNetCore.Http.Headers.ResponseHeaders.Set(string! name, object? valu
152152
Microsoft.AspNetCore.Http.Headers.ResponseHeaders.SetCookie.get -> System.Collections.Generic.IList<Microsoft.Net.Http.Headers.SetCookieHeaderValue!>!
153153
Microsoft.AspNetCore.Http.Headers.ResponseHeaders.SetCookie.set -> void
154154
Microsoft.AspNetCore.Http.Headers.ResponseHeaders.SetList<T>(string! name, System.Collections.Generic.IList<T>? values) -> void
155+
Microsoft.AspNetCore.Http.RequestDelegateBuilder
155156
override Microsoft.AspNetCore.Http.Extensions.QueryBuilder.Equals(object? obj) -> bool
156157
override Microsoft.AspNetCore.Http.Extensions.QueryBuilder.ToString() -> string!
157158
static Microsoft.AspNetCore.Http.Extensions.HttpRequestMultipartExtensions.GetMultipartBoundary(this Microsoft.AspNetCore.Http.HttpRequest! request) -> string!
@@ -168,6 +169,7 @@ static Microsoft.AspNetCore.Http.HeaderDictionaryTypeExtensions.AppendList<T>(th
168169
static Microsoft.AspNetCore.Http.HeaderDictionaryTypeExtensions.GetTypedHeaders(this Microsoft.AspNetCore.Http.HttpRequest! request) -> Microsoft.AspNetCore.Http.Headers.RequestHeaders!
169170
static Microsoft.AspNetCore.Http.HeaderDictionaryTypeExtensions.GetTypedHeaders(this Microsoft.AspNetCore.Http.HttpResponse! response) -> Microsoft.AspNetCore.Http.Headers.ResponseHeaders!
170171
static Microsoft.AspNetCore.Http.HttpContextServerVariableExtensions.GetServerVariable(this Microsoft.AspNetCore.Http.HttpContext! context, string! variableName) -> string?
172+
static Microsoft.AspNetCore.Http.RequestDelegateBuilder.BuildRequestDelegate(System.Delegate! action) -> Microsoft.AspNetCore.Http.RequestDelegate!
171173
static Microsoft.AspNetCore.Http.ResponseExtensions.Clear(this Microsoft.AspNetCore.Http.HttpResponse! response) -> void
172174
static Microsoft.AspNetCore.Http.ResponseExtensions.Redirect(this Microsoft.AspNetCore.Http.HttpResponse! response, string! location, bool permanent, bool preserveMethod) -> void
173175
static Microsoft.AspNetCore.Http.SendFileResponseExtensions.SendFileAsync(this Microsoft.AspNetCore.Http.HttpResponse! response, Microsoft.Extensions.FileProviders.IFileInfo! file, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task!

src/Http/Routing/src/Internal/MapActionExpressionTreeBuilder.cs renamed to src/Http/Http.Extensions/src/RequestDelegateBuilder.cs

+17-10
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,26 @@
1111
using System.Reflection;
1212
using System.Threading;
1313
using System.Threading.Tasks;
14-
using Microsoft.AspNetCore.Http;
1514
using Microsoft.AspNetCore.Http.Metadata;
1615
using Microsoft.Extensions.DependencyInjection;
1716
using Microsoft.Extensions.Internal;
1817
using Microsoft.Extensions.Logging;
1918

20-
namespace Microsoft.AspNetCore.Routing.Internal
19+
namespace Microsoft.AspNetCore.Http
2120
{
22-
internal static class MapActionExpressionTreeBuilder
21+
/// <summary>
22+
/// Builds <see cref="RequestDelegate"/> implementations from <see cref="Delegate"/> request handlers.
23+
/// </summary>
24+
public static class RequestDelegateBuilder
2325
{
2426
private static readonly MethodInfo ChangeTypeMethodInfo = GetMethodInfo<Func<object, Type, object>>((value, type) => Convert.ChangeType(value, type, CultureInfo.InvariantCulture));
25-
private static readonly MethodInfo ExecuteTaskOfTMethodInfo = typeof(MapActionExpressionTreeBuilder).GetMethod(nameof(ExecuteTask), BindingFlags.NonPublic | BindingFlags.Static)!;
26-
private static readonly MethodInfo ExecuteTaskOfStringMethodInfo = typeof(MapActionExpressionTreeBuilder).GetMethod(nameof(ExecuteTaskOfString), BindingFlags.NonPublic | BindingFlags.Static)!;
27-
private static readonly MethodInfo ExecuteValueTaskOfTMethodInfo = typeof(MapActionExpressionTreeBuilder).GetMethod(nameof(ExecuteValueTaskOfT), BindingFlags.NonPublic | BindingFlags.Static)!;
28-
private static readonly MethodInfo ExecuteValueTaskMethodInfo = typeof(MapActionExpressionTreeBuilder).GetMethod(nameof(ExecuteValueTask), BindingFlags.NonPublic | BindingFlags.Static)!;
29-
private static readonly MethodInfo ExecuteValueTaskOfStringMethodInfo = typeof(MapActionExpressionTreeBuilder).GetMethod(nameof(ExecuteValueTaskOfString), BindingFlags.NonPublic | BindingFlags.Static)!;
30-
private static readonly MethodInfo ExecuteTaskResultOfTMethodInfo = typeof(MapActionExpressionTreeBuilder).GetMethod(nameof(ExecuteTaskResult), BindingFlags.NonPublic | BindingFlags.Static)!;
31-
private static readonly MethodInfo ExecuteValueResultTaskOfTMethodInfo = typeof(MapActionExpressionTreeBuilder).GetMethod(nameof(ExecuteValueTaskResult), BindingFlags.NonPublic | BindingFlags.Static)!;
27+
private static readonly MethodInfo ExecuteTaskOfTMethodInfo = typeof(RequestDelegateBuilder).GetMethod(nameof(ExecuteTask), BindingFlags.NonPublic | BindingFlags.Static)!;
28+
private static readonly MethodInfo ExecuteTaskOfStringMethodInfo = typeof(RequestDelegateBuilder).GetMethod(nameof(ExecuteTaskOfString), BindingFlags.NonPublic | BindingFlags.Static)!;
29+
private static readonly MethodInfo ExecuteValueTaskOfTMethodInfo = typeof(RequestDelegateBuilder).GetMethod(nameof(ExecuteValueTaskOfT), BindingFlags.NonPublic | BindingFlags.Static)!;
30+
private static readonly MethodInfo ExecuteValueTaskMethodInfo = typeof(RequestDelegateBuilder).GetMethod(nameof(ExecuteValueTask), BindingFlags.NonPublic | BindingFlags.Static)!;
31+
private static readonly MethodInfo ExecuteValueTaskOfStringMethodInfo = typeof(RequestDelegateBuilder).GetMethod(nameof(ExecuteValueTaskOfString), BindingFlags.NonPublic | BindingFlags.Static)!;
32+
private static readonly MethodInfo ExecuteTaskResultOfTMethodInfo = typeof(RequestDelegateBuilder).GetMethod(nameof(ExecuteTaskResult), BindingFlags.NonPublic | BindingFlags.Static)!;
33+
private static readonly MethodInfo ExecuteValueResultTaskOfTMethodInfo = typeof(RequestDelegateBuilder).GetMethod(nameof(ExecuteValueTaskResult), BindingFlags.NonPublic | BindingFlags.Static)!;
3234
private static readonly MethodInfo GetRequiredServiceMethodInfo = typeof(ServiceProviderServiceExtensions).GetMethod(nameof(ServiceProviderServiceExtensions.GetRequiredService), BindingFlags.Public | BindingFlags.Static, new Type[] { typeof(IServiceProvider) })!;
3335
private static readonly MethodInfo ResultWriteResponseAsync = typeof(IResult).GetMethod(nameof(IResult.ExecuteAsync), BindingFlags.Public | BindingFlags.Instance)!;
3436
private static readonly MethodInfo StringResultWriteResponseAsync = GetMethodInfo<Func<HttpResponse, string, Task>>((response, text) => HttpResponseWritingExtensions.WriteAsync(response, text, default));
@@ -44,6 +46,11 @@ internal static class MapActionExpressionTreeBuilder
4446
private static readonly MemberExpression HttpResponseExpr = Expression.Property(HttpContextParameter, nameof(HttpContext.Response));
4547
private static readonly MemberExpression RequestAbortedExpr = Expression.Property(HttpContextParameter, nameof(HttpContext.RequestAborted));
4648

49+
/// <summary>
50+
/// Builds a <see cref="RequestDelegate"/> implementation for <paramref name="action"/>.
51+
/// </summary>
52+
/// <param name="action">A request handler with any number of custom parameters that often produces a response with its return value.</param>
53+
/// <returns>The <see cref="RequestDelegate"/></returns>
4754
public static RequestDelegate BuildRequestDelegate(Delegate action)
4855
{
4956
// Non void return type

0 commit comments

Comments
 (0)