Negative effects of the SerializableAttribute Class

When I generate custom classes using my own CodeSmith templates, I do not add the Serializable Attribute ([Serializable]) to the entity or collection classes by default.

Lately, it seems that I am adding the Serializable Attribute more often. I normally do this when I am storing the entity/collection in either ViewState or in a Session variable. I began wondering if I should add the Serializable Attribute by default. What could the negative effects be? After reading the documentation for the SerializableAttribute Class on MSDN, it seems the only side effect that I should be aware of is that classes marked as Serializable cannot be inherited. I can live with that.

Now I need to decide if I should edit my CodeSmith templates to include the Serializable Attribute in all of the entity and collection classes it generates. Hmmm...

For more information on what Serialization means check out the System.Runtime.Serialization Namespace documentation. Here is a good summary from the article:

Serialization is the process of converting an object or a graph of objects into a linear sequence of bytes for either storage or transmission to another location. Deserialization is the process of taking in stored information and recreating objects from it.

 

Published Thursday, February 15, 2007 12:33 PM by Tod Birdsall
Filed under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

No Comments

Leave a Comment

(required) 
(optional)
(required) 
Submit
Picture of Tod Birdsall

Welcome!

This is the personal website of Tod Birdsall, a programmer, business analyst, and gamer. Not necessarily in that order. Learn more...

Subscribe

Be notified of my latest posts. Subscribe to my blog.