3 instantiations of ReferenceHolder
Microsoft.CodeAnalysis.Workspaces (3)
Utilities\ReferenceHolder`1.cs (3)
31
=>
new
(value);
41
return new
ReferenceHolder
<T>(new WeakReference<T>(value), ReferenceEqualityComparer.GetHashCode(value));
100
=>
new
(new WeakReference<T>(null!), hashCode);
21 references to ReferenceHolder
Microsoft.CodeAnalysis.Workspaces (11)
Utilities\ReferenceHolder`1.cs (8)
9
internal readonly struct ReferenceHolder<T> : IEquatable<
ReferenceHolder
<T>>
30
public static
ReferenceHolder
<T> Strong(T value)
33
public static
ReferenceHolder
<T> Weak(T value)
54
return obj is
ReferenceHolder
<T> other
58
public bool Equals(
ReferenceHolder
<T> other)
95
/// Creates a <see cref="
ReferenceHolder
{T}"/> for a weakly-held reference that has since been collected.
98
/// <returns>A weak <see cref="
ReferenceHolder
{T}"/> which was already collected.</returns>
99
public static
ReferenceHolder
<T> ReleasedWeak(int hashCode)
Utilities\WeakSet`1.cs (3)
16
private readonly HashSet<
ReferenceHolder
<T>> _values = [];
27
return _values.Add(
ReferenceHolder
<T>.Weak(value));
32
return _values.Contains(
ReferenceHolder
<T>.Strong(value));
Microsoft.CodeAnalysis.Workspaces.UnitTests (10)
UtilityTest\ReferenceHolderTests.cs (10)
17
var
first = ReferenceHolder<object?>.Strong(obj);
18
var
second = ReferenceHolder<object?>.Strong(obj);
27
var
first = ReferenceHolder<object?>.Weak(obj);
28
var
second = ReferenceHolder<object?>.Weak(obj);
41
var
first = ReferenceHolder<object?>.Strong(obj);
42
var
second = ReferenceHolder<object?>.Weak(obj);
50
var
first = ReferenceHolder<object?>.Strong(null);
51
var
second = ReferenceHolder<object?>.Weak(null);
59
var
strongNull = ReferenceHolder<object?>.Strong(null);
60
var
weakNull = ReferenceHolder<object?>.Weak(null);