Allow ConditionalAttribute for Task-returning method #366
Replies: 4 comments
-
Would it make sense to extend this to no-result tasklikes? (Like a potential non-generic I don't know if such tasklikes are actually useful, but they do work. |
Beta Was this translation helpful? Give feedback.
-
@svick I think that would definitely make sense. Is the reason for limiting it to void that it avoids invalid code when the return value is used? Thing is that a task can also be assigned to a variable to await it later - so that might make the IL invalid, wouldn't it? |
Beta Was this translation helpful? Give feedback.
-
@Mafii The C# compiler would just emit code to push |
Beta Was this translation helpful? Give feedback.
-
Few more questions:
|
Beta Was this translation helpful? Give feedback.
-
The asynchronous equivalent of a
void
-returning method is aTask
-returning method. It seems natural to extend the valid uses ofConditionalAttribute
to includeTask
-returning methods, with the semantics that for a "missing" method, its return value is a completedTask
. This behavior is the same as modern auto-mocking libraries.See also [http://stackoverflow.com/questions/43056131/mark-async-methods-that-just-return-a-task-with-the-conditional-attribute](this question on SO).
Beta Was this translation helpful? Give feedback.
All reactions