Visual Studio Disabling Missing XML Comment Warning

泪湿孤枕 提交于 2019-11-26 18:54:33

问题


I have a project with over 500 Missing XML Comment warnings. I know I can remove the XML Comment feature, or paste empty comment snippets everywhere, but I'd prefer a generic solution where I can make one change that disables all warnings of this type.

What I do just now is putting

///<Summary>
/// 
///</Summary>

or

#pragma warning disable 1591

was just curious if it would be possible.


回答1:


As suggested above, in general I don't think that these warnings should be ignored (suppressed). To summarise, the ways around the warning would be to:

  • Suppress the warning by changing the project Properties > Build > Errors and warnings > Suppress warnings by entering 1591
  • Add the XML documentation tags (GhostDoc can be quite handy for that)
  • Suppress the warning via compiler options
  • Uncheck the "XML documentation file" checkbox in project Properties > Build > Output
  • Add #pragma warning disable 1591 at the top of the respective file and #pragma warning restore 1591 at the bottom



回答2:


Disable the warning: Go to the Project properties(Right click on your project and choose Properties from the context menu) Go to the Build tab

Add 1591 to the Suppress warnings textbox




回答3:


You can also modify your project's .csproj file to include a <noWarn>1591</noWarn> tag inside of the first <PropertyGroup>. Originally from Alexandru Bucur's Article Here

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    ...
    <noWarn>1591</noWarn>
  </PropertyGroup>
  ...
</Project>



回答4:


Go into project properties and uncheck the generate XML document option.

Recompile and the warnings should go away.




回答5:


This would have been a comment but I couldn't get it to fit the limitation:

I would love to disable them just for the Reference.cs and WebService imports. Actually I'm using a macro to do it for a file. Just open the file and execute this macro(Tested in VS2010):

Sub PragmaWarningDisableForOpenFile()
    DTE.ActiveDocument.Selection.StartOfDocument()
    DTE.ActiveDocument.Selection.NewLine()
    DTE.ActiveDocument.Selection.LineUp()
    DTE.ActiveDocument.Selection.Insert("#pragma warning disable 1591")
    DTE.ActiveDocument.Selection.EndOfDocument()
    DTE.ActiveDocument.Selection.NewLine()
    DTE.ActiveDocument.Selection.Insert("#pragma warning restore 1591")
    DTE.ActiveDocument.Save()
End Sub

There is really no way to do this automatically? You would have to redo this every time the auto-generated code overrides the file.



来源:https://stackoverflow.com/questions/7982525/visual-studio-disabling-missing-xml-comment-warning

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!