0

I have some classes generated by EF out of an Oracle database. Those class will be used to build a restful Web API with Help Pages. I wonder how do I add comments to the properties for those generated classes. I can edit those generated class files, but if I have to remap them, they'll be gone.

I tried creating DTO classes for the generated classes and use AutoMapper, but that quickly go out of hand since I have so many classes to create DTO for, and the worse is that the derived class will end up with two properties and that makes the Help Page not very helpful.

I hope C# lets me to redefine a property of a class, but I know that's not possible, I wonder what's the least painful way to add comments to generated classes.

Ray Cheng
  • 12,230
  • 14
  • 74
  • 137

1 Answers1

0

You don't need to place comments in code: it can be done in an XML file.

This is an old MSDN article, but check the resulting XML document at the bottom of the article.

That is, you can create your own XML document and distribute it along with your assemblies as auto-generated ones.

Matías Fidemraizer
  • 63,804
  • 18
  • 124
  • 206
  • I believe when the code is compiled in VS, it's doing that for me. The problem I have is there are classes generated already and I want to add comments to their properties easily. – Ray Cheng May 06 '14 at 19:01
  • @RayCheng Sorry, but I believe you don't understand my approach. I mean you can compose your own XML document to document auto-generated classes as if that XML documentation was in the whole classes. – Matías Fidemraizer May 06 '14 at 19:03
  • @RayCheng You know that VS project properties have an option to generate an XML file which is the result of extracting the in-code XML doc into an external file. This is how third-party libraries distribute their documentation. If you reference an assembly and in the location where the whole assembly there's a file `[assemblyName].XML` (instead of DLL or EXE), Visual Studio will show you documentation when you use intellisense. Or these files can be used to generate documentation pages (f.e. Sandcastle Help Builder) – Matías Fidemraizer May 06 '14 at 19:07
  • I'm using VS to generate the xml doc (in Build tab) and have it to output to App_Data folder for Help Page to consume it. I believe your approach will work, but I would like to have a more integrated solution. Like putting the comments alone side to the actual code and have VS to output the comments during build process. – Ray Cheng May 06 '14 at 19:17
  • @RayCheng Yeah, I understand what you want, but life isn't perfect :) – Matías Fidemraizer May 07 '14 at 05:27