Replies: 2 comments 6 replies
-
.... I think I'm immediately concerned about any code where you're handling arbitrary object types like that. The example chosen feels like it would emerge from a design smell of some sort, and would be better handled in some other fashion to begin with. Does this represent some of your real-world code? If so, what is the particular problem you're trying to solve by resolving arbitrary object types this way? |
Beta Was this translation helpful? Give feedback.
-
The example is misusing Since |
Beta Was this translation helpful? Give feedback.
-
Currently, it can be very tricky to work with tasks in reflection. For example, if you have a
Task<T>
cast to anobject
, there is no way to get the result without reflection. Additionally, there is no way to handleTask
andValueTask
at the same time. AnITask
interface could solve both problems.Before
After
A proposal already exists to make
Task
covariant, meaningTask<string>
could be cast toTask<object>
. However, this proposal would also handleValueTask
, and any other type ofTask
added in the future.ITask
would look something like this:Both
Task
andValueTask
would inherit fromITask
. Additionally, asynchronous functions would be able to returnITask
instead ofTask
orValueTask
.Beta Was this translation helpful? Give feedback.
All reactions