-
Notifications
You must be signed in to change notification settings - Fork 5
Covariant return types with ITask #15
Copy link
Copy link
Open
Description
Not really an issue per say, just wanted to suggest that you update your documentation to reflect that this also works really well with covariant return type support that was added in C# 9.0.
Here's a small example if you want one for your tests or docs:
[TestFixture]
public class MyTests
{
[Test]
public async Task MyTest()
{
var pz = new PettingZoo();
var an = await pz.GetAnimal().ConfigureAwait(false);
Assert.AreEqual("Cat", an.Name);
}
}
public class Zoo
{
public virtual async ITask<Animal> GetAnimal()
{
await Task.Delay(0).ConfigureAwait(false);
return new Animal();
}
}
public class PettingZoo : Zoo
{
public override async ITask<Cat> GetAnimal()
{
await Task.Delay(0).ConfigureAwait(false);
return new Cat();
}
}
public class Animal
{
public string Name { get; set; } = "Animal";
}
public class Cat : Animal
{
public Cat()
{
Name = "Cat";
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels