File tree 1 file changed +8
-0
lines changed
src/libraries/System.Resources.Extensions/tests/BinaryFormatTests/FormattedObject
1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,14 @@ public class BasicObjectTests : Common.BasicObjectTests<FormattedObjectSerialize
14
14
[ MemberData ( nameof ( SerializableObjects ) ) ]
15
15
public void BasicObjectsRoundTripAndMatch ( object value , TypeSerializableValue [ ] _ )
16
16
{
17
+ if ( value is WeakReference || ( value . GetType ( ) . IsGenericType && value . GetType ( ) . GetGenericTypeDefinition ( ) == typeof ( WeakReference < > ) ) )
18
+ {
19
+ // We can root the provided value, but we can't root the deserialized value:
20
+ // GC can free the target of WeakReference after it gets deserialized,
21
+ // but before it gets returned from BinaryFormatter.Deserialize.
22
+ return ;
23
+ }
24
+
17
25
// We need to round trip through the BinaryFormatter as a few objects in tests remove
18
26
// serialized data on deserialization.
19
27
BinaryFormatter formatter = new ( ) ;
You can’t perform that action at this time.
0 commit comments