Bug 16768 - SplitOrderedList is not marked as Serializable
Summary: SplitOrderedList is not marked as Serializable
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib ()
Version: master
Hardware: All All
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on: 16730
Blocks:
  Show dependency tree
 
Reported: 2013-12-13 06:16 UTC by Jon Hanna
Modified: 2014-11-25 05:00 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Jon Hanna 2013-12-13 06:16:08 UTC
This relates to #16730 to the point where I would reopen it if I had sufficient rights, but don't know if it being marked fixed will mean it doesn't end up on anyone's to-do list.

Example of breaking code:

var dict = new ConcurrentDictionary<string, string>();
dict["abc"] = "this will be removed";
dict["def"] = "This will Stay";
dict["abc"] = "This overwrites";

using(var ms = new MemoryStream())
{
	new BinaryFormatter().Serialize(ms, dict);
	ms.Flush();
	ms.Seek(0, SeekOrigin.Begin);
	var newDict = (ConcurrentDictionary<string, string>)new BinaryFormatter().Deserialize(ms);	
	foreach(var kvp in dict.OrderBy(kv => kv.Key))
	{
		Console.Write(kvp.Key);
		Console.Write(" = ");
		Console.WriteLine(kvp.Value);
	}
}

Expected output:

abc = This overwrites
def = This will Stay

Result with current release:

SerializationException: System.Collections.Concurrent.ConcurrentDictionary`2[System.String,System.String]
is not marked as Serializable.

Result with current code in git repository (after fix for #16730):

SerializationException: System.Collections.Concurrent.SplitOrderedList`2[System.String,System.Collections.Generic.KeyValuePair`2[System.String,System.String]] is not marked as Serializable.

There are reasons why just marking SplitOrderedList as Serializable will not be sufficient either. I describe why in more detail at #16730, along with a patch that will fix it.
Comment 1 Marek Safar 2014-11-25 05:00:32 UTC
Resolved in master