Below is my rather crude first attempt (warning: generates a huge list).
Below the if true line are some sample alternatives for testing, if you don't want the whole list.
Any improvements (extracting further documentation from the assemblies, getting member argument names, etc) would be most welcome.
Obtusely yours, OA.
- Code: Select all
"""
Get classes, methods/members, valueTypes in .NET framework
Significantly based on Andrew Hare's C# code in a thread on StackOverflow
Thread: http://stackoverflow.com/questions/2137444/exactly-how-large-is-the-net-3-5-framework-class-library
Andrew Hare: http://stackoverflow.com/users/34211/andrew-hare
"""
use System.Reflection
use System.Runtime.InteropServices
use System.Text.RegularExpressions
class Example
def main
assemblies = []
for f in Directory.getFiles(RuntimeEnvironment.getRuntimeDirectory)
if f.endsWith(".dll")
assemblies.add(f)
for name in assemblies
# We need to catch BadImageFormatException
# because not all DLLs in the runtime directory
# are CLR assemblies.
try
filename = name.toString
types = Assembly.loadFile(filename).getTypes
for t in types
if t.isClass
if true
#~ if "FileExists" in t.toString
#~ if t.toString == "System.Net.WebClient"
ms = t.getMethods
invoke = false
for m in ms
s = m.toString
if " Invoke(" in s
wordMatch = Regex.match(s, r"([\w+\.\[\]]+) Invoke(\([^\)]+\))")
if wordMatch.success
print '[t.toString][wordMatch.groups[2]] --> [wordMatch.groups[1]]'
invoke = true
if not invoke
mms = t.getMembers
for mm in mms
sm = mm.toString
mwordMatch = Regex.match(sm, r"([\w+\.\[\]]+) (.+)")
if mwordMatch.success
print '[t.toString]() [mwordMatch.groups[2]] --> [mwordMatch.groups[1]]'
else if t.isValueType
pass
#~ print t.toString
catch BadImageFormatException
pass