@@ -3156,6 +3156,55 @@ static void TestAction([AsParameters] ParameterListRequiredNullableStringFromDif
31563156 Assert . Null ( httpContext . Items [ "RequiredHeaderParam" ] ) ;
31573157 }
31583158
3159+ private class ParameterListFromHeaderCommaSeparatedValues
3160+ {
3161+ [ FromHeader ( Name = "q" ) ]
3162+ public required StringValues ? BoundToStringValues { get ; set ; }
3163+
3164+ [ FromHeader ( Name = "q" ) ]
3165+ public string ? BoundToString { get ; set ; }
3166+
3167+ [ FromHeader ( Name = "q" ) ]
3168+ public string [ ] ? BoundToStringArray { get ; set ; }
3169+
3170+ [ FromHeader ( Name = "q" ) ]
3171+ public int [ ] ? BoundToIntArray { get ; set ; }
3172+ }
3173+
3174+ [ Theory ]
3175+ [ InlineData ( "" , new string [ ] { } , new int [ ] { } ) ]
3176+ [ InlineData ( " " , new string [ ] { } , new int [ ] { } ) ]
3177+ [ InlineData ( "," , new string [ ] { } , new int [ ] { } ) ]
3178+ [ InlineData ( "100" , new string [ ] { "100" } , new int [ ] { 100 } ) ]
3179+ [ InlineData ( "1,2" , new string [ ] { "1" , "2" } , new int [ ] { 1 , 2 } ) ]
3180+ [ InlineData ( "1, 2 , 3" , new string [ ] { "1" , "2" , "3" } , new int [ ] { 1 , 2 , 3 } ) ]
3181+ public async Task RequestDelegateFactory_FromHeader_CommaSeparatedValues ( string headerValue , string [ ] expectedStringArray , int [ ] expectedIntArray )
3182+ {
3183+ // Arrange
3184+ var httpContext = CreateHttpContext ( ) ;
3185+ httpContext . Request . Headers [ "q" ] = headerValue ;
3186+
3187+ void TestAction ( [ AsParameters ] ParameterListFromHeaderCommaSeparatedValues args )
3188+ {
3189+ httpContext . Items [ nameof ( args . BoundToStringValues ) ] = args . BoundToStringValues ;
3190+ httpContext . Items [ nameof ( args . BoundToString ) ] = args . BoundToString ;
3191+ httpContext . Items [ nameof ( args . BoundToStringArray ) ] = args . BoundToStringArray ;
3192+ httpContext . Items [ nameof ( args . BoundToIntArray ) ] = args . BoundToIntArray ;
3193+ }
3194+
3195+ var factoryResult = RequestDelegateFactory . Create ( TestAction ) ;
3196+ var requestDelegate = factoryResult . RequestDelegate ;
3197+
3198+ // Act
3199+ await requestDelegate ( httpContext ) ;
3200+
3201+ // Assert
3202+ Assert . Equal ( headerValue , httpContext . Items [ nameof ( ParameterListFromHeaderCommaSeparatedValues . BoundToString ) ] ) ;
3203+ Assert . Equal ( new StringValues ( headerValue ) , httpContext . Items [ nameof ( ParameterListFromHeaderCommaSeparatedValues . BoundToStringValues ) ] ) ;
3204+ Assert . Equal ( expectedStringArray , httpContext . Items [ nameof ( ParameterListFromHeaderCommaSeparatedValues . BoundToStringArray ) ] ) ;
3205+ Assert . Equal ( expectedIntArray , httpContext . Items [ nameof ( ParameterListFromHeaderCommaSeparatedValues . BoundToIntArray ) ] ) ;
3206+ }
3207+
31593208#nullable disable
31603209 private class ParameterListMixedRequiredStringsFromDifferentSources
31613210 {
0 commit comments