Skip to content

Commit 2977dd0

Browse files
committed
Build -> Create
1 parent 5afa1a5 commit 2977dd0

File tree

4 files changed

+42
-42
lines changed

4 files changed

+42
-42
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,9 @@ static Microsoft.AspNetCore.Http.HeaderDictionaryTypeExtensions.AppendList<T>(th
169169
static Microsoft.AspNetCore.Http.HeaderDictionaryTypeExtensions.GetTypedHeaders(this Microsoft.AspNetCore.Http.HttpRequest! request) -> Microsoft.AspNetCore.Http.Headers.RequestHeaders!
170170
static Microsoft.AspNetCore.Http.HeaderDictionaryTypeExtensions.GetTypedHeaders(this Microsoft.AspNetCore.Http.HttpResponse! response) -> Microsoft.AspNetCore.Http.Headers.ResponseHeaders!
171171
static Microsoft.AspNetCore.Http.HttpContextServerVariableExtensions.GetServerVariable(this Microsoft.AspNetCore.Http.HttpContext! context, string! variableName) -> string?
172-
static Microsoft.AspNetCore.Http.RequestDelegateFactory.Build(System.Delegate! action) -> Microsoft.AspNetCore.Http.RequestDelegate!
173-
static Microsoft.AspNetCore.Http.RequestDelegateFactory.Build(System.Reflection.MethodInfo! methodInfo) -> Microsoft.AspNetCore.Http.RequestDelegate!
174-
static Microsoft.AspNetCore.Http.RequestDelegateFactory.Build(System.Reflection.MethodInfo! methodInfo, System.Func<Microsoft.AspNetCore.Http.HttpContext!, object!>! targetFactory) -> Microsoft.AspNetCore.Http.RequestDelegate!
172+
static Microsoft.AspNetCore.Http.RequestDelegateFactory.Create(System.Delegate! action) -> Microsoft.AspNetCore.Http.RequestDelegate!
173+
static Microsoft.AspNetCore.Http.RequestDelegateFactory.Create(System.Reflection.MethodInfo! methodInfo) -> Microsoft.AspNetCore.Http.RequestDelegate!
174+
static Microsoft.AspNetCore.Http.RequestDelegateFactory.Create(System.Reflection.MethodInfo! methodInfo, System.Func<Microsoft.AspNetCore.Http.HttpContext!, object!>! targetFactory) -> Microsoft.AspNetCore.Http.RequestDelegate!
175175
static Microsoft.AspNetCore.Http.ResponseExtensions.Clear(this Microsoft.AspNetCore.Http.HttpResponse! response) -> void
176176
static Microsoft.AspNetCore.Http.ResponseExtensions.Redirect(this Microsoft.AspNetCore.Http.HttpResponse! response, string! location, bool permanent, bool preserveMethod) -> void
177177
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/Http.Extensions/src/RequestDelegateFactory.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public static class RequestDelegateFactory
5151
/// </summary>
5252
/// <param name="action">A request handler with any number of custom parameters that often produces a response with its return value.</param>
5353
/// <returns>The <see cref="RequestDelegate"/></returns>
54-
public static RequestDelegate Build(Delegate action)
54+
public static RequestDelegate Create(Delegate action)
5555
{
5656
if (action is null)
5757
{
@@ -77,7 +77,7 @@ public static RequestDelegate Build(Delegate action)
7777
/// </summary>
7878
/// <param name="methodInfo">A static request handler with any number of custom parameters that often produces a response with its return value.</param>
7979
/// <returns>The <see cref="RequestDelegate"/></returns>
80-
public static RequestDelegate Build(MethodInfo methodInfo)
80+
public static RequestDelegate Create(MethodInfo methodInfo)
8181
{
8282
if (methodInfo is null)
8383
{
@@ -98,7 +98,7 @@ public static RequestDelegate Build(MethodInfo methodInfo)
9898
/// <param name="methodInfo">A request handler with any number of custom parameters that often produces a response with its return value.</param>
9999
/// <param name="targetFactory">Creates the <see langword="this"/> for the non-static method.</param>
100100
/// <returns>The <see cref="RequestDelegate"/></returns>
101-
public static RequestDelegate Build(MethodInfo methodInfo, Func<HttpContext, object> targetFactory)
101+
public static RequestDelegate Create(MethodInfo methodInfo, Func<HttpContext, object> targetFactory)
102102
{
103103
if (methodInfo is null)
104104
{

src/Http/Http.Extensions/test/RequestDelegateFactoryTests.cs

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public async Task RequestDelegateInvokesAction(Delegate @delegate)
8686
{
8787
var httpContext = new DefaultHttpContext();
8888

89-
var requestDelegate = RequestDelegateFactory.Build(@delegate);
89+
var requestDelegate = RequestDelegateFactory.Create(@delegate);
9090

9191
await requestDelegate(httpContext);
9292

@@ -106,7 +106,7 @@ public async Task StaticMethodInfoOverloadWorksWithBasicReflection()
106106
BindingFlags.NonPublic | BindingFlags.Static,
107107
new[] { typeof(HttpContext) });
108108

109-
var requestDelegate = RequestDelegateFactory.Build(methodInfo!);
109+
var requestDelegate = RequestDelegateFactory.Create(methodInfo!);
110110

111111
var httpContext = new DefaultHttpContext();
112112

@@ -151,7 +151,7 @@ object GetTarget()
151151
return new TestNonStaticActionClass(2);
152152
}
153153

154-
var requestDelegate = RequestDelegateFactory.Build(methodInfo!, _ => GetTarget());
154+
var requestDelegate = RequestDelegateFactory.Create(methodInfo!, _ => GetTarget());
155155

156156
var httpContext = new DefaultHttpContext();
157157

@@ -174,10 +174,10 @@ public void BuildRequestDelegateThrowsArgumentNullExceptions()
174174
BindingFlags.NonPublic | BindingFlags.Static,
175175
new[] { typeof(HttpContext) });
176176

177-
var exNullAction = Assert.Throws<ArgumentNullException>(() => RequestDelegateFactory.Build(action: null!));
178-
var exNullMethodInfo1 = Assert.Throws<ArgumentNullException>(() => RequestDelegateFactory.Build(methodInfo: null!));
179-
var exNullMethodInfo2 = Assert.Throws<ArgumentNullException>(() => RequestDelegateFactory.Build(methodInfo: null!, _ => 0));
180-
var exNullTargetFactory = Assert.Throws<ArgumentNullException>(() => RequestDelegateFactory.Build(methodInfo!, targetFactory: null!));
177+
var exNullAction = Assert.Throws<ArgumentNullException>(() => RequestDelegateFactory.Create(action: null!));
178+
var exNullMethodInfo1 = Assert.Throws<ArgumentNullException>(() => RequestDelegateFactory.Create(methodInfo: null!));
179+
var exNullMethodInfo2 = Assert.Throws<ArgumentNullException>(() => RequestDelegateFactory.Create(methodInfo: null!, _ => 0));
180+
var exNullTargetFactory = Assert.Throws<ArgumentNullException>(() => RequestDelegateFactory.Create(methodInfo!, targetFactory: null!));
181181

182182
Assert.Equal("action", exNullAction.ParamName);
183183
Assert.Equal("methodInfo", exNullMethodInfo1.ParamName);
@@ -229,7 +229,7 @@ public async Task RequestDelegatePopulatesFromRouteParameterBasedOnParameterName
229229
var httpContext = new DefaultHttpContext();
230230
httpContext.Request.RouteValues[paramName] = originalRouteParam.ToString(NumberFormatInfo.InvariantInfo);
231231

232-
var requestDelegate = RequestDelegateFactory.Build(@delegate);
232+
var requestDelegate = RequestDelegateFactory.Create(@delegate);
233233

234234
await requestDelegate(httpContext);
235235

@@ -272,7 +272,7 @@ public async Task RequestDelegatePopulatesFromRouteOptionalParameter(Delegate @d
272272
{
273273
var httpContext = new DefaultHttpContext();
274274

275-
var requestDelegate = RequestDelegateFactory.Build(@delegate);
275+
var requestDelegate = RequestDelegateFactory.Create(@delegate);
276276

277277
await requestDelegate(httpContext);
278278

@@ -290,7 +290,7 @@ public async Task RequestDelegatePopulatesFromRouteOptionalParameterBasedOnParam
290290

291291
httpContext.Request.RouteValues[paramName] = originalRouteParam.ToString(NumberFormatInfo.InvariantInfo);
292292

293-
var requestDelegate = RequestDelegateFactory.Build(@delegate);
293+
var requestDelegate = RequestDelegateFactory.Create(@delegate);
294294

295295
await requestDelegate(httpContext);
296296

@@ -313,7 +313,7 @@ void TestAction([FromRoute(Name = specifiedName)] int foo)
313313
var httpContext = new DefaultHttpContext();
314314
httpContext.Request.RouteValues[specifiedName] = originalRouteParam.ToString(NumberFormatInfo.InvariantInfo);
315315

316-
var requestDelegate = RequestDelegateFactory.Build((Action<int>)TestAction);
316+
var requestDelegate = RequestDelegateFactory.Create((Action<int>)TestAction);
317317

318318
await requestDelegate(httpContext);
319319

@@ -336,7 +336,7 @@ void TestAction([FromRoute] int foo)
336336
var httpContext = new DefaultHttpContext();
337337
httpContext.Request.RouteValues[unmatchedName] = unmatchedRouteParam.ToString(NumberFormatInfo.InvariantInfo);
338338

339-
var requestDelegate = RequestDelegateFactory.Build((Action<int>)TestAction);
339+
var requestDelegate = RequestDelegateFactory.Create((Action<int>)TestAction);
340340

341341
await requestDelegate(httpContext);
342342

@@ -364,7 +364,7 @@ void TestAction([FromQuery] int value)
364364
var httpContext = new DefaultHttpContext();
365365
httpContext.Request.Query = query;
366366

367-
var requestDelegate = RequestDelegateFactory.Build((Action<int>)TestAction);
367+
var requestDelegate = RequestDelegateFactory.Create((Action<int>)TestAction);
368368

369369
await requestDelegate(httpContext);
370370

@@ -387,7 +387,7 @@ void TestAction([FromHeader(Name = customHeaderName)] int value)
387387
var httpContext = new DefaultHttpContext();
388388
httpContext.Request.Headers[customHeaderName] = originalHeaderParam.ToString(NumberFormatInfo.InvariantInfo);
389389

390-
var requestDelegate = RequestDelegateFactory.Build((Action<int>)TestAction);
390+
var requestDelegate = RequestDelegateFactory.Create((Action<int>)TestAction);
391391

392392
await requestDelegate(httpContext);
393393

@@ -415,7 +415,7 @@ void TestAction([FromBody] Todo todo)
415415
var requestBodyBytes = JsonSerializer.SerializeToUtf8Bytes(originalTodo);
416416
httpContext.Request.Body = new MemoryStream(requestBodyBytes);
417417

418-
var requestDelegate = RequestDelegateFactory.Build((Action<Todo>)TestAction);
418+
var requestDelegate = RequestDelegateFactory.Create((Action<Todo>)TestAction);
419419

420420
await requestDelegate(httpContext);
421421

@@ -434,7 +434,7 @@ void TestAction([FromBody] Todo todo)
434434
httpContext.Request.Headers["Content-Type"] = "application/json";
435435
httpContext.Request.Headers["Content-Length"] = "0";
436436

437-
var requestDelegate = RequestDelegateFactory.Build((Action<Todo>)TestAction);
437+
var requestDelegate = RequestDelegateFactory.Create((Action<Todo>)TestAction);
438438

439439
await Assert.ThrowsAsync<JsonException>(() => requestDelegate(httpContext));
440440
}
@@ -453,7 +453,7 @@ void TestAction([FromBody(AllowEmpty = true)] Todo todo)
453453
httpContext.Request.Headers["Content-Type"] = "application/json";
454454
httpContext.Request.Headers["Content-Length"] = "0";
455455

456-
var requestDelegate = RequestDelegateFactory.Build((Action<Todo>)TestAction);
456+
var requestDelegate = RequestDelegateFactory.Create((Action<Todo>)TestAction);
457457

458458
await requestDelegate(httpContext);
459459

@@ -477,7 +477,7 @@ void TestAction([FromBody(AllowEmpty = true)] BodyStruct bodyStruct)
477477
httpContext.Request.Headers["Content-Type"] = "application/json";
478478
httpContext.Request.Headers["Content-Length"] = "0";
479479

480-
var requestDelegate = RequestDelegateFactory.Build((Action<BodyStruct>)TestAction);
480+
var requestDelegate = RequestDelegateFactory.Create((Action<BodyStruct>)TestAction);
481481

482482
await requestDelegate(httpContext);
483483

@@ -507,7 +507,7 @@ void TestAction([FromBody] Todo todo)
507507
httpContext.Features.Set<IHttpRequestLifetimeFeature>(new TestHttpRequestLifetimeFeature());
508508
httpContext.RequestServices = serviceCollection.BuildServiceProvider();
509509

510-
var requestDelegate = RequestDelegateFactory.Build((Action<Todo>)TestAction);
510+
var requestDelegate = RequestDelegateFactory.Create((Action<Todo>)TestAction);
511511

512512
await requestDelegate(httpContext);
513513

@@ -543,7 +543,7 @@ void TestAction([FromBody] Todo todo)
543543
httpContext.Features.Set<IHttpRequestLifetimeFeature>(new TestHttpRequestLifetimeFeature());
544544
httpContext.RequestServices = serviceCollection.BuildServiceProvider();
545545

546-
var requestDelegate = RequestDelegateFactory.Build((Action<Todo>)TestAction);
546+
var requestDelegate = RequestDelegateFactory.Create((Action<Todo>)TestAction);
547547

548548
await requestDelegate(httpContext);
549549

@@ -578,7 +578,7 @@ void TestAction([FromForm] int value)
578578
var httpContext = new DefaultHttpContext();
579579
httpContext.Request.Form = form;
580580

581-
var requestDelegate = RequestDelegateFactory.Build((Action<int>)TestAction);
581+
var requestDelegate = RequestDelegateFactory.Create((Action<int>)TestAction);
582582

583583
await requestDelegate(httpContext);
584584

@@ -608,7 +608,7 @@ void TestAction([FromForm] int value)
608608
httpContext.Features.Set<IHttpRequestLifetimeFeature>(new TestHttpRequestLifetimeFeature());
609609
httpContext.RequestServices = serviceCollection.BuildServiceProvider();
610610

611-
var requestDelegate = RequestDelegateFactory.Build((Action<int>)TestAction);
611+
var requestDelegate = RequestDelegateFactory.Create((Action<int>)TestAction);
612612

613613
await requestDelegate(httpContext);
614614

@@ -644,7 +644,7 @@ void TestAction([FromForm] int value)
644644
httpContext.Features.Set<IHttpRequestLifetimeFeature>(new TestHttpRequestLifetimeFeature());
645645
httpContext.RequestServices = serviceCollection.BuildServiceProvider();
646646

647-
var requestDelegate = RequestDelegateFactory.Build((Action<int>)TestAction);
647+
var requestDelegate = RequestDelegateFactory.Create((Action<int>)TestAction);
648648

649649
await requestDelegate(httpContext);
650650

@@ -664,16 +664,16 @@ public void BuildRequestDelegateThrowsInvalidOperationExceptionGivenBothFromBody
664664
void TestAction([FromBody] int value1, [FromForm] int value2) { }
665665
void TestActionWithFlippedParams([FromForm] int value1, [FromBody] int value2) { }
666666

667-
Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Build((Action<int, int>)TestAction));
668-
Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Build((Action<int, int>)TestActionWithFlippedParams));
667+
Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Create((Action<int, int>)TestAction));
668+
Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Create((Action<int, int>)TestActionWithFlippedParams));
669669
}
670670

671671
[Fact]
672672
public void BuildRequestDelegateThrowsInvalidOperationExceptionGivenFromBodyOnMultipleParameters()
673673
{
674674
void TestAction([FromBody] int value1, [FromBody] int value2) { }
675675

676-
Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Build((Action<int, int>)TestAction));
676+
Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Create((Action<int, int>)TestAction));
677677
}
678678

