认识到C#源代码中的注释

Mic*_*ber 2 c# visual-studio-2008

如何识别C#源代码中的注释?我想从评论中检索所有信息.

public class TestClass
    {
        /// <summary>
        /// Sample method
        /// </summary>
        /// <param name="a">1 argument</param>
        /// <param name="b">2 argument</param>
        /// <param name="c">3 argument</param>
        /// <returns>true or false</returns>
        /// <exception cref="NotImplementedException">Always throw exception</exception>
        public bool Method(int a, object b, Panel c)
        {
            throw new NotImplementedException();
        }
    }
Run Code Online (Sandbox Code Playgroud)
  1. 方法描述 - "样品方法"
  2. 参数描述 - "1参数,......"
  3. 返回值的描述 - "true或false"
  4. 异常类型和描述
  5. 其他用户标签

Mar*_*ell 5

最简单的方法是启用xml注释生成(项目属性 - >构建),并解析xml文件......

<?xml version="1.0"?>
<doc>
    <assembly>
        <name>ClassLibrary2</name>
    </assembly>
    <members>
        <member name="M:TestClass.Method(System.Int32,System.Object,System.Windows.Forms.Panel)">
            <summary>
            Sample method
            </summary>
            <param name="a">1 argument</param>
            <param name="b">2 argument</param>
            <param name="c">3 argument</param>
            <returns>true or false</returns>
            <exception cref="T:System.NotImplementedException">Always throw exception</exception>
        </member>
    </members>
</doc>
Run Code Online (Sandbox Code Playgroud)