我希望能够解析vb.net代码文件,以便检查子程序、函数(包括注释)、私有变量等的集合。
我可以打开实际的源代码文件。
例如,如果我有以下代码:
Public Function FunctionOne(arg1 As String, arg2 as String) as Integer
here is some code
''//here are some comments
End Function
Public Sub FunctionOne(arg1 As integer, arg2 as integer)
here is some code
''//here are some comments
End Sub
我希望能够解析出所有的子程序和函数以及在Public Function和End Function之间的所有代码(实际上,将有选择地包含仅在其中的代码或整个函数定义会更好)。
这似乎需要某种解析库,或者相当不错的正则表达式技能。
有什么建议吗?
更新: 我正在尝试实现的主要目标是解析源代码,因此反射也许只是用于获取函数列表等等,我知道如何做到这一点,但我正在努力找到一种适当的方法来解析源代码。