从代码库中提取API

发布于 2024-10-24 18:14:51 字数 102 浏览 3 评论 0原文

您好,有没有一种技术可以轻松地从 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

最偏执的依靠 2024-10-31 18:14:51

我不知道是否有方便的工具,但是您可以在编译时选择输出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.

柳若烟 2024-10-31 18:14:51

您可以在对象浏览器中获得所有类的树形图。
使用快捷键 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.

浮生面具三千个 2024-10-31 18:14:51

我将放弃通过反思自己做这件事的方法。同样,这很大程度上取决于您的要求。

// get assembly from Assembly.LoadFrom or other static overload

var types = assembly.GetTypes();

var typeNames = (from t in types
        select t.FullName);

var namespaces = (from n in types
        select n.Namespace).Distinct();

And I'll throw out the way to do it yourself, via reflection. Again, a lot of this depends on your requirements.

// get assembly from Assembly.LoadFrom or other static overload

var types = assembly.GetTypes();

var typeNames = (from t in types
        select t.FullName);

var namespaces = (from n in types
        select n.Namespace).Distinct();
天煞孤星 2024-10-31 18:14:51

有一个名为 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).

我很坚强 2024-10-31 18:14:51

.NET Reflector 非常适合此目的。直到大约一周前它都是免费的。我确信您仍然可以在某处找到免费版本或使用免费试用版。

来自网站:

.NET Reflector 是一个程序集浏览器
对于 Microsoft .NET 平台
可以用来探索、分析、
反编译、调试内容
任何 .NET 程序集。 .NET反射器
结合了类浏览、静态
分析和高级反编译
帮助 .NET 开发人员了解如何
图书馆的运作方式或互动方式
与 .NET 的其他部分
应用。 .NET Reflector 将
反编译为高级 C#、VB、IL 和
一些 F# 功能。

.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:

.NET Reflector is an assembly browser
for the Microsoft .NET platform that
can be used to explore, analyze,
decompile, and debug the contents of
any .NET assembly. .NET Reflector
combines class browsing, static
analysis and high-level decompilation
to help .NET developers understand how
a library works or how it interacts
with other parts of a .NET
application. .NET Reflector will
decompile to high level C#, VB, IL and
some F# features.

爱给你人给你 2024-10-31 18:14:51

根据您使用的 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.

蓝天 2024-10-31 18:14:51

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文