Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to obtain class summary at runtime?

Is it possible to obtain class summary at runtime in C#? I would like to obtain class summary through reflection and then write it to console. By class summary I mean summary comments before class definition, something like this:

/// <summary>
/// some description
/// </summary>
class SomeClass
{
}

I don't know if these comments are available after compiling the code, but if they are maybe there is a way to obtain them in code.

Thanks in advance for help.

like image 270
empi Avatar asked Feb 26 '09 19:02

empi


People also ask

What is Dot Net reflection?

Reflection provides objects that encapsulate assemblies, modules, and types. You can use reflection to dynamically create an instance of a type, bind the type to an existing object, or get the type from an existing object. You can then invoke the type's methods or access its fields and properties.

What is the use of system reflection namespace?

Provides access to custom attribute data for assemblies, modules, types, members and parameters that are loaded into the reflection-only context. Contains static methods for retrieving custom attributes.

Which namespace helps to find information of an assembly?

Reflection namespace. The System. Reflection namespace contains classes that allow you to obtain information about the application and to dynamically add types, values, and objects to the application.

What sequence of characters indicates the start of an XML style documentation comment in C# code?

The use of XML doc comments requires delimiters that indicate where a documentation comment begins and ends. You use the following delimiters with the XML documentation tags: /// Single-line delimiter: The documentation examples and C# project templates use this form.


2 Answers

I once messed with this a while back, and used this guys solution. Worked pretty good:

http://jimblackler.net/blog/?p=49

like image 155
BFree Avatar answered Nov 15 '22 15:11

BFree


I maintain the Jolt.NET project on CodePlex and have implemented a feature that performs this very task. Please refer to the Jolt library for more information.

In essence, the library allows you to programatically locate and query an XML doc comments file for an assembly using the metadata types in System.Reflection (i.e. MethodInfo, PropertyInfo, etc...).

like image 23
Steve Guidi Avatar answered Nov 15 '22 13:11

Steve Guidi