从代码库中提取API
您好,有没有一种技术可以轻松地从 C# 为 ASP.NET 编译的代码库中提取所有命名空间和方法等?
我基本上希望能够打印所有可用的命名空间、方法等,以便我可以决定如何重构。
Hi is there a technique available to easily extract all of the namespaces and methods etc from a code library compiled in C# for asp.net?
I basically want to be able to print all available namespaces, methods, etc so that I can decide how to refactor.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
我不知道是否有方便的工具,但是您可以在编译时选择输出xml文件的选项(项目属性->输出XML文档文件)。它将列出您可以导入和查询的所有 XML 方法。作为奖励,您还将获得开发人员提供的任何 xml 注释。
I don't know if there is a handy tool or not, but you can select the option to output the xml file when you compile (Project Properties->Output XML documentation file). It will list all the methods in XML that you can import and query. As a bonus, you will also have any xml comments that your developers have provided.
您可以在对象浏览器中获得所有类的树形图。
使用快捷键
Ctrl+W, J
打开对象浏览器。You can get a tree diagram of all classes in the object browser.
The object browser is opened with the shortcut
Ctrl+W, J
.我将放弃通过反思自己做这件事的方法。同样,这很大程度上取决于您的要求。
And I'll throw out the way to do it yourself, via reflection. Again, a lot of this depends on your requirements.
有一个名为 NDepend 的商业工具,可以让您以多种方式查询代码,并且当然支持特定的你提到的例子。
如果这是一项一次性任务,也许试用版的功能足够丰富,可以满足您的需求。或者也许您会意识到它有多棒并最终购买了一个副本(:(我与 NDepend 没有任何关系,我只是喜欢该工具背后的概念)。
There is a commercial tool called NDepend that lets you query code in many ways, and certainly supports the specific examples you mentioned.
If this is a one-time task, perhaps the trial edition would be rich enough in functionality to meet your needs. Or maybe you'll realize how terrific it is and end up buying a copy (: (I don't have any relationship with NDepend, I just like the concepts behind that tool).
.NET Reflector 非常适合此目的。直到大约一周前它都是免费的。我确信您仍然可以在某处找到免费版本或使用免费试用版。
来自网站:
.NET Reflector is great for this. It was free until about a week ago. I'm sure you could still find the free version out there somewhere or use the free trial.
From the website:
根据您使用的 Visual Studio 版本,您可以创建一个可打印的类图(我认为它适用于除 Express 之外的所有版本)。在您的项目中,添加一个新文件并从“常规”类别中选择“类图”。然后将您的类和接口文件拖到其设计界面上。
Depending on which edition of Visual Studio you are using, you can create a class diagram that is then printable (I think it is available to all editions except Express). In your project, add a new file and select Class Diagram from the General category. Then drag your classes and interface files onto it's design surface.
SandCastle 将为您构建一个很好的类/方法帮助文件以及开发人员使用 xml 所做的任何注释评论。
SandCastle Will build a nice help file for you of classes/methods as well as any comments the developer made using the xml commenting.