简体   繁体   中英

How to properly add comments to generated class properties?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM