Bug 775116 - TimeZoneInfo throws exception when serialized
Summary: TimeZoneInfo throws exception when serialized
Status: NEW
Alias: None
Product: Mono: Class Libraries
Classification: Mono
Component: Sys.Core (show other bugs)
Version: 2.10.x
Hardware: All All
: P5 - None : Major
Target Milestone: ---
Assignee: Michael Miller
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-08-08 19:48 UTC by James Clegg
Modified: 2012-08-08 19:48 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description James Clegg 2012-08-08 19:48:06 UTC
User-Agent:       Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20100101 Firefox/14.0.1

TimeZoneInfo implements ISerializable, but the GetObjectData() method simply
throws a NotImplementedException.   

Someone should be able to serialize an object of this type using a BinaryFormater
(works on MS .NET, and it's marked as serializable), but because of this, you get an exception if you try.

Reproducible: Always

Steps to Reproduce:
1. Create a TimeZoneInfo instance
2. Try to serialize it with a BinaryFormatter

Actual Results:  
throw exception

Expected Results:  
it should serialize the object properly without throwing an exception.  It should have code to deserialize the object as well.

This snippet will throw the exception.  It doesnt matter if it's the local time zone or any other:

TimeZoneInfo tzi = TimeZoneInfo.Local;
BinaryFormatter bf = new BinaryFormatter();
MemoryStream ms = new MemoryStream();
bf.Serialize(ms, tzi);
ms.Seek(0, SeekOrigin.Begin);
var tzi2= bf.Deserialize(ms);

/// in the TimeZoneInfo class, the following (lack of) code is the problem:

void ISerializable.GetObjectData (SerializationInfo info, StreamingContext 
{
throw new NotImplementedException ();
}
void IDeserializationCallback.OnDeserialization (object sender)
{
throw new NotImplementedException ();
}

it looks like there is also a missing custom deserialization constructor