Skip to content

Commit e73c2cb

Browse files
DamianEdwardscaptainsafia
authored andcommitted
RequestDelegateFactory context classes ApplicationServices property (dotnet#41952)
- Added `public IServiceProvider ApplicationServices { get; }` property to `RouteHandlerContext` - Enables route handler filter factories to access app services - Renamed existing `Services` property on `EndpointParameterMetadataContext` and `EndpointMetadataContext` to `ApplicationServices` and made it non-nullable - Added a unit test & updated another to ensure app's service provider is passed through correctly by `RequestDelegateFactory` Fixes dotnet#41900
1 parent 57c037c commit e73c2cb

33 files changed

+219
-53
lines changed

src/Http/Http.Abstractions/src/PublicAPI.Unshipped.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ Microsoft.AspNetCore.Http.Metadata.IFromFormMetadata.Name.get -> string?
1515
Microsoft.AspNetCore.Http.Metadata.IRequestSizeLimitMetadata
1616
Microsoft.AspNetCore.Http.Metadata.IRequestSizeLimitMetadata.MaxRequestBodySize.get -> long?
1717
Microsoft.AspNetCore.Http.RouteHandlerContext
18+
Microsoft.AspNetCore.Http.RouteHandlerContext.ApplicationServices.get -> System.IServiceProvider!
1819
Microsoft.AspNetCore.Http.RouteHandlerContext.EndpointMetadata.get -> Microsoft.AspNetCore.Http.EndpointMetadataCollection!
1920
Microsoft.AspNetCore.Http.RouteHandlerContext.MethodInfo.get -> System.Reflection.MethodInfo!
20-
Microsoft.AspNetCore.Http.RouteHandlerContext.RouteHandlerContext(System.Reflection.MethodInfo! methodInfo, Microsoft.AspNetCore.Http.EndpointMetadataCollection! endpointMetadata) -> void
21+
Microsoft.AspNetCore.Http.RouteHandlerContext.RouteHandlerContext(System.Reflection.MethodInfo! methodInfo, Microsoft.AspNetCore.Http.EndpointMetadataCollection! endpointMetadata, System.IServiceProvider! applicationServices) -> void
2122
Microsoft.AspNetCore.Http.RouteHandlerFilterDelegate
2223
Microsoft.AspNetCore.Http.RouteHandlerInvocationContext
2324
Microsoft.AspNetCore.Http.RouteHandlerInvocationContext.RouteHandlerInvocationContext() -> void

src/Http/Http.Abstractions/src/RouteHandlerContext.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,16 @@ public sealed class RouteHandlerContext
1616
/// </summary>
1717
/// <param name="methodInfo">The <see cref="MethodInfo"/> associated with the route handler of the current request.</param>
1818
/// <param name="endpointMetadata">The <see cref="EndpointMetadataCollection"/> associated with the endpoint the filter is targeting.</param>
19-
public RouteHandlerContext(MethodInfo methodInfo, EndpointMetadataCollection endpointMetadata)
19+
/// <param name="applicationServices">The <see cref="IServiceProvider"/> instance used to access the application services.</param>
20+
public RouteHandlerContext(MethodInfo methodInfo, EndpointMetadataCollection endpointMetadata, IServiceProvider applicationServices)
2021
{
22+
ArgumentNullException.ThrowIfNull(methodInfo);
23+
ArgumentNullException.ThrowIfNull(endpointMetadata);
24+
ArgumentNullException.ThrowIfNull(applicationServices);
25+
2126
MethodInfo = methodInfo;
2227
EndpointMetadata = endpointMetadata;
28+
ApplicationServices = applicationServices;
2329
}
2430

2531
/// <summary>
@@ -31,4 +37,9 @@ public RouteHandlerContext(MethodInfo methodInfo, EndpointMetadataCollection end
3137
/// The <see cref="EndpointMetadataCollection"/> associated with the current endpoint.
3238
/// </summary>
3339
public EndpointMetadataCollection EndpointMetadata { get; }
40+
41+
/// <summary>
42+
/// Gets the <see cref="IServiceProvider"/> instance used to access application services.
43+
/// </summary>
44+
public IServiceProvider ApplicationServices { get; }
3445
}

src/Http/Http.Extensions/src/EndpointMetadataContext.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,16 @@ public sealed class EndpointMetadataContext
1515
/// </summary>
1616
/// <param name="method">The <see cref="MethodInfo"/> of the route handler delegate of the endpoint being created.</param>
1717
/// <param name="endpointMetadata">The list of objects that will be added to the metadata of the endpoint.</param>
18-
/// <param name="services">The <see cref="IServiceProvider"/> instance used to access application services.</param>
19-
public EndpointMetadataContext(MethodInfo method, IList<object> endpointMetadata, IServiceProvider? services)
18+
/// <param name="applicationServices">The <see cref="IServiceProvider"/> instance used to access application services.</param>
19+
public EndpointMetadataContext(MethodInfo method, IList<object> endpointMetadata, IServiceProvider applicationServices)
2020
{
21-
ArgumentNullException.ThrowIfNull(method, nameof(method));
22-
ArgumentNullException.ThrowIfNull(endpointMetadata, nameof(endpointMetadata));
21+
ArgumentNullException.ThrowIfNull(method);
22+
ArgumentNullException.ThrowIfNull(endpointMetadata);
23+
ArgumentNullException.ThrowIfNull(applicationServices);
2324

2425
Method = method;
2526
EndpointMetadata = endpointMetadata;
26-
Services = services;
27+
ApplicationServices = applicationServices;
2728
}
2829

2930
/// <summary>
@@ -39,5 +40,5 @@ public EndpointMetadataContext(MethodInfo method, IList<object> endpointMetadata
3940
/// <summary>
4041
/// Gets the <see cref="IServiceProvider"/> instance used to access application services.
4142
/// </summary>
42-
public IServiceProvider? Services { get; }
43+
public IServiceProvider ApplicationServices { get; }
4344
}

src/Http/Http.Extensions/src/EndpointParameterMetadataContext.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,16 @@ public sealed class EndpointParameterMetadataContext
1515
/// </summary>
1616
/// <param name="parameter">The parameter of the route handler delegate of the endpoint being created.</param>
1717
/// <param name="endpointMetadata">The list of objects that will be added to the metadata of the endpoint.</param>
18-
/// <param name="services">The <see cref="IServiceProvider"/> instance used to access application services.</param>
19-
public EndpointParameterMetadataContext(ParameterInfo parameter, IList<object> endpointMetadata, IServiceProvider? services)
18+
/// <param name="applicationServices">The <see cref="IServiceProvider"/> instance used to access application services.</param>
19+
public EndpointParameterMetadataContext(ParameterInfo parameter, IList<object> endpointMetadata, IServiceProvider applicationServices)
2020
{
21-
ArgumentNullException.ThrowIfNull(parameter, nameof(parameter));
22-
ArgumentNullException.ThrowIfNull(endpointMetadata, nameof(endpointMetadata));
21+
ArgumentNullException.ThrowIfNull(parameter);
22+
ArgumentNullException.ThrowIfNull(endpointMetadata);
23+
ArgumentNullException.ThrowIfNull(applicationServices);
2324

2425
Parameter = parameter;
2526
EndpointMetadata = endpointMetadata;
26-
Services = services;
27+
ApplicationServices = applicationServices;
2728
}
2829

2930
/// <summary>
@@ -39,5 +40,5 @@ public EndpointParameterMetadataContext(ParameterInfo parameter, IList<object> e
3940
/// <summary>
4041
/// Gets the <see cref="IServiceProvider"/> instance used to access application services.
4142
/// </summary>
42-
public IServiceProvider? Services { get; }
43+
public IServiceProvider ApplicationServices { get; }
4344
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
#nullable enable
22
Microsoft.AspNetCore.Http.Metadata.EndpointMetadataContext
3-
Microsoft.AspNetCore.Http.Metadata.EndpointMetadataContext.EndpointMetadataContext(System.Reflection.MethodInfo! method, System.Collections.Generic.IList<object!>! endpointMetadata, System.IServiceProvider? services) -> void
3+
Microsoft.AspNetCore.Http.Metadata.EndpointMetadataContext.ApplicationServices.get -> System.IServiceProvider!
4+
Microsoft.AspNetCore.Http.Metadata.EndpointMetadataContext.EndpointMetadataContext(System.Reflection.MethodInfo! method, System.Collections.Generic.IList<object!>! endpointMetadata, System.IServiceProvider! applicationServices) -> void
45
Microsoft.AspNetCore.Http.Metadata.EndpointMetadataContext.EndpointMetadata.get -> System.Collections.Generic.IList<object!>!
56
Microsoft.AspNetCore.Http.Metadata.EndpointMetadataContext.Method.get -> System.Reflection.MethodInfo!
6-
Microsoft.AspNetCore.Http.Metadata.EndpointMetadataContext.Services.get -> System.IServiceProvider?
77
Microsoft.AspNetCore.Http.Metadata.EndpointParameterMetadataContext
8-
Microsoft.AspNetCore.Http.Metadata.EndpointParameterMetadataContext.EndpointParameterMetadataContext(System.Reflection.ParameterInfo! parameter, System.Collections.Generic.IList<object!>! endpointMetadata, System.IServiceProvider? services) -> void
8+
Microsoft.AspNetCore.Http.Metadata.EndpointParameterMetadataContext.ApplicationServices.get -> System.IServiceProvider!
9+
Microsoft.AspNetCore.Http.Metadata.EndpointParameterMetadataContext.EndpointParameterMetadataContext(System.Reflection.ParameterInfo! parameter, System.Collections.Generic.IList<object!>! endpointMetadata, System.IServiceProvider! applicationServices) -> void
910
Microsoft.AspNetCore.Http.Metadata.EndpointParameterMetadataContext.EndpointMetadata.get -> System.Collections.Generic.IList<object!>!
1011
Microsoft.AspNetCore.Http.Metadata.EndpointParameterMetadataContext.Parameter.get -> System.Reflection.ParameterInfo!
11-
Microsoft.AspNetCore.Http.Metadata.EndpointParameterMetadataContext.Services.get -> System.IServiceProvider?
1212
Microsoft.AspNetCore.Http.Metadata.IEndpointMetadataProvider
1313
Microsoft.AspNetCore.Http.Metadata.IEndpointMetadataProvider.PopulateMetadata(Microsoft.AspNetCore.Http.Metadata.EndpointMetadataContext! context) -> void
1414
Microsoft.AspNetCore.Http.Metadata.IEndpointParameterMetadataProvider

src/Http/Http.Extensions/src/RequestDelegateFactory.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,8 @@ targetExpression is null
305305
FilterContextExpr).Compile();
306306
var routeHandlerContext = new RouteHandlerContext(
307307
methodInfo,
308-
new EndpointMetadataCollection(factoryContext.Metadata));
308+
new EndpointMetadataCollection(factoryContext.Metadata),
309+
factoryContext.ServiceProvider ?? EmptyServiceProvider.Instance);
309310

