Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
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 @@ -183,6 +183,28 @@ public static void Concurrent_GetValue_Read_Remove_SameObject()
});
}

[Fact]
public static void AddRemove_DropValue()
{
var key = new object();
var value = new object();

var cwt = new ConditionalWeakTable<object, object>();

cwt.Add(key, value);
cwt.Remove(key);

// Verify that the removed entry is not keeping the value alive
var wrValue = new WeakReference(value);
value = null;

GC.Collect();
Assert.False(wrValue.IsAlive);

GC.KeepAlive(cwt);
GC.KeepAlive(key);
}

[Fact]
public static void GetOrCreateValue()
{
Expand Down