Support duck-typed awaitables and task-like types for Task/Async-related analyzers #1535
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.
Description
These changes add the same logic for checking duck-typed awaitables and task-like types that is currently in Roslyn.
This resolves #1529 - specifically, these analyzers/refactorings become aware of custom awaitables/custom task-like types:
Async
)ConfigureAwait(false)
)async
/await
)async
/await
)Remarks
RCS1090's behaviour is less obvious here - it seems there is no official stance for duck-typing
ConfigureAwait
(even Roslyn isn't perfectly consistent), but I'm of the opinion that if the rest of the ducks are quacking, it's better to join the flock 😄 The result is that these checks are relaxed from theTask
-specificConfiguredTaskAwaitable(`1)
return type to any awaitable return type.I noticed there were some checks for WinRT async interfaces, these are covered as there's an extension
GetAwaiter()
method available on those types.I'm not experienced with analyzers and their edge cases so it's possible I've missed writing some obvious tests, I'd love to get your feedback.