Missing XML comment for publicly visible type or m

2019-01-08 03:32发布

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

How to solve this?

15条回答
趁早两清
2楼-- · 2019-01-08 03:47

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..
查看更多
Rolldiameter
3楼-- · 2019-01-08 03:48

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))
  • 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)
查看更多
叛逆
4楼-- · 2019-01-08 03:51

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
查看更多
三岁会撩人
5楼-- · 2019-01-08 03:51

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()
{
}
查看更多
Explosion°爆炸
6楼-- · 2019-01-08 03:54

I know this is a really old thread, but it's the first response on google so I thought I'd add this bit of information:

This behavior only occurs when the warning level is set to 4 under "Project Properties" -> "Build". Unless you really need that much information you can set it to 3 and you'll get rid of these warnings. Of course, changing the warning level affects more than just comments, so please refer to the documentation if you're unsure what you'll be missing:
https://msdn.microsoft.com/en-us/library/thxezb7y.aspx

查看更多
放荡不羁爱自由
7楼-- · 2019-01-08 03:54

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

查看更多
登录 后发表回答