从CS文件获取方法的内容 [英] Get a method's contents from a cs file

查看:117
本文介绍了从CS文件获取方法的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个要求得到一个CS文件中的每个方法的内容为一个字符串。我所寻找的是当你有一个CS文件的输入,词典与方法名作为重点和方法体的返回值。

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 with the method name as the key and the method body as the value.

我曾尝试正则表达式和反射没有成功,任何人都可以帮忙吗?

I have tried Regex and reflection with no success, can anyone help?

感谢

推荐答案

我不知道这是否是使用任何你,但Visual Studio的加载项包括EnvDTE对象,让你完全访问VB和C#语言解析器。
查找代码的代码模型

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.

中的代码模型允许
自动化客户端,以避免
实施解析器可视
Studio语言
,以便及时发现

项目的高层次的定义,如类,接口,
结构,方法,属性和
以便上。

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

希望这有助于:)

这篇关于从CS文件获取方法的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