开发者

How can I read the documentation from a class in another class?

开发者 https://www.devze.com 2022-12-12 02:27 出处:网络
let\'s say I have class A and class B. Class A\'s definition is: /// <summary> 开发者_开发百科/// This is the class documentation.

let's say I have class A and class B. Class A's definition is:

/// <summary>
开发者_开发百科/// This is the class documentation.
/// </summary>
public class A
{
    /// <summary>
    /// This is the documentation for attribute.
    /// </summary>
    public int attribute;
    ...
}

I want to access the documentation from class A (ie. those strings that read 'This is the class documentation.' and 'This is the documentation for attribute.') in class B programatically. Is there a way to do this? using reflection, perhaps?

Thanks for your help :)


I am assuming your using visual studio. Go to your project settings, set the Xml Documentation file path. When you compile , the comments will be dumped into an Xml file. You can then open the file programatically and read the comments


The documentation is not exported into the program assemblies. It is (optionally) extracted into separate XML files.

To do as you suggest, you would need to find or write a tool that parses the XML files and adds metadata into the assembly, or ship the XML file with the assembly and dip into it when you wish to retrieve the related documentation.


Generate the XML documentation file and then you can parse it programmatically.

0

精彩评论

暂无评论...
验证码 换一张
取 消