File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed
src/libraries/System.Resources.Extensions/tests/BinaryFormatTests/FormattedObject Expand file tree Collapse file tree 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
1414 [ MemberData ( nameof ( SerializableObjects ) ) ]
1515 public void BasicObjectsRoundTripAndMatch ( object value , TypeSerializableValue [ ] _ )
1616 {
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+
1725 // We need to round trip through the BinaryFormatter as a few objects in tests remove
1826 // serialized data on deserialization.
1927 BinaryFormatter formatter = new ( ) ;
You can’t perform that action at this time.
0 commit comments