Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[release/8.0] Add explicit conversion for value-type returning handlers with filters#57966

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
wtgodbe merged 2 commits intorelease/8.0fromsafia/backport-filers-value-type-fix
Oct 2, 2024

Conversation

@captainsafia
Copy link
Member

@captainsafiacaptainsafia commentedSep 19, 2024
edited by BrennanConroy
Loading

Description

Merged in 10.0:#57428
Addresses#52128.

This PR fixes a bug with the handling of value type-returning handlers that are used in conjunction with endpoint filters. Such as:

varapp=WebApplication.Create();app.MapGet("/",()=>{return1;}).AddEndpointFilter(async(context,next)=>awaitnext(context));app.Run();

This currently throws:

ArgumentException: Expression of type 'System.Int32' cannot be used for parameter of type 'System.Object' of method 'System.Threading.Tasks.ValueTask`1[System.Object] WrapObjectAsValueTask(System.Object)' (Parameter 'arg0')

Because the return type requires an explicit conversion before being wrapped as aValueTask<object> to confirm with theEndpointFilterDelegate's signature.

Customer Impact

Without this bug fix, user applications that contain minimal API endpoints that return value types and use endpoint filters will fail to launch. Viable workarounds exist (for example, wrapping the value return in aResults.Ok), but they are difficult for the typical user to discover.

Regression?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

Scope of impact is limited to minimal APIs + endpoint filters + compile-time code generation.

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

@captainsafiacaptainsafia added area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etc feature-rdf labelsSep 19, 2024
@dotnet-policy-servicedotnet-policy-servicebot added this to the8.0.x milestoneSep 19, 2024
@captainsafiacaptainsafia added the Servicing-considerShiproom approval is required for the issue labelSep 19, 2024
@captainsafiacaptainsafia changed the titleAdd explicit conversion for value-type returning handlers with filters[release/8/0] Add explicit conversion for value-type returning handlers with filtersSep 19, 2024
@captainsafiacaptainsafia changed the title[release/8/0] Add explicit conversion for value-type returning handlers with filters[release/8.0] Add explicit conversion for value-type returning handlers with filtersSep 19, 2024
@BrennanConroy
Copy link
Member

Does RDG handle this? I did a quick search and wasn't able to find any tests that cover it for RDG

@captainsafia
Copy link
MemberAuthor

Does RDG handle this? I did a quick search and wasn't able to find any tests that cover it for RDG

RDG doesn't have this problem because the compiler will do the conversion implicitly when a value type is passed into thethis method.

As for tests, I don't believe we have test coverage for this scenario in RDG but I can add one (or move the tests that we have here to the shared infrastructure).

@captainsafia
Copy link
MemberAuthor

Approved via email.

@captainsafiacaptainsafia added Servicing-approvedShiproom has approved the issue and removed Servicing-considerShiproom approval is required for the issue labelsOct 1, 2024
@wtgodbewtgodbe merged commitaab1413 intorelease/8.0Oct 2, 2024
@wtgodbewtgodbe deleted the safia/backport-filers-value-type-fix branchOctober 2, 2024 18:33
@dotnet-policy-servicedotnet-policy-servicebot modified the milestones:8.0.x,8.0.11Oct 2, 2024
This was referencedNov 17, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@BrennanConroyBrennanConroyBrennanConroy approved these changes

@halter73halter73Awaiting requested review from halter73halter73 is a code owner

Assignees

No one assigned

Labels

area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-rdfServicing-approvedShiproom has approved the issue

Projects

None yet

Milestone

8.0.11

Development

Successfully merging this pull request may close these issues.

4 participants

@captainsafia@BrennanConroy@wtgodbe

[8]ページ先頭

©2009-2025 Movatter.jp