[Mono-dev] Patch to HashSet (System.Core) to enable serialization

Robert Jordan robertj at gmx.net
Fri Jan 28 09:15:34 EST 2011


On 28.01.2011 14:04, Nicklas Overgaard wrote:
> Hi everyone,
>
> I'm kind of stuck with adding support for this. After looking at
> the .net binary serialization of their HashSet via a hex editor, it
> seems that they only store:
> 	"Version"
> 	"Comparer"
> 	"Capacity"
> 	"Elements"
>
> Now, these are directly translatable into some of the internal structure
> of the Mono implementation of the HashSet, however, if serialized this
> way we lose information about the "Link" structure along with which
> slots are empty and so forth. I'm guessing that loss of such information
> would lead to an unstable deserialized version?
>
> So, the question is, would it hurt that I add this information to the
> serialized output (empty_slot, links, etc.)? Will the .net
> implementation just ignore these extra fields?

MS.NET will ignore these fields, but this doesn't help because
we must be able to deserialize a steam generated by MS.NET, too.

If they only store "Elements", they are probably recreating
the internal structures on deserialization. IIRC, Dictionary<K,V>
is also working this way.

Robert


>
> Best regards,
>
> Nicklas Overgaard.
>
> On Sun, 2011-01-23 at 11:55 +0100, Nicklas Overgaard wrote:
>> Hi Robert,
>>
>> 1) I know, I kinda created the method to ensure that everyting was
>> working as I expected.
>>
>> 2) I'll try and remove it.
>>
>> And I have not verified the output against the MS.NET implementation. I
>> will do that on monday when I have access to a windows machine.
>>
>> I will resubmit a cleaner patch next week.
>>
>> /Nicklas
>>
>> On Fri, 2011-01-21 at 22:46 -0500,
>> mono-devel-list-request at lists.ximian.com wrote:
>>> Date: Fri, 21 Jan 2011 13:58:11 +0100
>>> From: Robert Jordan<robertj at gmx.net>
>>> Subject: Re: [Mono-dev] Patch to HashSet (System.Core) to enable
>>>        serialization
>>> To: mono-devel-list at lists.ximian.com
>>> Message-ID:<ihbvsr$8aq$1 at dough.gmane.org>
>>> Content-Type: text/plain; charset=UTF-8; format=flowed
>>>
>>> Hi Nicklas,
>>>
>>> On 21.01.2011 10:35, Nicklas Overgaard wrote:
>>>> Hi,
>>>>
>>>> Attached is a patch that makes the HashSet class serializable.
>> Included
>>>> are unittests to check the functionality.
>>>
>>> Thanks for the patch. There are some issues with it, though:
>>>
>>> 1) it's not allowed to expose public members as you do
>>> with UnittestEqualityCheck.
>>>
>>> 2) OnDeserialization is supposed to be called by the serialization
>>> infrastructure implicitly. There is no need to invoke it manually
>>> from the ctor.
>>>
>>> Have you checked if the serialization format matches MS.NET?
>>>
>>> Robert
>>
>> _______________________________________________
>> Mono-devel-list mailing list
>> Mono-devel-list at lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/mono-devel-list




More information about the Mono-devel-list mailing list