S
Shalom Shachne
Hi all,
We have an object graph that we persist to disk using binary
serialization. The issue that we are trying to find a solution to, is
how to prevent developers from accidentally breaking serialization, by
adding a new object to the graph which is not serializable.
I was hoping to add a Nunit test to our suite which would fail if this
object graph is not serializable. However, after having done this
once in Java, I realized it is not so straightforward.
(In Java, if your object contains another object which is not
Serializable, it won't fail if the child object is null at time of
serialization. So our unit test had to use Reflection to iterate over
the public and private fields of the entire object graph to test that
each member implemented Serializable).
I'm wondering if, in .NET there is some easier way to test that the
entire object graph is serializable? (If the solution is have your
test populate every field with data, and then try to Serialize, we
might as well follow the same model as we did for the Java code).
Thanks for anyone's thoughts on this...
Sam
We have an object graph that we persist to disk using binary
serialization. The issue that we are trying to find a solution to, is
how to prevent developers from accidentally breaking serialization, by
adding a new object to the graph which is not serializable.
I was hoping to add a Nunit test to our suite which would fail if this
object graph is not serializable. However, after having done this
once in Java, I realized it is not so straightforward.
(In Java, if your object contains another object which is not
Serializable, it won't fail if the child object is null at time of
serialization. So our unit test had to use Reflection to iterate over
the public and private fields of the entire object graph to test that
each member implemented Serializable).
I'm wondering if, in .NET there is some easier way to test that the
entire object graph is serializable? (If the solution is have your
test populate every field with data, and then try to Serialize, we
might as well follow the same model as we did for the Java code).
Thanks for anyone's thoughts on this...
Sam