gpt4 book ai didi

C# AsyncStateMachine反编译

转载 作者:太空狗 更新时间:2023-10-30 01:30:25 29 4
gpt4 key购买 nike

我的代码几乎可以正常工作,但是 OnRequest 方法充满了错误,我看到它是我认为的编译代码。是否有助于将此代码变成人类可读的代码?

[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;
}

或者我在这里很无助,我不知道那是什么,如果我无法解决这个问题,我希望在最坏的情况下得到解释。

最佳答案

字符<>无效 C#对于类型和变量名称,但它们在 CIL 中完全有效代码。

ILSpy 不会“规范化”名称,因此您会得到不可编译的代码,但您可以删除特殊字符来修复它:

[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;
}

如果您还实现了引用类型,则可以完美编译:

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();
}
}

关于C# AsyncStateMachine反编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45216388/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com