/
githubmirror
/
roslyn
Обзор
Документация
Войти
/
githubmirror
/
roslyn
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Dependencies/Threading/IAsyncEnumerableExtensions.cs
33 строки
1 KB
Copilot
Remove obsolete CS1998 suppressions (#84216)
23 июн 2026, 03:21
Не верифицирован
23 июн 2026, 03:21
e9dffb7
Код
Авторство
О чём код?
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.PooledObjects; namespace Microsoft.CodeAnalysis; internal static class IAsyncEnumerableExtensions { public static async Task<ImmutableArray<T>> ToImmutableArrayAsync<T>(this IAsyncEnumerable<T> values, CancellationToken cancellationToken) { using var _ = ArrayBuilder<T>.GetInstance(out var result); await foreach (var value in values.WithCancellation(cancellationToken).ConfigureAwait(false)) result.Add(value); return result.ToImmutableAndClear(); } #pragma warning disable VSTHRD200 // Use "Async" suffix for async methods public static async IAsyncEnumerable<TSource> AsAsyncEnumerable<TSource>(this IEnumerable<TSource> source) #pragma warning restore VSTHRD200 // Use "Async" suffix for async methods { foreach (var item in source) yield return item; } }