310311
for (var i = factoryContext.Filters.Count - 1; i >= 0; i--)
311312
{
@@ -442,7 +443,7 @@ private static void AddTypeProvidedMetadata(MethodInfo methodInfo, List<object>
442443
if (typeof(IEndpointParameterMetadataProvider).IsAssignableFrom(parameter.ParameterType))
443444
{
444445
// Parameter type implements IEndpointParameterMetadataProvider
445-
var parameterContext = new EndpointParameterMetadataContext(parameter, metadata, services);
446+
var parameterContext = new EndpointParameterMetadataContext(parameter, metadata, services ?? EmptyServiceProvider.Instance);
446447
invokeArgs ??= new object[1];
447448
invokeArgs[0] = parameterContext;
448449
PopulateMetadataForParameterMethod.MakeGenericMethod(parameter.ParameterType).Invoke(null, invokeArgs);
@@ -451,7 +452,7 @@ private static void AddTypeProvidedMetadata(MethodInfo methodInfo, List<object>
451452
if (typeof(IEndpointMetadataProvider).IsAssignableFrom(parameter.ParameterType))
452453
{
453454
// Parameter type implements IEndpointMetadataProvider
454-
var context = new EndpointMetadataContext(methodInfo, metadata, services);
455+
var context = new EndpointMetadataContext(methodInfo, metadata, services ?? EmptyServiceProvider.Instance);
455456
invokeArgs ??= new object[1];
456457
invokeArgs[0] = context;
457458
PopulateMetadataForEndpointMethod.MakeGenericMethod(parameter.ParameterType).Invoke(null, invokeArgs);
@@ -468,7 +469,7 @@ private static void AddTypeProvidedMetadata(MethodInfo methodInfo, List<object>
468469
if (returnType is not null && typeof(IEndpointMetadataProvider).IsAssignableFrom(returnType))
469470
{
470471
// Return type implements IEndpointMetadataProvider
471-
var context = new EndpointMetadataContext(methodInfo, metadata, services);
472+
var context = new EndpointMetadataContext(methodInfo, metadata, services ?? EmptyServiceProvider.Instance);
472473
invokeArgs ??= new object[1];
473474
invokeArgs[0] = context;
474475
PopulateMetadataForEndpointMethod.MakeGenericMethod(returnType).Invoke(null, invokeArgs);
@@ -2350,4 +2351,11 @@ public Task ExecuteAsync(HttpContext httpContext)
23502351
return Task.CompletedTask;
23512352
}
23522353
}
2354+
2355+
private sealed class EmptyServiceProvider : IServiceProvider
2356+
{
2357+
public static IServiceProvider Instance { get; } = new EmptyServiceProvider();
2358+
2359+
public object? GetService(Type serviceType) => null;
2360+
}
23532361
}

src/Http/Http.Extensions/test/EndpointMetadataContextTests.cs

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class EndpointMetadataContextTests
1616
[Fact]
1717
public void EndpointMetadataContext_Ctor_ThrowsArgumentNullException_WhenMethodInfoIsNull()
1818
{
19-
Assert.Throws<ArgumentNullException>(() => new EndpointMetadataContext(null, new List<object>(), null));
19+
Assert.Throws<ArgumentNullException>("method", () => new EndpointMetadataContext(null, new List<object>(), null));
2020
}
2121

2222
[Fact]
@@ -25,13 +25,22 @@ public void EndpointMetadataContext_Ctor_ThrowsArgumentNullException_WhenMetadat
2525
Delegate handler = (int id) => { };
2626
var method = handler.GetMethodInfo();
2727

28-
Assert.Throws<ArgumentNullException>(() => new EndpointMetadataContext(method, null, null));
28+
Assert.Throws<ArgumentNullException>("endpointMetadata", () => new EndpointMetadataContext(method, null, null));
29+
}
30+
31+
[Fact]
32+
public void EndpointMetadataContext_Ctor_ThrowsArgumentNullException_WhenApplicationServicesAreNull()
33+
{
34+
Delegate handler = (int id) => { };
35+
var method = handler.GetMethodInfo();
36+
37+
Assert.Throws<ArgumentNullException>("applicationServices", () => new EndpointMetadataContext(method, new List<object>(), null));
2938
}
3039

3140
[Fact]
3241
public void EndpointParameterMetadataContext_Ctor_ThrowsArgumentNullException_WhenParameterInfoIsNull()
3342
{
34-
Assert.Throws<ArgumentNullException>(() => new EndpointParameterMetadataContext(null, new List<object>(), null));
43+
Assert.Throws<ArgumentNullException>("parameter", () => new EndpointParameterMetadataContext(null, new List<object>(), null));
3544
}
3645

3746
[Fact]
@@ -40,6 +49,15 @@ public void EndpointParameterMetadataContext_Ctor_ThrowsArgumentNullException_Wh
4049
Delegate handler = (int id) => { };
4150
var parameter = handler.GetMethodInfo().GetParameters()[0];
4251

43-
Assert.Throws<ArgumentNullException>(() => new EndpointParameterMetadataContext(parameter, null, null));
52+
Assert.Throws<ArgumentNullException>("endpointMetadata", () => new EndpointParameterMetadataContext(parameter, null, null));
53+
}
54+
55+
[Fact]
56+
public void EndpointParameterMetadataContext_Ctor_ThrowsArgumentNullException_WhenApplicationServicesAreNull()
57+
{
58+
Delegate handler = (int id) => { };
59+
var parameter = handler.GetMethodInfo().GetParameters()[0];
60+
61+
Assert.Throws<ArgumentNullException>("applicationServices", () => new EndpointParameterMetadataContext(parameter, new List<object>(), null));
4462
}
4563
}

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

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6025,6 +6025,36 @@ public void Create_AllowsRemovalOfDefaultMetadata_ByParameterTypesImplementingIE
60256025
Assert.DoesNotContain(result.EndpointMetadata, m => m is IAcceptsMetadata);
60266026
}
60276027

