using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
static void Main(string[] args)
Exception exception = null;
exception = ex.Demystify();
Console.WriteLine(exception);
static Action<string, bool> s_action = (string s, bool b) => s_func(s, b);
static Func<string, bool, (string val, bool)> s_func = (string s, bool b) => (RefMethod(s), b);
Action<Action<object>, object> _action = (Action<object> lambda, object state) => lambda(state);
[MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)]
Program() : this(() => Start())
[MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)]
Program(Action action) => RunAction((state) => _action((s) => action(), state), null);
[MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)]
static IEnumerable<string> Iterator(int startAt)
var list = new List<int>() { 1, 2, 3, 4 };
foreach (var item in list)
yield return item.ToString();
[MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)]
static async Task<string> MethodAsync(int value)
return GenericClass<byte>.GenericMethod(ref value);
[MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)]
static async Task<string> MethodAsync<TValue>(TValue value)
return await MethodLocalAsync();
async Task<string> MethodLocalAsync()
return await MethodAsync(1);
[MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)]
static void RunAction(Action<object> lambda, object state) => lambda(state);
[MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)]
static string RunLambda(Func<string> lambda) => lambda();
[MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)]
static (string val, bool) Method(string value)
#pragma warning disable IDE0039
Func<string> func = () => MethodAsync(value).GetAwaiter().GetResult();
#pragma warning restore IDE0039
var anonType = new { func };
return (RunLambda(() => anonType.func()), true);
[MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)]
static ref string RefMethod(int value) => ref s;
[MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)]
static string RefMethod(in string value)
return LocalFuncParam(value).ToString();
int LocalFuncParam(string s)
return int.Parse(LocalFuncRefReturn());
ref string LocalFuncRefReturn()
[MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)]
return LocalFunc2(true, false).ToString();
bool LocalFunc2(bool b1, bool b2)
[MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)]
static ref string RefMethod(bool value) => ref s;
[MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)]
static void Start((string val, bool) param) => s_action.Invoke(param.val, param.Item2);
class GenericClass<TSuperType>
[MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)]
public static string GenericMethod<TSubType>(ref TSubType value)
for (var i = 0; i < 10; i++)
returnVal += string.Join(", ", Iterator(5).Select(s => s));
throw new Exception(ex.Message, ex);