Skip to content
Merged
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 @@ -14,6 +14,14 @@ public class BasicObjectTests : Common.BasicObjectTests<FormattedObjectSerialize
[MemberData(nameof(SerializableObjects))]
public void BasicObjectsRoundTripAndMatch(object value, TypeSerializableValue[] _)
{
if (value is WeakReference || (value.GetType().IsGenericType && value.GetType().GetGenericTypeDefinition() == typeof(WeakReference<>)))
{
// We can root the provided value, but we can't root the deserialized value:
// GC can free the target of WeakReference after it gets deserialized,
// but before it gets returned from BinaryFormatter.Deserialize.
return;
}

// We need to round trip through the BinaryFormatter as a few objects in tests remove
// serialized data on deserialization.
BinaryFormatter formatter = new();
Expand Down