6028+
[Fact]
6029+
public void Create_SetsApplicationServices_OnEndpointMetadataContext()
6030+
{
6031+
// Arrange
6032+
var @delegate = (Todo todo) => new AccessesServicesMetadataResult();
6033+
var metadataService = new MetadataService();
6034+
var serviceProvider = new ServiceCollection().AddSingleton(metadataService).BuildServiceProvider();
6035+
6036+
// Act
6037+
var result = RequestDelegateFactory.Create(@delegate, new() { ServiceProvider = serviceProvider });
6038+
6039+
// Assert
6040+
Assert.Contains(result.EndpointMetadata, m => m is MetadataService);
6041+
}
6042+
6043+
[Fact]
6044+
public void Create_SetsApplicationServices_OnEndpointParameterMetadataContext()
6045+
{
6046+
// Arrange
6047+
var @delegate = (AccessesServicesMetadataBinder parameter1) => "Test";
6048+
var metadataService = new MetadataService();
6049+
var serviceProvider = new ServiceCollection().AddSingleton(metadataService).BuildServiceProvider();
6050+
6051+
// Act
6052+
var result = RequestDelegateFactory.Create(@delegate, new() { ServiceProvider = serviceProvider });
6053+
6054+
// Assert
6055+
Assert.Contains(result.EndpointMetadata, m => m is MetadataService);
6056+
}
6057+
60286058
private DefaultHttpContext CreateHttpContext()
60296059
{
60306060
var responseFeature = new TestHttpResponseFeature();
@@ -6041,6 +6071,35 @@ private DefaultHttpContext CreateHttpContext()
60416071
};
60426072
}
60436073

