如何在 .NET Framework 4.0 中的工作流自动生成的代码中禁用 XML 注释警告
我们遇到了这样的问题:Workflow Foundation 在编译期间生成的代码中缺少 XML 注释,因此会收到编译器警告。因为我们将所有警告视为错误,所以编译失败。
是的,我们可以简单地指示编译器忽略特定警告,从而不再编译失败,但这意味着项目中的任何代码都将免除 XML 注释。
所以问题是:是否有一种方法可以仅针对工作流基础生成的代码禁用缺少 XML 注释的警告?
We've had this issue of getting compiler warnings for XML comments missing on code that Workflow Foundation generates during compilation. Because we treat all warnings as errors, our compilation fails.
Yes, we could simply instruct the compiler to ignore specific warnings and thus not fail compilation anymore, but that would mean that any code in the project would be exempted from having XML comments.
So the question is: is there a way of disabling the warning on missing XML comments just for workflow foundation-generated code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据 Quoc Lam 的博客 (http://lvquoc.blogspot.com/2010/11/disable-xml-comment-warning-in-workflow.html),可以执行以下操作:
这会导致“#pragma warning禁用”被插入到生成的代码中。有关其工作原理的详细信息,请参阅博客文章。
Per Quoc Lam's blog (http://lvquoc.blogspot.com/2010/11/disable-xml-comment-warning-in-workflow.html), the following can be done:
<Target Name="XamlGeneratedCodeWarningRemoved" AfterTargets="XamlMarkupCompilePass1">
<Exec Command="for %%f in (@(XamlGeneratedCodeFiles)) do echo #pragma warning disable > %%f.temp" />
<Exec Command="for %%f in (@(XamlGeneratedCodeFiles)) do type %%f >> %%f.temp" />
<Exec Command="for %%f in (@(XamlGeneratedCodeFiles)) do copy /y %%f.temp %%f" />
<Message Text="XamlGeneratedCodeWarningRemoved: @(XamlGeneratedCodeFiles)" />
</Target>
This causes a "#pragma warning disable" to be inserted into the generated code. See the blog entry for detailed information on how this works.