Skip to content

Commit

Permalink
Remove System.Linq.Async and GetKeyedService overload
Browse files Browse the repository at this point in the history
  • Loading branch information
caaavik-msft committed Feb 19, 2025
1 parent 23dc0f5 commit 2b3fb93
Show file tree
Hide file tree
Showing 8 changed files with 3 additions and 25 deletions.
1 change: 0 additions & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
<PackageVersion Include="SixLabors.ImageSharp.Web.Providers.AWS" Version="3.1.3" />
<PackageVersion Include="StackExchange.Redis" Version="2.8.24" />
<PackageVersion Include="StyleCop.Analyzers" Version="1.1.118" />
<PackageVersion Include="System.Linq.Async" Version="6.0.1" />
<PackageVersion Include="System.IO.Hashing" Version="8.0.0" />
<PackageVersion Include="xunit.v3" Version="1.0.0" />
<PackageVersion Include="xunit.analyzers" Version="1.18.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public async Task<ActionResult<IEnumerable<MediaFolderViewModel>>> GetFolders(st
}

var allowed = _mediaFileStore.GetDirectoryContentAsync(path)
.WhereAwait(async e => e.IsDirectory && await _authorizationService.AuthorizeAsync(User, MediaPermissions.ManageMediaFolder, (object)e.Path));
.Where(async (e, t) => e.IsDirectory && await _authorizationService.AuthorizeAsync(User, MediaPermissions.ManageMediaFolder, (object)e.Path));

return Ok(await allowed.Select(folder =>
{
Expand Down Expand Up @@ -138,7 +138,7 @@ public async Task<ActionResult<IEnumerable<object>>> GetMediaItems(string path,
var allowedExtensions = GetRequestedExtensions(extensions, false);

var allowed = _mediaFileStore.GetDirectoryContentAsync(path)
.WhereAwait(async e =>
.Where(async (e, ct) =>
!e.IsDirectory
&& (allowedExtensions.Count == 0 || allowedExtensions.Contains(Path.GetExtension(e.Path)))
&& await _authorizationService.AuthorizeAsync(User, MediaPermissions.ManageMediaFolder, (object)e.Path))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ await context.Updater.TryUpdateModelAsync(step,
private async Task<IList<MediaStoreEntryViewModel>> GetMediaStoreEntries(string path = null, MediaStoreEntryViewModel parent = null)
{
var mediaStoreEntries = await _mediaFileStore.GetDirectoryContentAsync(path)
.SelectAwait(async e =>
.Select(async (FileStorage.IFileStoreEntry e, CancellationToken token) =>
{
var mediaStoreEntry = new MediaStoreEntryViewModel
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
<ItemGroup>
<PackageReference Include="Shortcodes" />
<PackageReference Include="SixLabors.ImageSharp.Web" />
<PackageReference Include="System.Linq.Async" />
<PackageReference Include="System.IO.Hashing" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,4 @@ public static TResult CreateInstance<TResult>(this IServiceProvider provider, Ty
{
return (TResult)ActivatorUtilities.CreateInstance(provider, type);
}

/// <summary>
/// Gets the service object of the specified type with the specified key.
/// </summary>
public static object? GetKeyedService(this IServiceProvider provider, Type serviceType, object? serviceKey)
{
ArgumentNullException.ThrowIfNull(provider);
if (provider is IKeyedServiceProvider keyedServiceProvider)
{
return keyedServiceProvider.GetKeyedService(serviceType, serviceKey);
}

throw new InvalidOperationException("This service provider doesn't support keyed services.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,4 @@
<ProjectReference Include="..\OrchardCore.FileStorage.Abstractions\OrchardCore.FileStorage.Abstractions.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.Linq.Async" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
<PackageReference Include="Lorem.Universal.NET" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="System.Linq.Async" />
<PackageReference Include="Moq" />
<PackageReference Include="xunit.v3" />
<PackageReference Include="xunit.analyzers" />
Expand Down
1 change: 0 additions & 1 deletion test/OrchardCore.Tests/OrchardCore.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
<PackageReference Include="AngleSharp" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="System.Linq.Async" />
<PackageReference Include="Moq" />
<PackageReference Include="xunit.v3" />
<PackageReference Include="xunit.analyzers" />
Expand Down

0 comments on commit 2b3fb93

Please sign in to comment.