How to make a class serializable without Serializable attibute in .net

I have one debugger visualizer to view a list of class objects as a data table. But the limitation for the code is that the class must be serializable, i.e. Must be marked as [Serializable], and if the class is not marked Serializable, then the debugger will work. So, can anyone tell me how to make the class Serializable at runtime if the class is not marked Serializable.

+3
source share
5 answers

If the class is not checked [Serializable], you can try serialization with SerializationSurrogate

+2
source

.

+3

get/set XmlSerializable. XML- ?

+2

, [Serializable], . , . . - , , , . Windows Forms , Windows, , , (, ) .

, . . . .

+2

-, [Serializable], dotnet json, xml .. , , , , xml json.

[Serializable] - #: 50 #.

You can serialize a class without being [Serializable], since @Darin (+1) indicated that you cannot retrospectively redefine the class. If I were you, I would put [Serializable], since working around it is not worth the effort.

+1
source

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


All Articles