679679
[Fact]
@@ -693,7 +693,7 @@ void TestAction([FromService] MyService myService)
693693
var httpContext = new DefaultHttpContext();
694694
httpContext.RequestServices = serviceCollection.BuildServiceProvider();
695695

696-
var requestDelegate = RequestDelegateFactory.Build((Action<MyService>)TestAction);
696+
var requestDelegate = RequestDelegateFactory.Create((Action<MyService>)TestAction);
697697

698698
await requestDelegate(httpContext);
699699

@@ -712,7 +712,7 @@ void TestAction(HttpContext httpContext)
712712

713713
var httpContext = new DefaultHttpContext();
714714

715-
var requestDelegate = RequestDelegateFactory.Build((Action<HttpContext>)TestAction);
715+
var requestDelegate = RequestDelegateFactory.Create((Action<HttpContext>)TestAction);
716716

717717
await requestDelegate(httpContext);
718718

@@ -732,7 +732,7 @@ void TestAction(IFormCollection httpContext)
732732
var httpContext = new DefaultHttpContext();
733733
httpContext.Request.Headers["Content-Type"] = "application/x-www-form-urlencoded";
734734

735-
var requestDelegate = RequestDelegateFactory.Build((Action<IFormCollection>)TestAction);
735+
var requestDelegate = RequestDelegateFactory.Create((Action<IFormCollection>)TestAction);
736736

