Missing XML comment for publicly visible type or member

前端 未结 16 2289
甜味超标
甜味超标 2020-11-30 17:16

I am getting this warning: \"Missing XML comment for publicly visible type or member\".

How to solve this?

相关标签:
16条回答
  • 2020-11-30 17:34

    5 options:

    • Fill in the documentation comments (great, but time-consuming)
    • Turn off the comment generation (in project properties)
    • Disable the warning in project properties (in 'Project properties' go to Project properties -> Build > "Errors and warnings" (section), Suppress Warnings (textbox), add 1591 (comma separated list)). By default it will change Active Configuration, consider to change configuration to All.
    • Use #pragma warning disable 1591 to disable the warning just for some bits of code (and #pragma warning restore 1591 afterwards)
    • Ignore the warnings (bad idea - you'll miss new "real" warnings)
    0 讨论(0)
  • 2020-11-30 17:35

    Insert an XML comment. ;-)

    /// <summary>
    /// Describe your member here.
    /// </summary>
    public string Something
    {
        get;
        set;
    }
    

    This may appear like a joke at the first glance, but it may actually be useful. For me it turned out to be helpful to think about what methods do even for private methods (unless really trivial, of course).

    0 讨论(0)
  • 2020-11-30 17:37

    There is another way you can suppress these messages without the need for any code change or pragma blocks. Using Visual Studio - Go to project properties > Build > Errors and Warnings > Suppress Warnings - append 1591 to list of warning codes.

    0 讨论(0)
  • 2020-11-30 17:38

    This is because an XML documentation file has been specified in your Project Properties and Your Method/Class is public and lack documentation.
    You can either :

    1. Disable XML documentation:

      Right Click on your Project -> Properties -> 'Build' tab -> uncheck XML Documentation File.

    2. Sit and write the documentation yourself!

    Summary of XML documentation goes like this:

    /// <summary>
    /// Description of the class/method/variable
    /// </summary>
    ..declaration goes here..
    
    0 讨论(0)
  • 2020-11-30 17:39

    Suppress Warnings for XML comments

    (not my work, but I found it useful so I've included the article & link)

    http://bernhardelbl.wordpress.com/2009/02/23/suppress-warnings-for-xml-comments/

    Here i will show you, how you can suppress warnings for XML comments after a Visual Studio build.

    Background

    If you have checked the "XML documentation file" mark in the Visual Studio project settings, a XML file containing all XML comments is created. Additionally you will get a lot of warnings also in designer generated files, because of the missing or wrong XML comments. While sometimes warnings helps us to improve and stabilize our code, getting hundreds of XML comment warnings is just a pain.

    Warnings

    Missing XML comment for publicly visible type or member …
    XML comment on … has a param tag for ‘…’, but there is no parameter by that name Parameter ‘…’ has no matching param tag in the XML comment for ‘…’ (but other parameters do)

    Solution

    You can suppress every warning in Visual Studio.

    • Right-click the Visual Studio project / Properties / Build Tab

    • Insert the following warning numbers in the "Suppress warnings": 1591,1572,1571,1573,1587,1570

    0 讨论(0)
  • 2020-11-30 17:43

    File > Edit > View Project (click)

    Bottom of the drop down bow (click on Open/Current work > Properties), opened project properties page at "Build" under "Output". "Uncheck" XML Documentation checkbox.

    Rebuild and no warnings.

    0 讨论(0)
提交回复
热议问题