mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-03-12 13:16:19 +00:00
Ban the usage of Task.Result
If the calling function can't be made async easily you can still use .GetAwaiter().GetResult(), which is way easier to find in the future
This commit is contained in:
@@ -331,7 +331,7 @@ namespace Emby.Server.Implementations.Channels
|
||||
|
||||
private Channel GetChannelEntity(IChannel channel)
|
||||
{
|
||||
return GetChannel(GetInternalChannelId(channel.Name)) ?? GetChannel(channel, CancellationToken.None).Result;
|
||||
return GetChannel(GetInternalChannelId(channel.Name)) ?? GetChannel(channel, CancellationToken.None).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
private MediaSourceInfo[] GetSavedMediaSources(BaseItem item)
|
||||
|
||||
@@ -55,6 +55,10 @@
|
||||
|
||||
<!-- Code Analyzers-->
|
||||
<ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.BannedApiAnalyzers" Version="3.3.3">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="SerilogAnalyzer" Version="0.15.0" PrivateAssets="All" />
|
||||
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.376" PrivateAssets="All" />
|
||||
<PackageReference Include="SmartAnalyzers.MultithreadingAnalyzer" Version="1.1.31" PrivateAssets="All" />
|
||||
|
||||
@@ -915,21 +915,21 @@ namespace Emby.Server.Implementations.LiveTv
|
||||
programs.ToArray());
|
||||
}
|
||||
|
||||
public QueryResult<BaseItemDto> GetRecommendedPrograms(InternalItemsQuery query, DtoOptions options, CancellationToken cancellationToken)
|
||||
public Task<QueryResult<BaseItemDto>> GetRecommendedProgramsAsync(InternalItemsQuery query, DtoOptions options, CancellationToken cancellationToken)
|
||||
{
|
||||
if (!(query.IsAiring ?? false))
|
||||
{
|
||||
return GetPrograms(query, options, cancellationToken).Result;
|
||||
return GetPrograms(query, options, cancellationToken);
|
||||
}
|
||||
|
||||
RemoveFields(options);
|
||||
|
||||
var internalResult = GetRecommendedProgramsInternal(query, options, cancellationToken);
|
||||
|
||||
return new QueryResult<BaseItemDto>(
|
||||
return Task.FromResult(new QueryResult<BaseItemDto>(
|
||||
query.StartIndex,
|
||||
internalResult.TotalRecordCount,
|
||||
_dtoService.GetBaseItemDtos(internalResult.Items, options, query.User));
|
||||
_dtoService.GetBaseItemDtos(internalResult.Items, options, query.User)));
|
||||
}
|
||||
|
||||
private int GetRecommendationScore(LiveTvProgram program, User user, bool factorChannelWatchCount)
|
||||
|
||||
Reference in New Issue
Block a user