6074+
private record MetadataService;
6075+
6076+
private class AccessesServicesMetadataResult : IResult, IEndpointMetadataProvider
6077+
{
6078+
public static void PopulateMetadata(EndpointMetadataContext context)
6079+
{
6080+
if (context.ApplicationServices?.GetRequiredService<MetadataService>() is { } metadataService)
6081+
{
6082+
context.EndpointMetadata.Add(metadataService);
6083+
}
6084+
}
6085+
6086+
public Task ExecuteAsync(HttpContext httpContext) => Task.CompletedTask;
6087+
}
6088+
6089+
private class AccessesServicesMetadataBinder : IEndpointMetadataProvider
6090+
{
6091+
public static ValueTask<AccessesServicesMetadataBinder> BindAsync(HttpContext context, ParameterInfo parameter) =>
6092+
new(new AccessesServicesMetadataBinder());
6093+
6094+
public static void PopulateMetadata(EndpointMetadataContext context)
6095+
{
6096+
if (context.ApplicationServices?.GetRequiredService<MetadataService>() is { } metadataService)
6097+
{
6098+
context.EndpointMetadata.Add(metadataService);
6099+
}
6100+
}
6101+
}
6102+
60446103
private class Attribute1 : Attribute
60456104
{
60466105
}

src/Http/Http.Results/test/AcceptedAtRouteOfTResultTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public void PopulateMetadata_AddsResponseTypeMetadata()
122122
// Arrange
123123
AcceptedAtRoute<Todo> MyApi() { throw new NotImplementedException(); }
124124
var metadata = new List<object>();
125-
var context = new EndpointMetadataContext(((Delegate)MyApi).GetMethodInfo(), metadata, null);
125+
var context = new EndpointMetadataContext(((Delegate)MyApi).GetMethodInfo(), metadata, EmptyServiceProvider.Instance);
126126

