Get a method's contents from a cs file

前端 未结 6 1715
孤独总比滥情好
孤独总比滥情好 2021-01-19 10:40

I have a requirement to get the contents of every method in a cs file into a string. What I am looking for is when you have an input of a cs file, a dictionary is returned w

6条回答
  •  情话喂你
    2021-01-19 11:06

    I don't know if it's any use to you but Visual Studio Addins include a EnvDTE object, that gives you full access to the VB and C# language parsers. See Discovering Code with the code Model

    I touched on it tangentially years ago, I don't know how difficult it is to use, or how effective it is, but it does look like it will give you what you need.

    The code model allows automation clients to avoid implementing a parser for Visual Studio languages in order to discover the high-level definitions in a project, such as classes, interfaces, structures, methods, properties, and so on.

    If you read the article in full it tells how to pull the full text from a file for a function

    Hope this helps :)

提交回复
热议问题