// <auto-generated />

#if !NETCOREAPP

#pragma warning disable

using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Linq;

namespace Polyfills;

// IMPORTANT (see https://github.com/microsoft/testfx/issues/9710):
// These Polyfill helpers are intentionally kept even though newer Microsoft.Testing.Platform code no
// longer calls them. Older (2.x) extension assemblies - e.g. Microsoft.Testing.Extensions.Telemetry,
// TrxReport, TrxReport.Abstractions and VSTestBridge - were compiled against these members and access
// them from the platform assembly via [InternalsVisibleTo] (they did not embed their own copy). Their
// baked-in member references are resolved by the runtime against THIS assembly, so removing any of the
// members below would reintroduce a MissingMethodException when a newer platform loads an older
// extension's netstandard2.0 / .NET Framework asset (the .NET assets bind these to the BCL and are not
// affected). Do NOT delete these as "unused polyfills".
internal static partial class Polyfill
{
    public static void Deconstruct<TKey, TValue>(this KeyValuePair<TKey, TValue> pair, out TKey key, out TValue value)
    {
        key = pair.Key;
        value = pair.Value;
    }

    public static bool Contains(this string target, char value)
        => target.IndexOf(value) != -1;

    public static bool Contains(this string target, string value, StringComparison comparisonType)
        => target.IndexOf(value, comparisonType) != -1;

    public static StringBuilder AppendJoin(this StringBuilder target, string separator, params string[] values)
        => target.Append(string.Join(separator, values));

    public static StringBuilder AppendJoin<T>(this StringBuilder target, string separator, IEnumerable<T> values)
        => target.Append(string.Join(separator, values));

    public static Task CopyToAsync(this Stream source, Stream destination, CancellationToken cancellationToken)
        => source.CopyToAsync(destination, 81920, cancellationToken);

    public static Task SaveAsync(this XDocument target, Stream stream, SaveOptions options, CancellationToken cancellationToken)
    {
        cancellationToken.ThrowIfCancellationRequested();
        target.Save(stream, options);
        return Task.CompletedTask;
    }
}
#endif
