Are attributes for a class serialized with the type?

Are attributes for a class serialized with the type?

Old forum URL: forums.lhotka.net/forums/t/4463.aspx


rsbaker0 posted on Wednesday, March 05, 2008

If you have a Type object as a member of serializable class, do the attributes for the type assigned to this member get serialized?

Sorry if this seems like more .NET related than CSLA, but I'm trying to understand the implications of adding custom attributes to my classes.

Since CSLA serializes everything, I'd like to avoid adding unnecessary weight and there are alternative implementations I could use rather than attributes if this will add "fat" to the serialization load.

 

ajj3085 replied on Thursday, March 06, 2008

Type definitions are not serialized at all.  All the is serliazed is the type name, assembly and version, and the fields in the instance.  There may be some other plumbing stuff serialized as well.  What that means is that the assembly must be in both locations if you're deserializing on a different location than the one you serialized with.

rsbaker0 replied on Thursday, March 06, 2008

Thanks -- this makes sense.

I was specifically curious about the Criteria classes themselves, which in our case contain a Type object as a field in the instance, so I wasn't sure what was involved in serializing the Type object field in a Criteria class instance around.

In any case, I have some debugging code that tests for serializability and dumps the size of the byte stream out to the debug output, and I don't notice any size change from adding attributes.

 

Copyright (c) Marimer LLC