質問

I am able to see all the methods in a referenced library in my object browser. I wish to export all these methods to a text file.object browser

I also have access to dotPeek but I could not locate any export functionality in that software.

役に立ちましたか?

解決

I've got to admit I'm not sure how you could do it in Visual Studio, but programatically you can use reflection:

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

ETA:

I'm not 100% if you want the methods in the screenshot or all the methods in the DLL so I've updated with the second variant:

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

他のヒント

You can use PowerShell to get a list of types/methods in a given assembly.

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

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

You can also do a reflection-only load on a particular file path:

$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;
    }
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top