T4 模板 TransformText 方法 XML 文档
我们有几个使用运行时 T4 模板的项目。 T4 模板文件 (.tt) 生成生成的同名 .cs 文件。它们包含一个 TransformText()
方法和一个 ToStringHelper()
方法,但不包含 XML 注释。我们为所有项目生成 XML 文档,因此这两种方法中缺少 XML 文档会导致编译期间出现持续警告。
我的问题是,有谁知道如何让这两个生成的方法具有 XML 文档?
感谢您的任何回复。
编辑:为了澄清,我正在使用 .NET 4.0 和 Visual Studio SP1。 TransformText() 和 ToStringHelper() 是样板 T4 方法,我无法通过 .tt 文件进行修改。
We have several projects that use runtime T4 Templates. The T4 Template files (.tt) produce generated .cs files with the same name. These contain a TransformText()
method and a ToStringHelper()
method which do not contain XML comments. We generate XML documentation for all of our projects, so the lack of it on these two methods causes persistent warnings during compilation.
My question is, does anyone know how to get these two generated methods to have XML documentation?
Thanks for any responses.
EDIT: To clarify, I'm using .NET 4.0 with Visual Studio SP1. The TransformText() and ToStringHelper() are boilerplate T4 methods that I cannot modify through the .tt file.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

无法在 T4 中直接更改此设置。它已在下一版本的 Visual Studio 中修复。您可以想象基于正则表达式的搜索/替换来插入作为预构建事件添加的注释。
或者,您可以将该后处理嵌入到从 Microsoft.VisualStudio.TextTemplated.VSHost.TemplatedPreprocessor 派生的新 SingleFileGenerator 中,但这似乎有点矫枉过正。
There's no way to change this directly in T4. It's fixed in the next version of Visual Studio. You could imagine a regex based search/replace to insert the comments added as a pre-build event.
Alternatively you could embed that post-processing in a new SingleFileGenerator derived from Microsoft.VisualStudio.TextTemplating.VSHost.TemplatedPreprocessor, but that seems a bit like overkill.