Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// Extension for System.Type enabling direct access to <summary> contents.
//
// This extension uses DocsByReflection by Jim Blackler:
//
// http://jimblackler.net/blog/?p=49
//
// (this just does the summary for types, but it should be easy to extend this
// concept to include other members and other tags...)
static class DocsByReflectionExtensions
{
/// <summary>
/// Gets the summary from the &lt;summary&gt; tag in documentation comments of the given Type.
/// </summary>
public static string GetSummary(this System.Type type)
{
XmlElement xml = DocsByReflection.XMLFromType(type);
var summary = xml["summary"];
return summary != null ? summary.InnerText.Trim() : type.Name;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment