Skip to content

Conversation

@StickFun
Copy link
Contributor

@StickFun StickFun commented Aug 2, 2025

Added string arrays to simple binding

Description

Fixed condition for using a string array with simple binding.

Fixes #62326

@github-actions github-actions bot added the area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions label Aug 2, 2025
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Aug 2, 2025
@captainsafia captainsafia added area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc and removed area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions labels Aug 3, 2025
Copy link
Member

@captainsafia captainsafia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change looks like a good start -- can you add some test coverage to RequestDelegateFactoryTests in the repo for this case?

@captainsafia captainsafia added the pr: pending author input For automation. Specifically separate from Needs: Author Feedback label Aug 3, 2025
@StickFun
Copy link
Contributor Author

StickFun commented Aug 3, 2025

Added unit test for handling string array

metadata.Name == "formValues") as ParameterBindingMetadata;

Assert.NotNull(parameterBindingMetadata);
Assert.Equal(typeof(string[]), parameterBindingMetadata.ParameterInfo.ParameterType);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we update the test to send a payload in the HTTP context and verify that context.Items["form"] is populated correctly?


await requestDelegate(httpContext);

Assert.Equal(new StringValues(new[] { "1", "2", "3" }), httpContext.Items["form"]!);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Assert.Equal(new StringValues(new[] { "1", "2", "3" }), httpContext.Items["form"]!);
var parameterBindingMetadata = factoryResult.EndpointMetadata
.FirstOrDefault(e => e is ParameterBindingMetadata metadata &&
metadata.Name == "formValues") as ParameterBindingMetadata;
Assert.NotNull(parameterBindingMetadata);
Assert.Equal(typeof(string[]), parameterBindingMetadata.ParameterInfo.ParameterType);
Assert.Equal(new StringValues(new[] { "1", "2", "3" }), httpContext.Items["form"]!);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commited suggestion

Copy link
Member

@captainsafia captainsafia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for addressing all the feedback points.

@dotnet-policy-service dotnet-policy-service bot added the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Aug 15, 2025
@StickFun
Copy link
Contributor Author

@captainsafia, do I need to do something else to merge this pull-request?

@captainsafia
Copy link
Member

/azp run

@dotnet-policy-service dotnet-policy-service bot removed the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Aug 18, 2025
@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@captainsafia captainsafia enabled auto-merge (squash) August 18, 2025 22:19
@captainsafia captainsafia merged commit 334fe40 into dotnet:main Aug 18, 2025
29 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the 10.0-rc1 milestone Aug 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc community-contribution Indicates that the PR has been added by a community member pr: pending author input For automation. Specifically separate from Needs: Author Feedback

Projects

None yet

Development

Successfully merging this pull request may close these issues.

InvalidOperationException when using string[] parameters with FromForm attribute

2 participants