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.
Uh oh!
There was an error while loading. Please reload this page.
-
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 handleTaskandValueTaskat the same time. AnITaskinterface could solve both problems.Before
After
A proposal already exists to make
Taskcovariant, meaningTask<string>could be cast toTask<object>. However, this proposal would also handleValueTask, and any other type ofTaskadded in the future.ITaskwould look something like this:Both
TaskandValueTaskwould inherit fromITask. Additionally, asynchronous functions would be able to returnITaskinstead ofTaskorValueTask.Beta Was this translation helpful? Give feedback.
All reactions