Surrogate argument list in Minimal APIs#41325
Merged
Merged
Conversation
1 task
davidfowl
reviewed
Apr 23, 2022
davidfowl
reviewed
Apr 23, 2022
davidfowl
reviewed
Apr 23, 2022
davidfowl
reviewed
Apr 25, 2022
brunolins16
commented
Apr 27, 2022
halter73
reviewed
Apr 27, 2022
BrennanConroy
approved these changes
May 11, 2022
Member
BrennanConroy
left a comment
There was a problem hiding this comment.
What happens with multiple [AsParameters] like
void TestMethod([AsParameters] One, [AsParameters] Two) { }Should a test be added for it?
Member
Author
It will work but I think I missed a test for it. Let me add it. |
Co-authored-by: Brennan <brecon@microsoft.com>
halter73
approved these changes
May 12, 2022
Member
|
Really good job on this. The PR looks super clean. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Closes #40712
This PR will introduce a support for the
[Parameters]attribute. The parameter will be created, based on the on the constructor parameters and/or writable properties, and thenewexpression will be similar to:Parameterless constructor
Where all writable properties will be initialized and included as endpoint parameter.
Parameterized constructor
Where all constructor argument will be included as endpoint parameter. Also, in this case the arguments attributes will be used as primary source for
attributesand fallback to the matching property when nothing defined.Fo all parameters detected the same Bind rules, currently available, will be applied.
Constructor detection mechanism
I have tried to match as much as possible the rules described in spec but some behavior diverges from it. With that, here is how the [Parameter] type constructor is detected.
classinsensitive) public property.InvalidOperationExceptionwill be thrown if deserialization is attempted.InvalidOperationExceptionwhen more than one parameterized is declared and the parameterless constructor is not present.InvalidOperationExceptionif not able to find a correct constructor.structinsensitive) public property.InvalidOperationExceptionwill be thrown if deserialization is attempted.structalways has a default constructor, the default constructor will be used if it is the only one present or more than one parameterized constructor is present.The same rules applied for
records.Examples
Valid
Invalid
Benchmark
Results here: https://gist.github.com/brunolins16/901f351f4db7b14e69e1c58677922dd0