Skip to content

Commit

Permalink
Add failing tests for covariant return types involving a variant gene…
Browse files Browse the repository at this point in the history
…ric interface
  • Loading branch information
stakx committed Dec 29, 2022
1 parent ee08309 commit be22332
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public void Reflection_returns_methods_from_a_derived_class_before_methods_from_
[TestCase(typeof(DerivedClassWithStringInsteadOfObject))]
[TestCase(typeof(DerivedClassWithStringInsteadOfInterface))]
[TestCase(typeof(DerivedClassWithStringInsteadOfGenericArg))]
[TestCase(typeof(BottleOfWater))]
public void Can_proxy_type_having_method_with_covariant_return(Type classToProxy)
{
_ = generator.CreateClassProxy(classToProxy, new StandardInterceptor());
Expand All @@ -62,6 +63,7 @@ public void Can_proxy_type_having_method_with_covariant_return(Type classToProxy
[TestCase(typeof(DerivedClassWithStringInsteadOfObject), typeof(string))]
[TestCase(typeof(DerivedClassWithStringInsteadOfInterface), typeof(string))]
[TestCase(typeof(DerivedClassWithStringInsteadOfGenericArg), typeof(string))]
[TestCase(typeof(BottleOfWater), typeof(Glass<Water>))]
public void Proxied_method_has_correct_return_type(Type classToProxy, Type expectedMethodReturnType)
{
var proxy = generator.CreateClassProxy(classToProxy, new StandardInterceptor());
Expand Down Expand Up @@ -116,6 +118,22 @@ public class DerivedClassWithStringInsteadOfGenericArg : BaseClassWithGenericArg
{
public override string Method() => nameof(DerivedClassWithStringInsteadOfGenericArg);
}

public interface Glass<out T> { }

public class Liquid { }

public class Water : Liquid { }

public class BottleOfLiquid
{
public virtual Glass<Liquid> Method() => default(Glass<Liquid>);
}

public class BottleOfWater : BottleOfLiquid
{
public override Glass<Water> Method() => default(Glass<Water>);
}
}
}

Expand Down

0 comments on commit be22332

Please sign in to comment.