Task<child> is not convertible to Task<parent>, because in .NET only interfaces and delegates, but not classes, may have convariant generic parameters. Explicitly specifying the type parameter of FromResult<T> is the correct way.
Task<parent> task = Task.FromResult<parent>(
This does not:
Task<parent> task = Task.FromResult(
I tried the following code and I didn't get a type cast exception:
child : parent
async Task Test()
var mock = Mock.Create<ITest>();
Mock.Arrange(() => mock.Test())
child o = await mock.Test()
A more complete example would help examine the issue.
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Telerik Feedback Portal
and vote to affect the priority of the items