in TeamCity.VSTest.TestLogger/Disposable.cs [32:51]
private sealed class DisposableAction(Action action, object? key = null) : IDisposable
{
private readonly object _key = key ?? action;
private int _counter;
public void Dispose()
{
if (Interlocked.Increment(ref _counter) != 1) return;
action();
}
public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
return obj is DisposableAction other && Equals(_key, other._key);
}
public override int GetHashCode() => _key.GetHashCode();
}