在运行时以编程方式获取摘要注释 [英] Programmatically get Summary comments at runtime

查看:21
本文介绍了在运行时以编程方式获取摘要注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种方法来以编程方式获取 ASP.net 中方法的 Xml 注释的摘要部分.

I'm looking for a way to programmatically get the summary portion of Xml-comments of a method in ASP.net.

我查看了之前的相关帖子,但它们没有提供在 Web 环境中执行此操作的方法.

I have looked at the previous related posts and they do not supply a way of doing so in a web environment.

我无法使用任何 3rd 方应用程序,并且由于网络环境,Visual Studio 插件也没有太大用处.

I can not use any 3rd party apps and due to a web environment, Visual studio plugin's aren't much use either.

我发现的最接近可行解决方案的是 JimBlackler 项目,但它仅适用于 DLL.

The closest thing I have found to a working solution was the JimBlackler project, but it only works on DLL's.

自然,诸如提供 .CS 文件,获取 XML 文档"之类的内容将是最佳选择.

Naturally, something like 'supply .CS file, get XML documentation' would be optimal.

我有一个网络服务并试图为其动态生成文档.

I have a web-service and trying to dynamically generate documentation for it.

阅读方法和属性很容易,但获取每个方法的摘要让我有点失望.

Reading the Methods, and properties is easy, but getting the Summary for each method is throwing me off a bit.

/// <summary>
/// This Is what I'm trying to read
/// </summary>
public class SomeClass()
{
    /// <summary>
    /// This Is what I'm trying to read
    /// </summary>
    public void SomeMethod()
    {
    }
}

<小时>

推荐答案

XML 摘要不存储在 .NET 程序集中 - 作为构建的一部分(假设您使用 Visual工作室).

The XML summary isn't stored in the .NET assembly - it's optionally written out to an XML file as part of your build (assuming you're using Visual Studio).

因此,无法通过对已编译的 .NET 程序集(.EXE 或 .DLL)的反射来提取"每个方法的 XML 摘要 - 因为数据根本不存在供您提取.如果需要数据,则必须指示构建环境输出 XML 文件作为构建过程的一部分,并在运行时解析这些 XML 文件以获取摘要信息.

Consequently there is no way to "pull out" the XML summaries of each method via reflection on a compiled .NET assembly (either .EXE or .DLL) - because the data simply isn't there for you to pull out. If you want the data, you'll have to instruct your build environment to output the XML files as part of your build process and parse those XML files at runtime to get at the summary information.

这篇关于在运行时以编程方式获取摘要注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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