Click here to Skip to main content
15,886,795 members

Comments by rhyous (Top 3 by date)

rhyous 8-Apr-16 0:40am View    
Quote: Serialized data are hardly read by humans, right?

Wrong. Xml is read by humans. Hence the need for comments.

Your argument is flawed anyway.

Hardly Ever != never.

By your logic, as most code is only read by one human (so hardly ever), we should remove the comment feature in code. The comments are stripped out when it compiles anyway, right?

Quote: what is really the purpose of this? Who is supposed to read this comment in the serialized data?

I have already answered your question above when I said:

I have had requests to add comments in every Xml I have ever serialized. Either from software testers, tech support, or Eula inclusion reasons.

Do you grasp how many things Xml is used for? It isn't just for code to code.

How often have you opened an xml file (web.config, app.config) in Visual Studio an not seen some default comments?

It is a markup language and is used for many reasons, so many that we as developers couldn't ever list or comprehend all of them. In many of these uses, Xml is often viewed by a human and as such, need comments.
rhyous 6-Aug-15 17:36pm View    
I disagree. We are not talking about reading an Xml and ignoring comments. We are talking about writing and Xml and adding comments to the written Xml.

C# is not Xml. Serialization is the ability to generate an Xml file from a C# object. Should a C# object allow for adding comments? I think it should. Comments in Xml are part of the spec for Xml.
http://www.w3.org/TR/REC-xml/#sec-comments

The default Serializer in C# doesn't support adding a comment to an Xml file despite the fact that comments are valid and supported in the Xml spec.

The spec says: They are not part of the document's character data; an XML processor may, but need not, make it possible for an application to retrieve the text of comments.

The verbage is very clear that it is not required for a processor to support comments, but it may. In this case, we aren't even talking about reading the comment, we are talking about writing an Xml with comments.

I didn't see anything about an Xml generator or serializer, but one can assume if comments were not meant to be written, they wouldn't have added them to the spec. Whether we hand craft and xml or generate an Xml, comments are important.

I have had requests to add comments in every Xml I have ever serialized. Either from software testers, tech support, or Eula inclusion reasons.

To accommodate such requests, I have to roll my own serializer.
rhyous 16-Jul-15 13:18pm View    
Xml can be displayed on web pages with an XSLT very similar to HTML. Comments might need to be displayed.

Also, an XML might need to be output with a EULA in comments.