【问题标题】:What does it mean when dotpeek fills a method with "// Stub method ('ret' instruction only)"当dotpeek用“//存根方法(仅'ret'指令)”填充方法时是什么意思
【发布时间】:2016-05-13 04:06:41
【问题描述】:

我偶然发现了这个question 询问 linq 的聚合算法,并认为这是最好通过逆向工程来回答的问题,所以我去了 Visual Studio 并编写了以下代码(这段代码是为了使用在一个 Compact 框架项目中,Combine 函数只能有两个参数):

    public static string Combine(string path1, params string[] paths)
    {
        return paths.Aggregate(path1, System.IO.Path.Combine);
    }

然后我将光标设置到 Aggregate 方法,按 F12 键(我安装了 Resharper),然后被引导到以下代码:

// Decompiled with JetBrains decompiler
// Type: System.Linq.Enumerable
// Assembly: System.Core, Version=3.9.0.0, Culture=neutral, PublicKeyToken=969db8053d3322ac, Retargetable=Yes
// MVID: 77D23A6E-E19D-435B-9CBB-733D74F92072
// Assembly location: C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\WindowsEmbeddedCompact\v3.9\System.Core.dll

Lots of stuff...

public static TAccumulate Aggregate<TSource, TAccumulate>(this IEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> func)
{
  // Stub method ('ret' instruction only)
}

现在显然,这不是我调用 Aggregate 时运行的代码,因为... Aggregate 做了一些事情。问题是反编译器的这个结果究竟意味着什么?什么是对“聚合”方法进行逆向工程的合适方法?

--编辑--

我刚刚意识到我上面所说的只有在 Compact Framework 项目中完成时才是正确的,当我反编译标准框架的 Aggregate 时,我得到了正确的源代码。

【问题讨论】:

  • 附带说明:您知道源代码是免费提供的吗? referencesource.microsoft.com/#System.Core/System/Linq/…
  • 哇,谢谢!我不是,然而,在这种情况下,我已经知道“聚合”是做什么的,这不是我第一次遇到这种情况,所以我仍然有兴趣了解如何正确反编译。

标签: c# linq compact-framework reverse-engineering dotpeek


【解决方案1】:

如果您想反编译 CF 程序集,您必须使用实际的 BCL,而不是 Studio 中通常用作参考的存根(不,我不知道他们为什么这样做)。我看到您使用的是 3.9,所以我不确定您需要查看的路径,但是对于 3.5,您可以在此处找到它们:

C:\Program Files (x86)\Microsoft.NET\SDK\CompactFramework\v3.5\Debugger\BCL

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-04-10
    • 2013-12-29
    • 1970-01-01
    • 2013-03-29
    • 2013-01-30
    • 2016-02-26
    • 2023-03-21
    • 1970-01-01
    相关资源
    最近更新 更多