我得到这个警告:“缺少公开可见类型或成员的XML注释”。

如何解决这个问题?


当前回答

文件>编辑>查看项目(点击)

下拉弓的底部(点击打开/当前工作>属性), 打开项目属性页在“构建”下的“输出”。取消选中“XML文档”复选框。

重建,没有警告。

其他回答

当然要向公开可见的类型和成员添加XML注释:)

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

所有成员都需要这些<summary>类型的注释——这些注释也会显示在智能感知弹出菜单中。

得到此警告的原因是因为您已经将项目设置为输出文档xml文件(在项目设置中)。这对于类库(.dll程序集)很有用,这意味着.dll的用户可以在visual studio中获得API的智能感知文档。

我建议你买一份GhostDoc Visual Studio插件。使记录变得更容易。

文件>编辑>查看项目(点击)

下拉弓的底部(点击打开/当前工作>属性), 打开项目属性页在“构建”下的“输出”。取消选中“XML文档”复选框。

重建,没有警告。

将警告级别设置为2将抑制此消息。不知道这是否是最好的解决方案,因为它也抑制了有用的警告。

5个选项:

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)

您需要为显示警告的成员添加/// Comment。

参见下面的代码

public EventLogger()
{
    LogFile = string.Format("{0}{1}", LogFilePath, FileName);
}

显示警告 缺少公开可见类型或成员'.EventLogger()'的XML注释

我为成员添加了评论,警告消失了。

///<Summary>
/// To write a log <Anycomment as per your code>
///</Summary>
public EventLogger()
{
    LogFile = string.Format("{0}{1}", LogFilePath, FileName);
}