4

我正在尝试使用最新版本的 dnSpy 反汇编我的 .NET core 3.1 二进制文件,但得到如下输出:

在此处输入图像描述

原来的方法:

public async Task<List<FirmwarePackage>> CalculatePackagesDeltaAsync(List<FirmwarePackage> firmwarePackages) {
  var packagesToUpdate = await GetPackageDifferences(firmwarePackages);

  // sort packages
  // "version-update" packages should be updated last, with "mez" being last
  packagesToUpdate = packagesToUpdate
    .OrderBy(x => x.TargetType)
    .ThenBy(x => x.Name)
    .ToList();

  packagesToUpdate.RemoveAll(x => x.Name == "version-update");

  var versionPkgs = firmwarePackages
    .Where(x => x.Name == "version-update")
    .OrderBy(x => x.TargetType);

  packagesToUpdate.AddRange(versionPkgs);
  return packagesToUpdate;
}

这是正常的吗?我怎样才能把它变成更容易理解的东西。尝试调试这是一场噩梦。

在 github repoissues上不可用,这就是我在这里问的原因。

4

1 回答 1

3

What you can see there is totally normal. What you have cropped is just one part of the generated code.

The highlighted code saves the local variables (as fields of the state machine) to preserve their state.

The code generation is quite complex because there are couple of use cases that are handled in the different way. But the generic ideas are written quite well in the following articles:

Stephen Toub has written a blog post which reveals some of the optimizations that the .NET team has accomplished in .NET 5.

于 2020-12-02T15:08:58.313 回答