我希望能够在使用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) 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)
我想要的是得到一个特定方法的评论.,有什么办法可以用反射实现这个目的吗?或任何其他可能的方式?