File: System\Private\Windows\Ole\ClipboardScope.cs
Web Access
Project: src\src\System.Private.Windows.Core\tests\System.Private.Windows.Core.Tests\System.Private.Windows.Core.Tests.csproj (System.Private.Windows.Core.Tests)
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
 
using Windows.Win32.Foundation;
 
namespace System.Private.Windows.Ole;
 
/// <summary>
///  Ensures the CoreClipboard is cleared before and after a test.
/// </summary>
internal ref struct ClipboardScope<TOleServices> where TOleServices : IOleServices
{
    public ClipboardScope() => ClipboardCore<TOleServices>.Clear(retryTimes: 1, retryDelay: 0).Should().Be(HRESULT.S_OK);
 
#pragma warning disable CA1822 // Mark members as static - must be an instance for the dispose pattern matching to work
    public readonly void Dispose() => ClipboardCore<TOleServices>.Clear(retryTimes: 1, retryDelay: 0).Should().Be(HRESULT.S_OK);
#pragma warning restore CA1822
}