Missing XML comment for publicly visible type or member

前端 未结 16 2287
甜味超标
甜味超标 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:22
    #pragma warning disable 1591
    #pragma warning disable 1591
    #pragma warning disable 1572
    #pragma warning disable 1571
    #pragma warning disable 1573
    #pragma warning disable 1587
    #pragma warning disable 1570
    
    0 讨论(0)
  • 2020-11-30 17:24

    Setting the warning level to 2 suppresses this messages. Don't know if it's the best solution as it also suppresses useful warnings.

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

    Add XML comments to the publicly visible types and members of course :)

    ///<Summary>
    /// Gets the answer
    ///</Summary>
    public int MyMethod()
    {
       return 42;
    }
    

    You need these <summary> type comments on all members - these also show up in the intellisense popup menu.

    The reason you get this warning is because you've set your project to output documentation xml file (in the project settings). This is useful for class libraries (.dll assemblies) which means users of your .dll are getting intellisense documentation for your API right there in visual studio.

    I recommend you get yourself a copy of the GhostDoc Visual Studio AddIn.. Makes documenting much easier.

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

    I wanted to add something to the answers listed here:

    As Isak pointed out, the XML documentation is useful for Class Libraries, as it provides intellisense to any consumer within Visual Studio. Therefore, an easy and correct solution is to simply turn off documentation for any top-level project (such as UI, etc), which is not going to be implemented outside of its own project.

    Additionally I wanted to point out that the warning only expresses on publicly visible members. So, if you setup your class library to only expose what it needs to, you can get by without documenting private and internal members.

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

    Jon Skeet's answer works great for when you're building with VisualStudio. However, if you're building the sln via the command line (in my case it was via Ant) then you may find that msbuild ignores the sln supression requests.

    Adding this to the msbuild command line solved the problem for me:

    /p:NoWarn=1591
    
    0 讨论(0)
  • 2020-11-30 17:33

    I got that message after attached an attribute to a method

    [webMethod]
    public void DoSomething()
    {
    }
    

    But the correct way was this:

    [webMethod()] // Note the Parentheses 
    public void DoSomething()
    {
    }
    
    0 讨论(0)
提交回复
热议问题