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
This repository was archived by the owner on Dec 14, 2018. It is now read-only.
/MvcPublic archive
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

Support F# async in actions #5570

Closed
Closed
Assignees
SteveSandersonMS
@enricosada

Description

@enricosada

Support F#async like theTask based async in actions.

So an action likethe following can be used OOTB.

memberthis.About()=async{let!msg= getDescription()    this.ViewData.["Message"]<- msgreturn this.View()}

I added anexample aspnet project with both F# async and current workaround actions.
Example is based ondotnet new -l fsharp -t web template inpreview4, but is the same for all sdk versions (preview2 etc)

The f# asyncHome/About doesnt work (async class is converted as string =>{}), converting asTask works inHome/About2

The workaround is to callAsync.StartAsTask before returning theFSharpAsync, so is converted asTask.

How to implement that.

Like xunit does, recognize the result isFSharpAsync and invokeAsync.StartAsTask (ref xunit commit to add f# async supportxunit/xunit@a2aa665 )

In previous aspnet was possibile to use anActionResult.

Speaking with@davidfowl he directed me intoObjectMethodExecutor class.

It should not give runtime performance penality (f# or c#), because it's done at initialization step also for normalTask, so at runtime just use a different delegate configured inObjectMethodExecutor (inGetCoerceMethodCallExpression?)

/cc@panesofglass

Metadata

Metadata

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp