File tree 3 files changed +35
-0
lines changed
3 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,9 @@ public static IServiceCollection AddRoutingCore(this IServiceCollection services
43
43
{
44
44
ArgumentNullException . ThrowIfNull ( services ) ;
45
45
46
+ // Required for IMeterFactory dependency.
47
+ services . AddMetrics ( ) ;
48
+
46
49
services . TryAddTransient < IInlineConstraintResolver , DefaultInlineConstraintResolver > ( ) ;
47
50
services . TryAddTransient < ObjectPoolProvider , DefaultObjectPoolProvider > ( ) ;
48
51
services . TryAddSingleton < ObjectPool < UriBuildingContext > > ( s =>
Original file line number Diff line number Diff line change 46
46
<Reference Include =" Microsoft.AspNetCore.Http.Features" />
47
47
<Reference Include =" Microsoft.AspNetCore.Http.Abstractions" />
48
48
<Reference Include =" Microsoft.AspNetCore.Routing.Abstractions" />
49
+ <Reference Include =" Microsoft.Extensions.Diagnostics" />
49
50
<Reference Include =" Microsoft.Extensions.Features" />
50
51
<Reference Include =" Microsoft.Extensions.ObjectPool" />
51
52
<Reference Include =" Microsoft.Extensions.Options" />
Original file line number Diff line number Diff line change 10
10
using Microsoft . AspNetCore . Routing . Matching ;
11
11
using Microsoft . AspNetCore . Routing . TestObjects ;
12
12
using Microsoft . AspNetCore . Testing ;
13
+ using Microsoft . Extensions . DependencyInjection ;
13
14
using Microsoft . Extensions . Logging ;
14
15
using Microsoft . Extensions . Logging . Abstractions ;
15
16
using Microsoft . Extensions . Logging . Testing ;
@@ -393,6 +394,36 @@ public async Task Endpoint_HasBodySizeFeature_SetUsingSizeLimitMetadata(bool isR
393
394
Assert . Equal ( expectedRequestSizeLimit , actualRequestSizeLimit ) ;
394
395
}
395
396
397
+ [ Fact ]
398
+ public async Task Create_WithoutHostBuilder_Success ( )
399
+ {
400
+ // Arrange
401
+ var httpContext = CreateHttpContext ( ) ;
402
+
403
+ var services = new ServiceCollection ( ) ;
404
+ services . AddLogging ( ) ;
405
+ services . AddOptions ( ) ;
406
+ services . AddSingleton < DiagnosticListener > ( s => new DiagnosticListener ( "Test" ) ) ;
407
+ services . AddRouting ( ) ;
408
+
409
+ var applicationBuilder = new ApplicationBuilder ( services . BuildServiceProvider ( ) ) ;
410
+
411
+ applicationBuilder . UseRouting ( ) ;
412
+ applicationBuilder . UseEndpoints ( endpoints =>
413
+ {
414
+ endpoints . MapGet ( "/" , ( HttpContext c ) => Task . CompletedTask ) ;
415
+ } ) ;
416
+
417
+ var requestDelegate = applicationBuilder . Build ( ) ;
418
+
419
+ // Act
420
+ await requestDelegate ( httpContext ) ;
421
+
422
+ // Assert
423
+ var endpointFeature = httpContext . Features . Get < IEndpointFeature > ( ) ;
424
+ Assert . NotNull ( endpointFeature ) ;
425
+ }
426
+
396
427
private class RequestSizeLimitMetadata ( long ? maxRequestBodySize ) : IRequestSizeLimitMetadata
397
428
{
398
429
You can’t perform that action at this time.
0 commit comments