dnSpyEx/dnSpy

Failed to decompile async Task function: "<>t__builder"

g3rzi opened this issue · 1 comments

dnSpyEx version

6.4.1

Describe the Bug

When loading a .NET DLL from Microsoft Azure DevOps agent: Agent.Worker.dll, some functions, do not decompile correctly.
It shows the content with wrong data, some variables like <>t__builder, <>4__this, and so on. See in the "Actual Behaviour" how the function looks like.

How To Reproduce

Go to azure-pipelines-agent release and download the vsts-agent-win-x64-3.230.0.zip.

Extract the Agent.Worker.dll from ZIP:

C:\Users\<username>\Downloads\vsts-agent-win-x64-3.230.0.zip\bin\Agent.Worker.dll  

Start dnSpy 6.4.1, and open Agent.Worker.dll: File -> Open -> Choose Agent.Worker.dll and press Open.
Go to the class JobRunner: Agent.Worker -> Agent.Worker.dll -> Microsoft.VisualStudio.Services.Agent.Worker -> JobRunner.

Then search for the function RunAsync (line 29) and you will see the function.

This is what it looks like:
image

Expected Behavior

The function should look like it appears in the source code:

public async Task<TaskResult> RunAsync(Pipelines.AgentJobRequestMessage message, CancellationToken jobRequestCancellationToken)
{
            // Validate parameters.
            Trace.Entering();
            ArgUtil.NotNull(message, nameof(message));
            ArgUtil.NotNull(message.Resources, nameof(message.Resources));
            ArgUtil.NotNull(message.Variables, nameof(message.Variables));
            ArgUtil.NotNull(message.Steps, nameof(message.Steps));
            Trace.Info("Job ID {0}", message.JobId);

            DateTime jobStartTimeUtc = DateTime.UtcNow;
...

}

Actual Behavior

When decompiling it with dnSpy 6.4.1 it doesn't show the real content of the function:

public Task<TaskResult> RunAsync(Microsoft.TeamFoundation.DistributedTask.Pipelines.AgentJobRequestMessage message, CancellationToken jobRequestCancellationToken)
{
	JobRunner.<RunAsync>d__4 <RunAsync>d__;
	<RunAsync>d__.<>t__builder = AsyncTaskMethodBuilder<TaskResult>.Create();
	<RunAsync>d__.<>4__this = this;
	<RunAsync>d__.message = message;
	<RunAsync>d__.jobRequestCancellationToken = jobRequestCancellationToken;
	<RunAsync>d__.<>1__state = -1;
	<RunAsync>d__.<>t__builder.Start<JobRunner.<RunAsync>d__4>(ref <RunAsync>d__);
	return <RunAsync>d__.<>t__builder.Task;
}

Additional Context

With ILSpy (version 8.2.7535) it works correctly:
image

this new lang feature is supported in newer version of ILSpy, while currently dnspy is heavily modified old version of ILSpy. Need to wait for the new ILSpy based version works, then this will be solved.

can refer issue 5 for details

#5