0

I'm generating a class from an interface using T4 templates, and I want to be able to copy xml-comments from the interface to the class methods. Is it possible and if yes, how?

In my template I am just taking the interface methods and copying them like this:

foreach(var m in typeof(IFrontEndService).GetMethods()) 
{
      <#= "Some output here"; #>
}
Egor Pavlikhin
  • 17,503
  • 16
  • 61
  • 99
  • There are multiple ways to do what you are asking, but it's not clear what you are doing now and why it's not meeting your needs. Can you provide a sample of the T4 code you are using now? – Michael Maddox Mar 03 '10 at 16:33

2 Answers2

1

Unfortunately, I'm not aware of any existing public API for reading xmldoc comments. You're pretty much stuck reading the comments out of the XML file on disk. Unfortunately, mapping the member names to the identifiers used in the XML file is non-trivial. I use a variation on the approach described at http://www.binarycoder.net/fxcop/html/doccomments.html.

Nicole Calinoiu
  • 20,843
  • 2
  • 44
  • 49
0

One way would be using CodeModel. Here is an example of using this API in a T4 template: http://www.olegsych.com/2007/12/how-to-use-t4-to-generate-decorator-classes/

Oleg Sych
  • 6,548
  • 36
  • 34