相关疑难解决方法(0)

如何使用Roslyn阅读XML文档注释

我希望能够在使用Roslyn解析C#源代码时阅读XML文档注释.

/// <summary>
/// Documentation...
/// </summary>
Run Code Online (Sandbox Code Playgroud)

我尝试在ParseOptions中设置ParseDocumentationComments,但它似乎没有效果?

var parseOptions = ParseOptions.Default.WithParseDocumentationComments(true);
SyntaxTree unit = SyntaxTree.ParseFile(file, parseOptions);
Run Code Online (Sandbox Code Playgroud)

c# roslyn

22
推荐指数
2
解决办法
5728
查看次数

如何使用Reflection获取方法或类的文档?

var className = typeof(Console);
var methodInfo = className.GetMethod("WriteLine",new [] { typeof(string) });
Run Code Online (Sandbox Code Playgroud)

我有一个Writel方法的methodInfo对象,现在如果我们看到该方法的定义,它看起来像这样.

//
        // Summary:
        //     Writes the specified string value, followed by the current line terminator,
        //     to the standard output stream.
        //
        // Parameters:
        //   value:
        //     The value to write.
        //
        // Exceptions:
        //   System.IO.IOException:
        //     An I/O error occurred.
        public static void WriteLine(string value);
Run Code Online (Sandbox Code Playgroud)

我想要的是得到一个特定方法的评论.,有什么办法可以用反射实现这个目的吗?或任何其他可能的方式?

c# reflection metadata methodinfo

5
推荐指数
1
解决办法
939
查看次数

标签 统计

c# ×2

metadata ×1

methodinfo ×1

reflection ×1

roslyn ×1