Resources.Designer.cs 中的 XML 注释?
在我的 Visual Studio 2008 项目中,我的项目包含 Resources.resx,其中包含图像和字符串。 为了迫使我自己和其他人至少编写 XML 注释,我在项目属性的构建选项卡中启用了 XML 注释的生成。 现在,如果存在未记录的类、方法……,Visual Studio 会向我发出一些警告,这太棒了!
但是,自动生成的 Resources.Designer.cs 中的所有图像都没有任何 XML 注释(而字符串则有),因此我收到了几个缺少 XML 注释的编译器警告,但我实际上无能为力,因为对此进行了更改无论如何,文件可能会被覆盖。
是否有机会
- 告诉编译器忽略设计器生成的代码中的 XML 注释,或者
- 强制 Visual Studio 2008 将资源注释写入生成的代码中?
感谢您的任何提示!
In my Visual Studio 2008 project, I have this project with Resources.resx which contains images and strings. In order to force myself and everyone else to write at least the XML comments, I enabled the generation of XML comments in the build tab of the project's property. Now Visual Studio gives me some warnings if there are undocumented classes, methods, … which is great!
However, all of the images in the automatically generated Resources.Designer.cs do not have any XML comments (while the strings do), so I get several compiler warnings of missing XML comments which I actually cannot do anything about, because changes to that file would probably overwritten anyways.
Is there any chance to either
- tell the compiler to ignore XML comments in designer generated code, or
- force Visual Studio 2008 to write the resource comment into the generated code?
Thanks for any hint!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 自定义 工具,用于为 .resx 文件生成 Designer.cs 文件。 自定义工具将调用 resgen.exe 生成 .cs 文件,然后用 #pragma 语句包围内容以忽略缺少 xml 注释的警告:
You could use a custom tool to generate the designer.cs file for the .resx file. The custom tool would call resgen.exe to generate the .cs file and then surround the content with #pragma statements to ignore the warnings for missing xml comment:
Visual Studio应该执行此操作,但事实并非如此,因此请像这样创建文件:
Visual Studio should be doing this, but it's not, so make your file like this: