C # AsyncStateMachine Decompile
I have almost working code, but the OnRequest
method is full of errors, I can see that it has compiled the code I think. Any help to make this code human-readable code?
[AsyncStateMachine(typeof(Service1.<OnRequest>d__24))]
public Task OnRequest(object sender, SessionEventArgs e)
{
Service1.<OnRequest>d__24 <OnRequest>d__;
<OnRequest>d__.<>4__this = this;
<OnRequest>d__.e = e;
<OnRequest>d__.<>t__builder = AsyncTaskMethodBuilder.Create();
<OnRequest>d__.<>1__state = -1;
AsyncTaskMethodBuilder <>t__builder = <OnRequest>d__.<>t__builder;
<>t__builder.Start<Service1.<OnRequest>d__24>(ref <OnRequest>d__);
return <OnRequest>d__.<>t__builder.Task;
}
Or I'm helpless here, I don't know what it is and I would like to explain the worst case if I don't have a solution for this.
source to share
The symbols <
and are >
not valid C#
for type and variable names, but they work fine in code CIL
.
ILSpy doesn't "normalize" names, so you end up with code that doesn't compile, but you can simply remove special characters to fix it:
[AsyncStateMachine(typeof(Service1.OnRequestd__24))]
public Task OnRequest(object sender, SessionEventArgs e)
{
Service1.OnRequestd__24 OnRequestd__;
OnRequestd__.__this = this;
OnRequestd__.e = e;
OnRequestd__.t__builder = AsyncTaskMethodBuilder.Create();
OnRequestd__.__state = -1;
AsyncTaskMethodBuilder t__builder = OnRequestd__.t__builder;
t__builder.Start<Service1.OnRequestd__24>(ref OnRequestd__);
return OnRequestd__.t__builder.Task;
}
This compiles fine if you also implement reference types:
public class Service1
{
public struct OnRequestd__24 : IAsyncStateMachine
{
public ObjectPoolAutoTest __this;
public SessionEventArgs e;
public AsyncTaskMethodBuilder t__builder;
public int __state;
public void MoveNext() => throw new NotImplementedException();
public void SetStateMachine(IAsyncStateMachine stateMachine) => throw new NotImplementedException();
}
}
source to share