Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove System.Linq.Async dependency. #19745

Merged
merged 1 commit into from
Mar 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion eng/Packages.Data.props
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
<PackageReference Update="Microsoft.Bcl.AsyncInterfaces" Version="1.0.0" />
<PackageReference Update="Microsoft.CSharp" Version="4.5.0" />
<PackageReference Update="System.Collections.Immutable" Version="1.3.1" />
<PackageReference Update="System.Linq.Async" Version="4.0.0" />

<!-- Azure SDK packages -->
<PackageReference Update="Azure.Core" Version="1.10.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
<ItemGroup>
<PackageReference Include="System.Collections.Immutable" />
<PackageReference Include="Azure.ResourceManager.Resources" />
<PackageReference Include="System.Linq.Async" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using System.Threading;
using System.Threading.Tasks;

namespace Azure.ResourceManager.Core.Extensions
{
internal static class AsyncPageableExtensions
{
public static async Task<TSource> FirstOrDefaultAsync<TSource>(
this AsyncPageable<TSource> source,
Func<TSource, bool> predicate,
CancellationToken token = default)
{
if (source == null)
throw new ArgumentNullException(nameof(source));
if (predicate == null)
throw new ArgumentNullException(nameof(predicate));

token.ThrowIfCancellationRequested();

await foreach (var item in source.ConfigureAwait(false))
{
token.ThrowIfCancellationRequested();

if (predicate(item))
{
return item;
}
}

return default;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Threading;
using System.Threading.Tasks;
using Azure.Core;
using Azure.ResourceManager.Core.Extensions;

namespace Azure.ResourceManager.Core
{
Expand Down