我得到这个警告:“缺少公开可见类型或成员的XML注释”。
如何解决这个问题?
我得到这个警告:“缺少公开可见类型或成员的XML注释”。
如何解决这个问题?
当前回答
这是因为您的项目属性中指定了一个XML文档文件,而您的方法/类是公共的,缺乏文档。 你可以:
禁用XML文档: 右键单击您的项目->属性->“构建”选项卡->取消选中XML文档文件。 坐下来自己写文档吧!
XML文档的总结如下:
/// <summary>
/// Description of the class/method/variable
/// </summary>
..declaration goes here..
其他回答
一个非常简单的方法是在.csproj文件中添加一个属性:
<Project>
<PropertyGroup>
...
<!--disable missing comment warning-->
<NoWarn>$(NoWarn);1591</NoWarn>
</PropertyGroup>
...
我想对这里列出的答案补充一些东西:
正如Isak所指出的,XML文档对于类库非常有用,因为它为Visual Studio中的任何消费者提供了智能感知。因此,一个简单而正确的解决方案是关闭任何顶级项目(如UI等)的文档,因为它不会在自己的项目之外实现。
此外,我想指出的是,警告只表示在公开可见的成员。因此,如果将类库设置为只公开它需要公开的内容,则无需记录私有成员和内部成员。
禁止XML注释的警告
(不是我的作品,但我发现它很有用,所以我包含了文章和链接)
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
还有另一种方法可以抑制这些消息,而不需要任何代码更改或pragma块。使用Visual Studio -转到项目属性>构建>错误和警告>抑制警告-将1591附加到警告代码列表。
将警告级别设置为2将抑制此消息。不知道这是否是最好的解决方案,因为它也抑制了有用的警告。