127127
// Act
128128
PopulateMetadata<AcceptedAtRoute<Todo>>(context);

src/Http/Http.Results/test/AcceptedAtRouteResultTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public void PopulateMetadata_AddsResponseTypeMetadata()
7575
// Arrange
7676
AcceptedAtRoute MyApi() { throw new NotImplementedException(); }
7777
var metadata = new List<object>();
78-
var context = new EndpointMetadataContext(((Delegate)MyApi).GetMethodInfo(), metadata, null);
78+
var context = new EndpointMetadataContext(((Delegate)MyApi).GetMethodInfo(), metadata, EmptyServiceProvider.Instance);
7979

8080
// Act
8181
PopulateMetadata<AcceptedAtRoute>(context);

src/Http/Http.Results/test/AcceptedOfTResultTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public void PopulateMetadata_AddsResponseTypeMetadata()
6262
// Arrange
6363
Accepted<Todo> MyApi() { throw new NotImplementedException(); }
6464
var metadata = new List<object>();
65-
var context = new EndpointMetadataContext(((Delegate)MyApi).GetMethodInfo(), metadata, null);
65+
var context = new EndpointMetadataContext(((Delegate)MyApi).GetMethodInfo(), metadata, EmptyServiceProvider.Instance);
6666

6767
// Act
6868
PopulateMetadata<Accepted<Todo>>(context);

