using System.Runtime.CompilerServices; using TerraFX.Interop.Windows; namespace ComputeSharp.D2D1.Tests.Extensions; /// /// Helper methods for working with the type. /// /// Trimmed down version of the same file in ComputeSharp. internal static class ComPtrExtensions { /// /// Moves the current instance and resets it without releasing the reference. /// /// The type to wrap in the current instance. /// The input instance to move. /// The moved instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] public static unsafe ComPtr Move(this in ComPtr ptr) where T : unmanaged, IUnknown.Interface { ComPtr copy = default; Unsafe.AsRef(in ptr).Swap(ref copy); return copy; } }