Stashbox by Peter Csajtai

<PackageReference Include="Stashbox" Version="3.1.2-preview-556" />

 Swap

static class Swap
public static void SwapCurrent<T1, T2, T3, T4, TValue>(ref TValue refValue, Func<T1, T2, T3, T4, TValue, TValue> valueFactory, T1 t1, T2 t2, T3 t3, T4 t4)

public static void SwapValue<T1, T2, T3, T4, TValue>(ref TValue refValue, Func<T1, T2, T3, T4, TValue, TValue> valueFactory, T1 t1, T2 t2, T3 t3, T4 t4)

public static bool TrySwapCurrent<TValue>(ref TValue refValue, TValue currentValue, TValue newValue)