Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Propagate PropertyInfo for AsParameters parameters #57264

Conversation

jgarciadelanoceda
Copy link
Contributor

Propagate PropertyInfo for AsParameters parameters

Fixes the issue #56764

It adds the ContainerType for AsParameters parameters to be able to solve the issue in SwashBuckle OpenApi documentation with XML comments

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Aug 10, 2024
@jgarciadelanoceda
Copy link
Contributor Author

@dotnet-policy-service agree

@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Aug 10, 2024
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.

Looks good! Left a few more comments to make the way we construct model metadata for parameters more resilient in the future.

@jgarciadelanoceda
Copy link
Contributor Author

jgarciadelanoceda commented Aug 14, 2024

Looks good! Left a few more comments to make the way we construct model metadata for parameters more resilient in the future.

@captainsafia were you able to see the response? I had the same idea but the ParameterInfo does not contain the ContainerType and also the reportedType will not be the same in the case I change to ParameterInfo( for Types that have a TryParse method)

@captainsafia
Copy link
Member

@jgarciadelanoceda Sorry for the delay...I needed a little bit of time to grok what you meant in your message.

This was my first thought indeed but the forParamater does not include the Container type (Because the ParameterInfo doesn't either)

The proposed change was for the else case of the change where we try to generate ModelMetadata for a parameter that doesn't have AsParameters. It seems like not having the ContainerType there is fine?

and also the logic in GetBindingSource and name gets other type that could be different from the type that the paramater has(for example when the type has a tryParse) and for compability issues I opted to just report the ParameterInfo

I see what you mean here. There is however an overload of ModelMetadataIdentity.ForParmaeter that takes ParameterInfo and Type (ref). I think that should do the trick?

@jgarciadelanoceda jgarciadelanoceda requested a review from a team as a code owner August 15, 2024 13:50
@jgarciadelanoceda
Copy link
Contributor Author

Finally it worked inserting a new line in ForParameter method :), checking if the Member is a PropertyInfo and Propagating the ContainerType of that PropertyInfo

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 iterating until we landed on a good spot.

@captainsafia
Copy link
Member

/azp run

@captainsafia captainsafia enabled auto-merge (squash) August 20, 2024 03:30
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@captainsafia captainsafia merged commit 0e812ec into dotnet:main Aug 20, 2024
26 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the 10.0-preview1 milestone Aug 20, 2024
@jgarciadelanoceda jgarciadelanoceda deleted the issue_56764_AsParametersNotPopulatingContainerType branch August 20, 2024 05:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants