taohyson / protobuf-net

Automatically exported from code.google.com/p/protobuf-net
Other
0 stars 0 forks source link

GetProto could extract comments from a decorated C# class #386

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
It is often convenient to use a decorated C# class as the authoritative 
definition of message types for serialisation, rather than use .proto files.  
Once the type is defined in C#, it's easy enough to extract a .proto file from 
it using Serializer.GetProto<>().

The current implementation of GetProto works well for my needs, but it would be 
nice if it extracted the summary documentation for members of a protocontract 
class, and put those in the appropriate places of the generated proto spec.  
This would allow for the documentation to be defined once, and then extracted 
automatically for python/c++/whatever interop.

Original issue reported on code.google.com by j...@staunton.me on 7 Jun 2013 at 10:03

GoogleCodeExporter commented 8 years ago
This is an interesting one; reading from `[Description(...)]` would be pretty 
easy; however, reading the `///` comments is much trickier - that data is not 
compiled into the .NET dll - it goes into the intellisense .xml file - so is 
only available *if* xml comment files are being generated (it isn't by 
default), and *if* the xml file is available at the time (it doesn't need to 
be).

Would `[Description(...)]` suffice?

Original comment by marc.gravell on 7 Jun 2013 at 10:21

GoogleCodeExporter commented 8 years ago
Sounds great! For us, our goal is to keep documentation localised to the class 
def, so as long as it's in the file, the minor redundancy between <summary> and 
Description would be acceptable!

Cheers!

Original comment by j...@staunton.me on 7 Jun 2013 at 10:32

GoogleCodeExporter commented 8 years ago
An alternative could be to add a named parameter to ProtoMember, and save the 
dependency on ComponentModel...

Original comment by j...@staunton.me on 7 Jun 2013 at 10:33