[Mono-list] New Tool: Serialize

Duncan Mak duncan@ximian.com
01 Feb 2002 15:51:51 -0500

Hey guys,

As you're implementing your classes, have you ever thought, "Hmm, I
wonder how this will get serialized?" Have you ever felt the urge to see
how an object will get serialized into an XML format?

The tool to help you is here!

I just committed serialize.cs into the mcs/tools directory. It works
like this:

Let's say you're implementing a serializable class named Foo. Its
constructor goes public Foo (int a, string b).

* Fire up serialize.exe like so "./serialize.exe My.Namespace.Foo",
remember to use the full name of the class.

* Type in the type of the arguments "int,string".

* Type in the values, i.e. "1,Foo"

Tada! There'll now be a My.Namespace.Foo.xml file in the mcs/tools
directory (hopefully). That should contain all the info on how your
private fields get serialized.

At least, that's how I think it works.

I used this tool and got most of the GetObjectData methods done in the
System namespace. While writing this, I learned quite a bit about the
power of reflection and how easy it is.

I hope this will be useful to others implementing Serialization bits