Last active
June 28, 2017 22:31
-
-
Save Joe4evr/1ba4e5abd7d7f122244cd7d681a45529 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Reflection; | |
using System.Threading.Tasks; | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var method = typeof(Program).GetMethod(nameof(Foo), BindingFlags.Static | BindingFlags.NonPublic); | |
var task = method.Invoke(new object(), Array.Empty<object>()); | |
if (task is Task<IResult> returnTask) | |
{ | |
Console.WriteLine("Yep"); | |
} | |
else | |
{ | |
Console.WriteLine("Nope"); | |
} | |
Console.ReadLine(); | |
} | |
static Task<RuntimeResult> Foo() => Task.FromResult<RuntimeResult>(new MyRuntimeResult()); | |
} | |
interface IResult | |
{ | |
} | |
abstract class RuntimeResult : IResult | |
{ | |
} | |
class MyRuntimeResult : RuntimeResult | |
{ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment