{\r
return _typeCodesToType [code];\r
}\r
+ \r
+ public static void CheckSerializable (Type type, ISurrogateSelector selector, StreamingContext context)\r
+ {\r
+ if (!type.IsSerializable && !type.IsInterface) \r
+ {\r
+ if (selector != null && selector.GetSurrogate (type, context, out selector) != null)\r
+ return;\r
+\r
+ throw new SerializationException ("Type " + type + " is not marked as Serializable.");\r
+ }\r
+ }\r
}\r
\r
internal enum BinaryElement : byte\r
+2004-07-02 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * BinaryCommon.cs: Added CheckSerializable method.
+ * ObjectWriter.cs: Check for type serializability even for members with
+ null values.
+
2004-05-29 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* ObjectWriter.cs: reduce contention in GetObjectData.
\r
// Check if the object is marked with the Serializable attribute\r
\r
- if (!instanceType.IsSerializable)\r
- throw new SerializationException ("Type " + instanceType +\r
- " is not marked as Serializable " + \r
- "and does not implement ISerializable.");\r
+ BinaryCommon.CheckSerializable (instanceType, _surrogateSelector, _context);\r
\r
ISerializable ser = obj as ISerializable;\r
\r
{\r
if (val == null) \r
{\r
+ BinaryCommon.CheckSerializable (valueType, _surrogateSelector, _context);\r
writer.Write ((byte) BinaryElement.NullValue);\r
}\r
else if (BinaryCommon.IsPrimitive(val.GetType()))\r