2

我可以在我的对象浏览器中查看引用库中的所有方法。我希望将所有这些方法导出到文本文件。对象浏览器

我也可以访问 dotPeek,但在该软件中找不到任何导出功能。

4

2 回答 2

2

我不得不承认我不确定你如何在 Visual Studio 中做到这一点,但你可以通过编程使用反射:

System.IO.File.WriteAllLines(myFileName,
                System.Reflection.Assembly.LoadFile(myDllPath)
                    .GetType(className)
                    .GetMethods()
                    .Select(m => m.Name)
                    .ToArray());

预计到达时间:

如果您想要屏幕截图中的方法或 DLL 中的所有方法,我不是 100%,所以我更新了第二个变体:

 System.IO.File.WriteAllLines(myFileName,
                System.Reflection.Assembly.LoadFile(myDllPath)
                    .GetTypes()                    
                    .SelectMany(t => t.GetMethods())
                    .Select(m => m.Name)
                    .ToArray());
于 2014-01-14T15:12:17.493 回答
2

您可以使用 PowerShell 获取给定程序集中的类型/方法列表。

$AssemblyList = [System.AppDomain]::CurrentDomain.GetAssemblies();

foreach ($Type in $AssemblyList[5].GetTypes()) {
    $MethodList = $Type.GetMethods();
    foreach ($Method in $MethodList) {
        $Type.Name + ' ' + $Method.Name;
    }
}

您还可以对特定文件路径进行仅反射加载:

$Assembly = [System.Reflection.Assembly]::ReflectionOnlyLoadFrom('c:\path\to\assembly.dll');

foreach ($Type in $Assembly.GetTypes()) {
    $MethodList = $Type.GetMethods();
    foreach ($Method in $MethodList) {
        $Type.Name + ' ' + $Method.Name;
    }
}
于 2014-01-14T15:12:35.260 回答