16,004,539 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View .NET questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
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.