Propagate asynchrony through member access expressions
- Dominant language
- No language data
- Stars
- 328
- Forks
- 71
- PR merge metrics
- No merged PRs in 30d
Description
It's inconvenient to access a member of the result of an Await operation because you have to backtrack (I hate backtracking) and wrap the entire expression in parenthesis. Once I recall having to even write a call like this:
`Dim si = (Await (Await context.GetDocumentAsync()).GetSemanticModalAsync()).GetSymbolInfo(node)`
Visual Basic is nothing if not a constant struggle against the tyranny of parentheses. I think we can apply a similar trick to what we do for method calls and just elide some intermediate parentheses so you could write the above as:
`Dim si = Await context.GetDocumentAsync().GetSemanticModelAsync().GetSymbolInfo(node)`
So basically, if a member access on an awaitable type fails _and_ that member access would succeed on the type of GetAwaiter().GetResult() we insert an implicit Await _but_ the result type of the expression becomes "asynchronous" and must ultimately be awaited. I think that cleans up the code without harming readability, particularly if the -Async naming convention is used.
Of course, for this to work at all for class libraries we'd need to do #115
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.