3 instantiations of ReferenceHolder
Microsoft.CodeAnalysis.Workspaces (3)
Utilities\ReferenceHolder`1.cs (3)
31=> new(value); 41return 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)
9internal readonly struct ReferenceHolder<T> : IEquatable<ReferenceHolder<T>> 30public static ReferenceHolder<T> Strong(T value) 33public static ReferenceHolder<T> Weak(T value) 54return obj is ReferenceHolder<T> other 58public 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> 99public static ReferenceHolder<T> ReleasedWeak(int hashCode)
Utilities\WeakSet`1.cs (3)
16private readonly HashSet<ReferenceHolder<T>> _values = []; 27return _values.Add(ReferenceHolder<T>.Weak(value)); 32return _values.Contains(ReferenceHolder<T>.Strong(value));
Microsoft.CodeAnalysis.Workspaces.UnitTests (10)
UtilityTest\ReferenceHolderTests.cs (10)
17var first = ReferenceHolder<object?>.Strong(obj); 18var second = ReferenceHolder<object?>.Strong(obj); 27var first = ReferenceHolder<object?>.Weak(obj); 28var second = ReferenceHolder<object?>.Weak(obj); 41var first = ReferenceHolder<object?>.Strong(obj); 42var second = ReferenceHolder<object?>.Weak(obj); 50var first = ReferenceHolder<object?>.Strong(null); 51var second = ReferenceHolder<object?>.Weak(null); 59var strongNull = ReferenceHolder<object?>.Strong(null); 60var weakNull = ReferenceHolder<object?>.Weak(null);