解决方法
您需要解析您的代码才能执行此操作.我不认为你可以用反思来做. MS已经在一个名为Roslyn的项目上工作.这是.NET编译器的一种API.它应该提供你所需要的.查看
this的帖子,了解Roslyn项目的详细信息.
从帖子引用:
This opens up new opportunities for VS extenders to write powerful
refactorings and language analysis tools,as well as allow anyone to
incorporate our parsers,semantic engines,code generators and
scripting in their own applications.