How do I document a c# dll

2019-02-21 18:42发布

问题:

How do I write a class so that property and method descriptions are visible to people referencing the dll in other projects?

    [Description("My age in years attribute")]
    public int Age
    {
        get { return 0; }
        set { }
    }

doesn't work, neither does

    /// <summary>
    /// My age in years attribute
    /// </summary>
    public int Age
    {
        get { return 0; }
        set { }
    }

回答1:

In Visual Studio:

Project -> Properties -> Build -> Check "XML Documentation File".

For further details, see XML Comments Let You Build Documentation Directly From Your Visual Studio .NET Source Files.



回答2:

The description provided in DescriptionAttribute is visible in Property Grid for sure and it has nothing to do with code editor.

For XML comments to be available, you have to generate an XML documentation file and ship it with your assembly.



回答3:

Did you build the XML documentation file for your second case?

Project properties -> Build -> [Output] XML Documentation file



回答4:

The second should work (summary), be sure to select in the project Properties (Build -> Output ) XML Documentation File.