src/Http/Http.Results/test/AcceptedResultTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public void PopulateMetadata_AddsResponseTypeMetadata()
3232
// Arrange
3333
Accepted MyApi() { throw new NotImplementedException(); }
3434
var metadata = new List<object>();
35-
var context = new EndpointMetadataContext(((Delegate)MyApi).GetMethodInfo(), metadata, null);
35+
var context = new EndpointMetadataContext(((Delegate)MyApi).GetMethodInfo(), metadata, EmptyServiceProvider.Instance);
3636

3737
// Act
3838
PopulateMetadata<Accepted>(context);

src/Http/Http.Results/test/BadRequestOfTResultTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public void PopulateMetadata_AddsResponseTypeMetadata()
104104
// Arrange
105105
BadRequest<Todo> MyApi() { throw new NotImplementedException(); }
106106
var metadata = new List<object>();
107-
var context = new EndpointMetadataContext(((Delegate)MyApi).GetMethodInfo(), metadata, null);
107+
var context = new EndpointMetadataContext(((Delegate)MyApi).GetMethodInfo(), metadata, EmptyServiceProvider.Instance);
108108

109109
// Act
110110
PopulateMetadata<BadRequest<Todo>>(context);

src/Http/Http.Results/test/BadRequestResultTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public void PopulateMetadata_AddsResponseTypeMetadata()
4545
// Arrange
4646
BadRequest MyApi() { throw new NotImplementedException(); }
4747
var metadata = new List<object>();
48-
var context = new EndpointMetadataContext(((Delegate)MyApi).GetMethodInfo(), metadata, null);
48+
var context = new EndpointMetadataContext(((Delegate)MyApi).GetMethodInfo(), metadata, EmptyServiceProvider.Instance);
4949

5050
// Act
5151
PopulateMetadata<BadRequest>(context);

src/Http/Http.Results/test/ConflictOfTResultTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public void PopulateMetadata_AddsResponseTypeMetadata()
8383
// Arrange
8484
Conflict<Todo> MyApi() { throw new NotImplementedException(); }
8585
var metadata = new List<object>();
86-
var context = new EndpointMetadataContext(((Delegate)MyApi).GetMethodInfo(), metadata, null);
86+
var context = new EndpointMetadataContext(((Delegate)MyApi).GetMethodInfo(), metadata, EmptyServiceProvider.Instance);
8787

8888
// Act
8989
PopulateMetadata<Conflict<Todo>>(context);

0 commit comments

Comments
 (0)