Add XML comment during serialization / deserialization using VB.NET

I have an XML document that I am deserializing (VB.NET 3.5 Framework), changing some values ​​and serializing again. There are several XML comments in the source document. When I look through all deserializations / serializations, all comments are lost. Is there a way to save comments? If not, is there a way to add comments to serialization without having to go through the author and manually add all comments to the right place?

+3
source share
1 answer

No no. If you want to serialize the content, you will have to use custom serialization (I assume that you reference the IXmlSerializableinterface implementation ) and store the comments in the class instance and reinitialize them when serializing back to XML.

The runtime may not know that the comment needs to be serialized and store it for you, so you have to do it yourself.

+3
source

Source: https://habr.com/ru/post/1705677/


All Articles