Skip to content

Instantly share code, notes, and snippets.

@Joe4evr
Last active June 28, 2017 22:31
Show Gist options
  • Save Joe4evr/1ba4e5abd7d7f122244cd7d681a45529 to your computer and use it in GitHub Desktop.
Save Joe4evr/1ba4e5abd7d7f122244cd7d681a45529 to your computer and use it in GitHub Desktop.
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