737737
await requestDelegate(httpContext);
738738

@@ -755,7 +755,7 @@ void TestAction(CancellationToken cancellationToken)
755755
RequestAborted = cts.Token
756756
};
757757

758-
var requestDelegate = RequestDelegateFactory.Build((Action<CancellationToken>)TestAction);
758+
var requestDelegate = RequestDelegateFactory.Create((Action<CancellationToken>)TestAction);
759759

760760
await requestDelegate(httpContext);
761761

@@ -799,7 +799,7 @@ public async Task RequestDelegateWritesComplexReturnValueAsJsonResponseBody(Dele
799799
var responseBodyStream = new MemoryStream();
800800
httpContext.Response.Body = responseBodyStream;
801801

802-
var requestDelegate = RequestDelegateFactory.Build(@delegate);
802+
var requestDelegate = RequestDelegateFactory.Create(@delegate);
803803

804804
await requestDelegate(httpContext);
805805

@@ -848,7 +848,7 @@ public async Task RequestDelegateUsesCustomIResult(Delegate @delegate)
848848
var responseBodyStream = new MemoryStream();
849849
httpContext.Response.Body = responseBodyStream;
850850

851-
var requestDelegate = RequestDelegateFactory.Build(@delegate);
851+
var requestDelegate = RequestDelegateFactory.Create(@delegate);
852852

853853
await requestDelegate(httpContext);
854854

@@ -891,7 +891,7 @@ public async Task RequestDelegateWritesStringReturnValueAsJsonResponseBody(Deleg
891891
var responseBodyStream = new MemoryStream();
892892
httpContext.Response.Body = responseBodyStream;
893893

894-
var requestDelegate = RequestDelegateFactory.Build(@delegate);
894+
var requestDelegate = RequestDelegateFactory.Create(@delegate);
895895

896896
await requestDelegate(httpContext);
897897

@@ -932,7 +932,7 @@ public async Task RequestDelegateWritesIntReturnValue(Delegate @delegate)
932932
var responseBodyStream = new MemoryStream();
933933
httpContext.Response.Body = responseBodyStream;
934934

935-
var requestDelegate = RequestDelegateFactory.Build(@delegate);
935+
var requestDelegate = RequestDelegateFactory.Create(@delegate);
936936

937937
await requestDelegate(httpContext);
938938

@@ -973,7 +973,7 @@ public async Task RequestDelegateWritesBoolReturnValue(Delegate @delegate)
973973
var responseBodyStream = new MemoryStream();
974974
httpContext.Response.Body = responseBodyStream;
975975

976-
var requestDelegate = RequestDelegateFactory.Build(@delegate);
976+
var requestDelegate = RequestDelegateFactory.Create(@delegate);
977977

978978
await requestDelegate(httpContext);
979979

src/Http/Routing/src/Builder/MapActionEndpointRouteBuilderExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public static MapActionEndpointConventionBuilder Map(
159159
const int defaultOrder = 0;
160160

161161
var builder = new RouteEndpointBuilder(
162-
RequestDelegateFactory.Build(action),
162+
RequestDelegateFactory.Create(action),
163163
pattern,
164164
defaultOrder)
165165
{

0 commit comments

Comments
 (0)