Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,6 @@ public struct Enumerator : IEnumerator<T>, IEnumerator, ISerializable, IDeserial
private int _version;
private T _current;
private int _index;
private SerializationInfo _siInfo; //A temporary variable which we need during deserialization.

const string LinkedListName = "LinkedList";
const string CurrentValueName = "Current";
Expand All @@ -558,7 +557,6 @@ internal Enumerator(LinkedList<T> list)
_node = list.head;
_current = default(T);
_index = 0;
_siInfo = null;
}

private Enumerator(SerializationInfo info, StreamingContext context)
Expand Down Expand Up @@ -630,51 +628,7 @@ void ISerializable.GetObjectData(SerializationInfo info, StreamingContext contex

void IDeserializationCallback.OnDeserialization(Object sender)
{
if (_list != null)
{
return; // Somebody had a dependency on this Dictionary and fixed us up before the ObjectManager got to it.
}

if (_siInfo == null)
{
throw new SerializationException(SR.Serialization_InvalidOnDeser);
}

_list = (LinkedList<T>)_siInfo.GetValue(LinkedListName, typeof(LinkedList<T>));
_version = _siInfo.GetInt32(VersionName);
_current = (T)_siInfo.GetValue(CurrentValueName, typeof(T));
_index = _siInfo.GetInt32(IndexName);

if (_list._siInfo != null)
{
_list.OnDeserialization(sender);
}

if (_index == _list.Count + 1)
{
// end of enumeration
_node = null;
}
else
{
_node = _list.First;

// We don't care if we can point to the correct node if the LinkedList was changed
// MoveNext will throw upon next call and Current has the correct value.
if (_node != null && _index != 0)
{
for (int i = 0; i < _index; i++)
{
_node = _node.next;
}
if (_node == _list.First)
{
_node = null;
}
}
}

_siInfo = null;
throw new PlatformNotSupportedException();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,53 +348,10 @@ protected override void GetObjectData(SerializationInfo info, StreamingContext c

void IDeserializationCallback.OnDeserialization(Object sender)
{
// Don't do anything here as the work has already been done by the constructor
throw new PlatformNotSupportedException();
}

protected override void OnDeserialization(Object sender) => OnDeserializationImpl(sender);

private void OnDeserializationImpl(Object sender)
{
if (_siInfo == null)
{
throw new SerializationException(SR.Serialization_InvalidOnDeser);
}

_comparer = (IComparer<T>)_siInfo.GetValue(ComparerName, typeof(IComparer<T>));
int savedCount = _siInfo.GetInt32(CountName);
_max = (T)_siInfo.GetValue(MaxName, typeof(T));
_min = (T)_siInfo.GetValue(MinName, typeof(T));
_lBoundActive = _siInfo.GetBoolean(LowerBoundActiveName);
_uBoundActive = _siInfo.GetBoolean(UpperBoundActiveName);
_underlying = new SortedSet<T>();

if (savedCount != 0)
{
T[] items = (T[])_siInfo.GetValue(ItemsName, typeof(T[]));

if (items == null)
{
throw new SerializationException(SR.Serialization_MissingValues);
}

for (int i = 0; i < items.Length; i++)
{
_underlying.Add(items[i]);
}
}

_underlying._version = _siInfo.GetInt32(VersionName);
_count = _underlying._count;
_version = _underlying._version - 1;
VersionCheck(); // this should update the count to be right and update root to be right

if (_count != savedCount)
{
throw new SerializationException(SR.Serialization_MismatchedCount);
}

_siInfo = null;
}
protected override void OnDeserialization(Object sender) => throw new PlatformNotSupportedException();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1861,7 +1861,6 @@ public struct Enumerator : IEnumerator<T>, IEnumerator, ISerializable, IDeserial
private Node _current;

private bool _reverse;
private SerializationInfo _siInfo;

internal Enumerator(SortedSet<T> set)
{
Expand All @@ -1875,8 +1874,6 @@ internal Enumerator(SortedSet<T> set)
_current = null;
_reverse = false;

_siInfo = null;

Initialize();
}

Expand All @@ -1891,8 +1888,6 @@ internal Enumerator(SortedSet<T> set, bool reverse)
_current = null;
_reverse = reverse;

_siInfo = null;

Initialize();
}

Expand All @@ -1903,34 +1898,7 @@ void ISerializable.GetObjectData(SerializationInfo info, StreamingContext contex

void IDeserializationCallback.OnDeserialization(Object sender)
{
OnDeserialization(sender);
}

private void OnDeserialization(Object sender)
{
if (_siInfo == null)
{
throw new SerializationException(SR.Serialization_InvalidOnDeser);
}

_tree = (SortedSet<T>)_siInfo.GetValue(TreeName, typeof(SortedSet<T>));
_version = _siInfo.GetInt32(EnumVersionName);
_reverse = _siInfo.GetBoolean(ReverseName);
bool EnumStarted = _siInfo.GetBoolean(EnumStartName);
_stack = new Stack<Node>(2 * (int)Log2(_tree.Count + 1));
_current = null;
if (EnumStarted)
{
T item = (T)_siInfo.GetValue(NodeValueName, typeof(T));
Initialize();

// go until it reaches the value we want
while (this.MoveNext())
{
if (_tree.Comparer.Compare(Current, item) == 0)
break;
}
}
throw new PlatformNotSupportedException();
}

private void Initialize()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,10 @@ void ISerializable.GetObjectData(SerializationInfo info, StreamingContext contex
throw new PlatformNotSupportedException();
}

void IDeserializationCallback.OnDeserialization(object sender) { }
void IDeserializationCallback.OnDeserialization(object sender)
{
throw new PlatformNotSupportedException();
}

public IntPtr Handle
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,10 @@ void ISerializable.GetObjectData(SerializationInfo info, StreamingContext contex
throw new PlatformNotSupportedException();
}

void IDeserializationCallback.OnDeserialization(object sender) { }
void IDeserializationCallback.OnDeserialization(object sender)
{
throw new PlatformNotSupportedException();
}

//
// Factory methods.
Expand Down