Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
namespace DecompilationSpying
{
public class AsyncSleepyMethods
{
public AsyncSleepyMethods()
{
base.\u002Ector();
}
public void Sleepy()
{
Task.Delay(1000).Wait();
}
public void SleepyComplicated(Action slee)
{
slee();
}
public Task<string> Sleepy5()
{
AsyncSleepyMethods.\u003CSleepy5\u003Ed__3 stateMachine = new AsyncSleepyMethods.\u003CSleepy5\u003Ed__3();
stateMachine.\u003C\u003E4__this = this;
stateMachine.\u003C\u003Et__builder = AsyncTaskMethodBuilder<string>.Create();
stateMachine.\u003C\u003E1__state = -1;
stateMachine.\u003C\u003Et__builder.Start<AsyncSleepyMethods.\u003CSleepy5\u003Ed__3>(ref stateMachine);
return stateMachine.\u003C\u003Et__builder.Task;
}
public Task SleepyComplicated(Func<Task> slee)
{
AsyncSleepyMethods.\u003CSleepyComplicated\u003Ed__4 stateMachine = new AsyncSleepyMethods.\u003CSleepyComplicated\u003Ed__4();
stateMachine.\u003C\u003E4__this = this;
stateMachine.slee = slee;
stateMachine.\u003C\u003Et__builder = AsyncTaskMethodBuilder.Create();
stateMachine.\u003C\u003E1__state = -1;
stateMachine.\u003C\u003Et__builder.Start<AsyncSleepyMethods.\u003CSleepyComplicated\u003Ed__4>(ref stateMachine);
return stateMachine.\u003C\u003Et__builder.Task;
}
public Task<string> CallSleepyComplicated()
{
AsyncSleepyMethods.\u003CCallSleepyComplicated\u003Ed__5 stateMachine = new AsyncSleepyMethods.\u003CCallSleepyComplicated\u003Ed__5();
stateMachine.\u003C\u003E4__this = this;
stateMachine.\u003C\u003Et__builder = AsyncTaskMethodBuilder<string>.Create();
stateMachine.\u003C\u003E1__state = -1;
stateMachine.\u003C\u003Et__builder.Start<AsyncSleepyMethods.\u003CCallSleepyComplicated\u003Ed__5>(ref stateMachine);
return stateMachine.\u003C\u003Et__builder.Task;
}
public Task<string> CallSleepyComplicatedAwaitingWithFunc(Func<Task<string>> call)
{
AsyncSleepyMethods.\u003CCallSleepyComplicatedAwaitingWithFunc\u003Ed__6 stateMachine = new AsyncSleepyMethods.\u003CCallSleepyComplicatedAwaitingWithFunc\u003Ed__6();
stateMachine.\u003C\u003E4__this = this;
stateMachine.call = call;
stateMachine.\u003C\u003Et__builder = AsyncTaskMethodBuilder<string>.Create();
stateMachine.\u003C\u003E1__state = -1;
stateMachine.\u003C\u003Et__builder.Start<AsyncSleepyMethods.\u003CCallSleepyComplicatedAwaitingWithFunc\u003Ed__6>(ref stateMachine);
return stateMachine.\u003C\u003Et__builder.Task;
}
public Task<string> CallSleepyComplicatedAwaiting()
{
AsyncSleepyMethods.\u003CCallSleepyComplicatedAwaiting\u003Ed__7 stateMachine = new AsyncSleepyMethods.\u003CCallSleepyComplicatedAwaiting\u003Ed__7();
stateMachine.\u003C\u003E4__this = this;
stateMachine.\u003C\u003Et__builder = AsyncTaskMethodBuilder<string>.Create();
stateMachine.\u003C\u003E1__state = -1;
stateMachine.\u003C\u003Et__builder.Start<AsyncSleepyMethods.\u003CCallSleepyComplicatedAwaiting\u003Ed__7>(ref stateMachine);
return stateMachine.\u003C\u003Et__builder.Task;
}
[CompilerGenerated]
private void \u003CSleepy5\u003Eb__3_0()
{
this.Sleepy();
}
[CompilerGenerated]
private Task<string> \u003CCallSleepyComplicatedAwaiting\u003Eb__7_0()
{
AsyncSleepyMethods.\u003C\u003CCallSleepyComplicatedAwaiting\u003Eb__7_0\u003Ed stateMachine = new AsyncSleepyMethods.\u003C\u003CCallSleepyComplicatedAwaiting\u003Eb__7_0\u003Ed();
stateMachine.\u003C\u003E4__this = this;
stateMachine.\u003C\u003Et__builder = AsyncTaskMethodBuilder<string>.Create();
stateMachine.\u003C\u003E1__state = -1;
stateMachine.\u003C\u003Et__builder.Start<AsyncSleepyMethods.\u003C\u003CCallSleepyComplicatedAwaiting\u003Eb__7_0\u003Ed>(ref stateMachine);
return stateMachine.\u003C\u003Et__builder.Task;
}
[CompilerGenerated]
private sealed class \u003CSleepy5\u003Ed__3 : IAsyncStateMachine
{
public int \u003C\u003E1__state;
public AsyncTaskMethodBuilder<string> \u003C\u003Et__builder;
public AsyncSleepyMethods \u003C\u003E4__this;
private TaskAwaiter \u003C\u003Eu__1;
public \u003CSleepy5\u003Ed__3()
{
base.\u002Ector();
}
void IAsyncStateMachine.MoveNext()
{
int num1 = this.\u003C\u003E1__state;
string result;
try
{
TaskAwaiter awaiter;
int num2;
if (num1 != 0)
{
// ISSUE: method pointer
awaiter = Task.Run(new Action((object) this.\u003C\u003E4__this, __methodptr(\u003CSleepy5\u003Eb__3_0))).GetAwaiter();
if (!awaiter.IsCompleted)
{
this.\u003C\u003E1__state = num2 = 0;
this.\u003C\u003Eu__1 = awaiter;
AsyncSleepyMethods.\u003CSleepy5\u003Ed__3 stateMachine = this;
this.\u003C\u003Et__builder.AwaitUnsafeOnCompleted<TaskAwaiter, AsyncSleepyMethods.\u003CSleepy5\u003Ed__3>(ref awaiter, ref stateMachine);
return;
}
}
else
{
awaiter = this.\u003C\u003Eu__1;
this.\u003C\u003Eu__1 = new TaskAwaiter();
this.\u003C\u003E1__state = num2 = -1;
}
awaiter.GetResult();
awaiter = new TaskAwaiter();
result = "ready Sleepy5" + Environment.NewLine;
}
catch (Exception ex)
{
this.\u003C\u003E1__state = -2;
this.\u003C\u003Et__builder.SetException(ex);
return;
}
this.\u003C\u003E1__state = -2;
this.\u003C\u003Et__builder.SetResult(result);
}
[DebuggerHidden]
void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine)
{
}
}
[CompilerGenerated]
private sealed class \u003CSleepyComplicated\u003Ed__4 : IAsyncStateMachine
{
public int \u003C\u003E1__state;
public AsyncTaskMethodBuilder \u003C\u003Et__builder;
public Func<Task> slee;
public AsyncSleepyMethods \u003C\u003E4__this;
private TaskAwaiter \u003C\u003Eu__1;
public \u003CSleepyComplicated\u003Ed__4()
{
base.\u002Ector();
}
void IAsyncStateMachine.MoveNext()
{
int num1 = this.\u003C\u003E1__state;
try
{
TaskAwaiter awaiter;
int num2;
if (num1 != 0)
{
awaiter = this.slee().GetAwaiter();
if (!awaiter.IsCompleted)
{
this.\u003C\u003E1__state = num2 = 0;
this.\u003C\u003Eu__1 = awaiter;
AsyncSleepyMethods.\u003CSleepyComplicated\u003Ed__4 stateMachine = this;
this.\u003C\u003Et__builder.AwaitUnsafeOnCompleted<TaskAwaiter, AsyncSleepyMethods.\u003CSleepyComplicated\u003Ed__4>(ref awaiter, ref stateMachine);
return;
}
}
else
{
awaiter = this.\u003C\u003Eu__1;
this.\u003C\u003Eu__1 = new TaskAwaiter();
this.\u003C\u003E1__state = num2 = -1;
}
awaiter.GetResult();
awaiter = new TaskAwaiter();
}
catch (Exception ex)
{
this.\u003C\u003E1__state = -2;
this.\u003C\u003Et__builder.SetException(ex);
return;
}
this.\u003C\u003E1__state = -2;
this.\u003C\u003Et__builder.SetResult();
}
[DebuggerHidden]
void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine)
{
}
}
[CompilerGenerated]
private sealed class \u003CCallSleepyComplicated\u003Ed__5 : IAsyncStateMachine
{
public int \u003C\u003E1__state;
public AsyncTaskMethodBuilder<string> \u003C\u003Et__builder;
public AsyncSleepyMethods \u003C\u003E4__this;
private string \u003Cresult\u003E5__1;
private string \u003C\u003Es__2;
private string \u003C\u003Es__3;
private string \u003C\u003Es__4;
private string \u003C\u003Es__5;
private TaskAwaiter<string> \u003C\u003Eu__1;
public \u003CCallSleepyComplicated\u003Ed__5()
{
base.\u002Ector();
}
void IAsyncStateMachine.MoveNext()
{
int num1 = this.\u003C\u003E1__state;
string result51;
try
{
TaskAwaiter<string> awaiter1;
int num2;
TaskAwaiter<string> awaiter2;
if (num1 != 0)
{
if (num1 != 1)
{
this.\u003Cresult\u003E5__1 = string.Empty;
this.\u003C\u003Es__2 = this.\u003Cresult\u003E5__1;
awaiter1 = this.\u003C\u003E4__this.Sleepy5().GetAwaiter();
if (!awaiter1.IsCompleted)
{
this.\u003C\u003E1__state = num2 = 0;
this.\u003C\u003Eu__1 = awaiter1;
AsyncSleepyMethods.\u003CCallSleepyComplicated\u003Ed__5 stateMachine = this;
this.\u003C\u003Et__builder.AwaitUnsafeOnCompleted<TaskAwaiter<string>, AsyncSleepyMethods.\u003CCallSleepyComplicated\u003Ed__5>(ref awaiter1, ref stateMachine);
return;
}
}
else
{
awaiter2 = this.\u003C\u003Eu__1;
this.\u003C\u003Eu__1 = new TaskAwaiter<string>();
this.\u003C\u003E1__state = num2 = -1;
goto label_9;
}
}
else
{
awaiter1 = this.\u003C\u003Eu__1;
this.\u003C\u003Eu__1 = new TaskAwaiter<string>();
this.\u003C\u003E1__state = num2 = -1;
}
string result1 = awaiter1.GetResult();
TaskAwaiter<string> taskAwaiter = new TaskAwaiter<string>();
this.\u003C\u003Es__3 = result1;
this.\u003Cresult\u003E5__1 = this.\u003C\u003Es__2 + this.\u003C\u003Es__3;
this.\u003C\u003Es__2 = (string) null;
this.\u003C\u003Es__3 = (string) null;
this.\u003Cresult\u003E5__1 = this.\u003Cresult\u003E5__1 + "in Call sleepy complicated " + Environment.NewLine;
this.\u003C\u003Es__4 = this.\u003Cresult\u003E5__1;
awaiter2 = this.\u003C\u003E4__this.Sleepy5().GetAwaiter();
if (!awaiter2.IsCompleted)
{
this.\u003C\u003E1__state = num2 = 1;
this.\u003C\u003Eu__1 = awaiter2;
AsyncSleepyMethods.\u003CCallSleepyComplicated\u003Ed__5 stateMachine = this;
this.\u003C\u003Et__builder.AwaitUnsafeOnCompleted<TaskAwaiter<string>, AsyncSleepyMethods.\u003CCallSleepyComplicated\u003Ed__5>(ref awaiter2, ref stateMachine);
return;
}
label_9:
string result2 = awaiter2.GetResult();
awaiter2 = new TaskAwaiter<string>();
this.\u003C\u003Es__5 = result2;
this.\u003Cresult\u003E5__1 = this.\u003C\u003Es__4 + this.\u003C\u003Es__5;
this.\u003C\u003Es__4 = (string) null;
this.\u003C\u003Es__5 = (string) null;
result51 = this.\u003Cresult\u003E5__1;
}
catch (Exception ex)
{
this.\u003C\u003E1__state = -2;
this.\u003C\u003Et__builder.SetException(ex);
return;
}
this.\u003C\u003E1__state = -2;
this.\u003C\u003Et__builder.SetResult(result51);
}
[DebuggerHidden]
void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine)
{
}
}
[CompilerGenerated]
private sealed class \u003CCallSleepyComplicatedAwaitingWithFunc\u003Ed__6 : IAsyncStateMachine
{
public int \u003C\u003E1__state;
public AsyncTaskMethodBuilder<string> \u003C\u003Et__builder;
public Func<Task<string>> call;
public AsyncSleepyMethods \u003C\u003E4__this;
private string \u003C\u003Es__1;
private TaskAwaiter<string> \u003C\u003Eu__1;
public \u003CCallSleepyComplicatedAwaitingWithFunc\u003Ed__6()
{
base.\u002Ector();
}
void IAsyncStateMachine.MoveNext()
{
int num1 = this.\u003C\u003E1__state;
string s1;
try
{
TaskAwaiter<string> awaiter;
int num2;
if (num1 != 0)
{
awaiter = this.call().GetAwaiter();
if (!awaiter.IsCompleted)
{
this.\u003C\u003E1__state = num2 = 0;
this.\u003C\u003Eu__1 = awaiter;
AsyncSleepyMethods.\u003CCallSleepyComplicatedAwaitingWithFunc\u003Ed__6 stateMachine = this;
this.\u003C\u003Et__builder.AwaitUnsafeOnCompleted<TaskAwaiter<string>, AsyncSleepyMethods.\u003CCallSleepyComplicatedAwaitingWithFunc\u003Ed__6>(ref awaiter, ref stateMachine);
return;
}
}
else
{
awaiter = this.\u003C\u003Eu__1;
this.\u003C\u003Eu__1 = new TaskAwaiter<string>();
this.\u003C\u003E1__state = num2 = -1;
}
string result = awaiter.GetResult();
awaiter = new TaskAwaiter<string>();
this.\u003C\u003Es__1 = result;
s1 = this.\u003C\u003Es__1;
}
catch (Exception ex)
{
this.\u003C\u003E1__state = -2;
this.\u003C\u003Et__builder.SetException(ex);
return;
}
this.\u003C\u003E1__state = -2;
this.\u003C\u003Et__builder.SetResult(s1);
}
[DebuggerHidden]
void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine)
{
}
}
[CompilerGenerated]
private sealed class \u003CCallSleepyComplicatedAwaiting\u003Ed__7 : IAsyncStateMachine
{
public int \u003C\u003E1__state;
public AsyncTaskMethodBuilder<string> \u003C\u003Et__builder;
public AsyncSleepyMethods \u003C\u003E4__this;
private string \u003C\u003Es__1;
private TaskAwaiter<string> \u003C\u003Eu__1;
public \u003CCallSleepyComplicatedAwaiting\u003Ed__7()
{
base.\u002Ector();
}
void IAsyncStateMachine.MoveNext()
{
int num1 = this.\u003C\u003E1__state;
string s1;
try
{
TaskAwaiter<string> awaiter;
int num2;
if (num1 != 0)
{
// ISSUE: method pointer
awaiter = this.\u003C\u003E4__this.CallSleepyComplicatedAwaitingWithFunc(new Func<Task<string>>((object) this.\u003C\u003E4__this, __methodptr(\u003CCallSleepyComplicatedAwaiting\u003Eb__7_0))).GetAwaiter();
if (!awaiter.IsCompleted)
{
this.\u003C\u003E1__state = num2 = 0;
this.\u003C\u003Eu__1 = awaiter;
AsyncSleepyMethods.\u003CCallSleepyComplicatedAwaiting\u003Ed__7 stateMachine = this;
this.\u003C\u003Et__builder.AwaitUnsafeOnCompleted<TaskAwaiter<string>, AsyncSleepyMethods.\u003CCallSleepyComplicatedAwaiting\u003Ed__7>(ref awaiter, ref stateMachine);
return;
}
}
else
{
awaiter = this.\u003C\u003Eu__1;
this.\u003C\u003Eu__1 = new TaskAwaiter<string>();
this.\u003C\u003E1__state = num2 = -1;
}
string result = awaiter.GetResult();
awaiter = new TaskAwaiter<string>();
this.\u003C\u003Es__1 = result;
s1 = this.\u003C\u003Es__1;
}
catch (Exception ex)
{
this.\u003C\u003E1__state = -2;
this.\u003C\u003Et__builder.SetException(ex);
return;
}
this.\u003C\u003E1__state = -2;
this.\u003C\u003Et__builder.SetResult(s1);
}
[DebuggerHidden]
void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine)
{
}
}
[CompilerGenerated]
private sealed class \u003C\u003CCallSleepyComplicatedAwaiting\u003Eb__7_0\u003Ed : IAsyncStateMachine
{
public int \u003C\u003E1__state;
public AsyncTaskMethodBuilder<string> \u003C\u003Et__builder;
public AsyncSleepyMethods \u003C\u003E4__this;
private string \u003C\u003Es__1;
private TaskAwaiter<string> \u003C\u003Eu__1;
public \u003C\u003CCallSleepyComplicatedAwaiting\u003Eb__7_0\u003Ed()
{
base.\u002Ector();
}
void IAsyncStateMachine.MoveNext()
{
int num1 = this.\u003C\u003E1__state;
string s1;
try
{
TaskAwaiter<string> awaiter;
int num2;
if (num1 != 0)
{
awaiter = this.\u003C\u003E4__this.CallSleepyComplicated().GetAwaiter();
if (!awaiter.IsCompleted)
{
this.\u003C\u003E1__state = num2 = 0;
this.\u003C\u003Eu__1 = awaiter;
AsyncSleepyMethods.\u003C\u003CCallSleepyComplicatedAwaiting\u003Eb__7_0\u003Ed stateMachine = this;
this.\u003C\u003Et__builder.AwaitUnsafeOnCompleted<TaskAwaiter<string>, AsyncSleepyMethods.\u003C\u003CCallSleepyComplicatedAwaiting\u003Eb__7_0\u003Ed>(ref awaiter, ref stateMachine);
return;
}
}
else
{
awaiter = this.\u003C\u003Eu__1;
this.\u003C\u003Eu__1 = new TaskAwaiter<string>();
this.\u003C\u003E1__state = num2 = -1;
}
string result = awaiter.GetResult();
awaiter = new TaskAwaiter<string>();
this.\u003C\u003Es__1 = result;
s1 = this.\u003C\u003Es__1;
}
catch (Exception ex)
{
this.\u003C\u003E1__state = -2;
this.\u003C\u003Et__builder.SetException(ex);
return;
}
this.\u003C\u003E1__state = -2;
this.\u003C\u003Et__builder.SetResult(s1);
}
[DebuggerHidden]
void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine)
{
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment