Getting a description of a method using reflection

Is it possible to get a description of a comment on a method or property using reflection. For example, when you use intellisense in Visual Studio to scroll through the methods available to an object, there is a label that describes what this method does. How can I access this data programmatically using reflection? your thoughts are greatly appreciated. Tony

+3
source share
3 answers

No. The method description is defined in the XML file (with the same name as the declaring assembly), extracted from the XML comments in the source code. Visual Studio uses this XML file to download these materials. This information is not found anywhere in the assembly metadata and, of course, is not available using reflection:

/// <summary> Method description </summary>
public void Something() { ... }

When the C # compiler is invoked using a switch /doc, it retrieves the XML tags and places it in an XML file. Visual Studio checks for the presence of an XML file along the referenced assembly and displays the corresponding description.

+4
source

Intellisense ( /// XML dll/exe), , . . [Description], .

+2

If you open the properties of a project for which documentation is required, select the assembly tab.

One of the last properties of ypu can install the Xml documentation file, here you can specify in which file to store the documentation.

The file is just xml, so parsing should be trivial.

0
source

Source: https://habr.com/ru/post/1721390/


All Articles