visual-studio-2010 - VS2010 : Autogenerated files and XML documentation

标签 visual-studio-2010 visual-studio compiler-warnings documentation-generation xml-comments

这真的只是重新询问 this question asked about Visual Studio 2008 . VS2010 是否提供任何功能来消除自动生成代码的 CS1591 编译器警告?
CS1591: Missing XML comment for publicly visible type or member
引用 VS2008 的问题:

This is an annoyance more than a problem. My project contains a number of autogenerated files (using mgmtclassgen.exe). When I generate the XML documentation, my beautifully commented library is plagued by xml documentation warnings from these autogen files.

Is there a way to either a) suppress generating documentation for these files or b) suppress warning CS1591 just for a set of files? I obviously do not want to modify files that are autogenerated, even if to just add suppression pragmas.



编辑:
在我的例子中,有问题的文件是由 WCF RIA 服务生成的,因此生成错误的文件是自动生成的 WebContext 类 ( MyProject.BusinessApplication.Web.g.cs )。

我无法手动修改此文件,因为它是动态生成的,所有更改都将被清除。我也不想全局禁用警告,因为它对我的非自动生成代码很有帮助。

最佳答案

我对自动生成的 Entity Framework 类有类似的问题。我设法通过修改模板文件来解决它。这显然不适用于所有自动生成的场景,也可能不适用于您的特定 RIA 场景,但我会在这里为可能遇到相同问题的其他人发帖。

打开模板文件(something.tt),找到自动生成的 xml 注释部分

//------------------------------------------------------------------------------
// <auto-generated>
//    This code was generated from a template.
//
//    Manual changes to this file may cause unexpected behavior in your application.
//    Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

在注释 block 之后添加以下行
#pragma warning disable 1591 

再往下一点,您应该会找到命名空间 block 的结束位置。它可能看起来像这样
if (!String.IsNullOrEmpty(ObjectNamespace))
{
    PopIndent();
#>
}

将以下行放在该右大括号之后
#pragma warning restore 1591

如果一切正常,只要你的类是由 Entity Framework 自动生成的,它们应该被 disable/restore pragma 语句包装。这应该抑制有关 EF 类中没有 XML 注释的警告,而不抑制项目级别的警告。

关于visual-studio-2010 - VS2010 : Autogenerated files and XML documentation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3630282/

相关文章:

wpf - 这是 Visual Studio 2010 IDE 的错误吗?

visual-studio-2010 - 无法使用 resharper 解决符号问题,但代码可以编译

c# - 在 C# 中接受小数作为输入需要帮助

c - 尝试在 OS X 10.9 中编译 Haskell 程序时的警告

ios - 带有 xcconfig 链接器标志的 CocoaPods 警告

c++ - 多个 WT 应用程序可以在同一个网页上运行吗?

visual-studio - XSLT 1.0 修改配置文件替换功能

c# - 以编程方式通过 C# 代码格式化 Html 代码(如 Visual Studio 中的 Ctrl + E + D)

ios - 如何解决可能出现意外的 Swift 警告 : "Constant ' value' inferred to have type 'AnyClass?' (aka 'Optional<AnyObject.Type>' ),?

c# - Visual Studio 的 Web 性能测试可以用作 Web 场的压力测试吗?