T4 Template TransformText method XML Documentation

回眸只為那壹抹淺笑 提交于 2020-01-24 21:22:04

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/9179341/t4-template-transformtext-method-xml-documentation

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