File tree Expand file tree Collapse file tree 3 files changed +23
-27
lines changed
gen/StaticRouteHandlerModel Expand file tree Collapse file tree 3 files changed +23
-27
lines changed Original file line number Diff line number Diff line change @@ -228,10 +228,10 @@ private static void EmitCallsToMetadataProvidersForParameters(this Endpoint endp
228
228
ProcessParameter ( innerParameter , codeWriter ) ;
229
229
}
230
230
}
231
- else
232
- {
233
- ProcessParameter ( parameter , codeWriter ) ;
234
- }
231
+
232
+ // Even if a parameter is decorated with the AsParameters attribute, we still need
233
+ // to fetch metadata on the parameter itself (as well as the properties).
234
+ ProcessParameter ( parameter , codeWriter ) ;
235
235
}
236
236
237
237
static void ProcessParameter ( EndpointParameter parameter , CodeWriter codeWriter )
Original file line number Diff line number Diff line change @@ -2501,29 +2501,6 @@ public void Create_CombinesDefaultMetadata_AndMetadataFromParameterTypesImplemen
2501
2501
Assert . Contains ( result . EndpointMetadata , m => m is CustomEndpointMetadata { Source : MetadataSource . Parameter } ) ;
2502
2502
}
2503
2503
2504
- [ Fact ]
2505
- public void Create_CombinesPropertiesAsParameterMetadata_AndTopLevelParameter ( )
2506
- {
2507
- // Arrange
2508
- var @delegate = ( [ AsParameters ] AddsCustomParameterMetadata param1 ) => new CountsDefaultEndpointMetadataResult ( ) ;
2509
- var options = new RequestDelegateFactoryOptions
2510
- {
2511
- EndpointBuilder = CreateEndpointBuilder ( new List < object >
2512
- {
2513
- new CustomEndpointMetadata { Source = MetadataSource . Caller }
2514
- } ) ,
2515
- } ;
2516
-
2517
- // Act
2518
- var result = RequestDelegateFactory . Create ( @delegate , options ) ;
2519
-
2520
- // Assert
2521
- Assert . Contains ( result . EndpointMetadata , m => m is CustomEndpointMetadata { Source : MetadataSource . Parameter } ) ;
2522
- Assert . Contains ( result . EndpointMetadata , m => m is ParameterNameMetadata { Name : "param1" } ) ;
2523
- Assert . Contains ( result . EndpointMetadata , m => m is CustomEndpointMetadata { Source : MetadataSource . Property } ) ;
2524
- Assert . Contains ( result . EndpointMetadata , m => m is ParameterNameMetadata { Name : nameof ( AddsCustomParameterMetadata . Data ) } ) ;
2525
- }
2526
-
2527
2504
[ Fact ]
2528
2505
public void Create_CombinesAllMetadata_InCorrectOrder ( )
2529
2506
{
Original file line number Diff line number Diff line change @@ -520,4 +520,23 @@ m is not Attribute2 &&
520
520
// Entry-specific metadata added after a call to InferMetadata
521
521
m => Assert . True ( m is CustomEndpointMetadata { Source : MetadataSource . Caller } ) ) ;
522
522
}
523
+
524
+ [ Fact ]
525
+ public async Task Create_CombinesPropertiesAsParameterMetadata_AndTopLevelParameter ( )
526
+ {
527
+ // Arrange
528
+ var ( _, compilation ) = await RunGeneratorAsync ( """
529
+ app.MapPost("/test/pattern", ([AsParameters] AddsCustomParameterMetadata param1) => new CountsDefaultEndpointMetadataPoco())
530
+ .WithMetadata(new CustomEndpointMetadata { Source = MetadataSource.Caller });
531
+ """ ) ;
532
+
533
+ // Act
534
+ var endpoint = GetEndpointFromCompilation ( compilation ) ;
535
+
536
+ // Assert
537
+ Assert . Contains ( endpoint . Metadata , m => m is CustomEndpointMetadata { Source : MetadataSource . Parameter } ) ;
538
+ Assert . Contains ( endpoint . Metadata , m => m is ParameterNameMetadata { Name : "param1" } ) ;
539
+ Assert . Contains ( endpoint . Metadata , m => m is CustomEndpointMetadata { Source : MetadataSource . Property } ) ;
540
+ Assert . Contains ( endpoint . Metadata , m => m is ParameterNameMetadata { Name : nameof ( AddsCustomParameterMetadata . Data ) } ) ;
541
+ }
523
542
}
You can’t perform that action at this time.
0 commit comments