Fix warning SA1414 and CA1849
This commit is contained in:
parent
d24683f0ab
commit
05836c8cd3
|
@ -1192,13 +1192,13 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="result">A <see cref="QueryResult{BaseItem}"/>.</param>
|
/// <param name="result">A <see cref="QueryResult{BaseItem}"/>.</param>
|
||||||
/// <returns>The <see cref="QueryResult{ServerItem}"/>.</returns>
|
/// <returns>The <see cref="QueryResult{ServerItem}"/>.</returns>
|
||||||
private static QueryResult<ServerItem> ToResult(QueryResult<(BaseItem, ItemCounts)> result)
|
private static QueryResult<ServerItem> ToResult(QueryResult<(BaseItem Item, ItemCounts ItemCounts)> result)
|
||||||
{
|
{
|
||||||
var length = result.Items.Count;
|
var length = result.Items.Count;
|
||||||
var serverItems = new ServerItem[length];
|
var serverItems = new ServerItem[length];
|
||||||
for (var i = 0; i < length; i++)
|
for (var i = 0; i < length; i++)
|
||||||
{
|
{
|
||||||
serverItems[i] = new ServerItem(result.Items[i].Item1, null);
|
serverItems[i] = new ServerItem(result.Items[i].Item, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new QueryResult<ServerItem>
|
return new QueryResult<ServerItem>
|
||||||
|
@ -1213,7 +1213,7 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sort">The <see cref="SortCriteria"/>.</param>
|
/// <param name="sort">The <see cref="SortCriteria"/>.</param>
|
||||||
/// <param name="isPreSorted">True if pre-sorted.</param>
|
/// <param name="isPreSorted">True if pre-sorted.</param>
|
||||||
private static (string, SortOrder)[] GetOrderBy(SortCriteria sort, bool isPreSorted)
|
private static (string SortName, SortOrder SortOrder)[] GetOrderBy(SortCriteria sort, bool isPreSorted)
|
||||||
{
|
{
|
||||||
return isPreSorted ? Array.Empty<(string, SortOrder)>() : new[] { (ItemSortBy.SortName, sort.SortOrder) };
|
return isPreSorted ? Array.Empty<(string, SortOrder)>() : new[] { (ItemSortBy.SortName, sort.SortOrder) };
|
||||||
}
|
}
|
||||||
|
|
|
@ -535,9 +535,9 @@ namespace Emby.Dlna.PlayTo
|
||||||
{
|
{
|
||||||
var tuple = await GetPositionInfo(avCommands, cancellationToken).ConfigureAwait(false);
|
var tuple = await GetPositionInfo(avCommands, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
var currentObject = tuple.Item2;
|
var currentObject = tuple.Track;
|
||||||
|
|
||||||
if (tuple.Item1 && currentObject == null)
|
if (tuple.Success && currentObject == null)
|
||||||
{
|
{
|
||||||
currentObject = await GetMediaInfo(avCommands, cancellationToken).ConfigureAwait(false);
|
currentObject = await GetMediaInfo(avCommands, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
@ -797,7 +797,7 @@ namespace Emby.Dlna.PlayTo
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<(bool, UBaseObject)> GetPositionInfo(TransportCommands avCommands, CancellationToken cancellationToken)
|
private async Task<(bool Success, UBaseObject Track)> GetPositionInfo(TransportCommands avCommands, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var command = avCommands.ServiceActions.FirstOrDefault(c => c.Name == "GetPositionInfo");
|
var command = avCommands.ServiceActions.FirstOrDefault(c => c.Name == "GetPositionInfo");
|
||||||
if (command == null)
|
if (command == null)
|
||||||
|
|
|
@ -47,7 +47,7 @@ namespace Emby.Dlna.Service
|
||||||
|
|
||||||
private async Task<ControlResponse> ProcessControlRequestInternalAsync(ControlRequest request)
|
private async Task<ControlResponse> ProcessControlRequestInternalAsync(ControlRequest request)
|
||||||
{
|
{
|
||||||
ControlRequestInfo? requestInfo = null;
|
ControlRequestInfo requestInfo;
|
||||||
|
|
||||||
using (var streamReader = new StreamReader(request.InputXml, Encoding.UTF8))
|
using (var streamReader = new StreamReader(request.InputXml, Encoding.UTF8))
|
||||||
{
|
{
|
||||||
|
@ -66,6 +66,11 @@ namespace Emby.Dlna.Service
|
||||||
|
|
||||||
Logger.LogDebug("Received control request {LocalName}, params: {@Headers}", requestInfo.LocalName, requestInfo.Headers);
|
Logger.LogDebug("Received control request {LocalName}, params: {@Headers}", requestInfo.LocalName, requestInfo.Headers);
|
||||||
|
|
||||||
|
return CreateControlResponse(requestInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ControlResponse CreateControlResponse(ControlRequestInfo requestInfo)
|
||||||
|
{
|
||||||
var settings = new XmlWriterSettings
|
var settings = new XmlWriterSettings
|
||||||
{
|
{
|
||||||
Encoding = Encoding.UTF8,
|
Encoding = Encoding.UTF8,
|
||||||
|
@ -112,29 +117,19 @@ namespace Emby.Dlna.Service
|
||||||
{
|
{
|
||||||
if (reader.NodeType == XmlNodeType.Element)
|
if (reader.NodeType == XmlNodeType.Element)
|
||||||
{
|
{
|
||||||
switch (reader.LocalName)
|
if (string.Equals(reader.LocalName, "Body", StringComparison.Ordinal))
|
||||||
{
|
{
|
||||||
case "Body":
|
if (reader.IsEmptyElement)
|
||||||
{
|
{
|
||||||
if (!reader.IsEmptyElement)
|
await reader.ReadAsync().ConfigureAwait(false);
|
||||||
{
|
continue;
|
||||||
using var subReader = reader.ReadSubtree();
|
}
|
||||||
return await ParseBodyTagAsync(subReader).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
await reader.ReadAsync().ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
using var subReader = reader.ReadSubtree();
|
||||||
}
|
return await ParseBodyTagAsync(subReader).ConfigureAwait(false);
|
||||||
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
await reader.SkipAsync().ConfigureAwait(false);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await reader.SkipAsync().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -160,17 +155,17 @@ namespace Emby.Dlna.Service
|
||||||
localName = reader.LocalName;
|
localName = reader.LocalName;
|
||||||
namespaceURI = reader.NamespaceURI;
|
namespaceURI = reader.NamespaceURI;
|
||||||
|
|
||||||
if (!reader.IsEmptyElement)
|
if (reader.IsEmptyElement)
|
||||||
|
{
|
||||||
|
await reader.ReadAsync().ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
var result = new ControlRequestInfo(localName, namespaceURI);
|
var result = new ControlRequestInfo(localName, namespaceURI);
|
||||||
using var subReader = reader.ReadSubtree();
|
using var subReader = reader.ReadSubtree();
|
||||||
await ParseFirstBodyChildAsync(subReader, result.Headers).ConfigureAwait(false);
|
await ParseFirstBodyChildAsync(subReader, result.Headers).ConfigureAwait(false);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
await reader.ReadAsync().ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -80,7 +80,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
|
||||||
_remoteEndPoint = new IPEndPoint(remoteIp, HdHomeRunPort);
|
_remoteEndPoint = new IPEndPoint(remoteIp, HdHomeRunPort);
|
||||||
|
|
||||||
_tcpClient = new TcpClient();
|
_tcpClient = new TcpClient();
|
||||||
_tcpClient.Connect(_remoteEndPoint);
|
await _tcpClient.ConnectAsync(_remoteEndPoint, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
if (!_lockkey.HasValue)
|
if (!_lockkey.HasValue)
|
||||||
{
|
{
|
||||||
|
@ -158,7 +158,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
|
||||||
}
|
}
|
||||||
|
|
||||||
using var tcpClient = new TcpClient();
|
using var tcpClient = new TcpClient();
|
||||||
tcpClient.Connect(_remoteEndPoint);
|
await tcpClient.ConnectAsync(_remoteEndPoint, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
using var stream = tcpClient.GetStream();
|
using var stream = tcpClient.GetStream();
|
||||||
var commandList = commands.GetCommands();
|
var commandList = commands.GetCommands();
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
#pragma warning disable CS1591
|
#pragma warning disable CS1591
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
@ -51,7 +49,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
|
||||||
|
|
||||||
var url = mediaSource.Path;
|
var url = mediaSource.Path;
|
||||||
|
|
||||||
Directory.CreateDirectory(Path.GetDirectoryName(TempFilePath));
|
Directory.CreateDirectory(Path.GetDirectoryName(TempFilePath) ?? throw new InvalidOperationException("Path can't be a root directory."));
|
||||||
|
|
||||||
var typeName = GetType().Name;
|
var typeName = GetType().Name;
|
||||||
Logger.LogInformation("Opening {StreamType} Live stream from {Url}", typeName, url);
|
Logger.LogInformation("Opening {StreamType} Live stream from {Url}", typeName, url);
|
||||||
|
@ -94,14 +92,8 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
|
||||||
// OpenedMediaSource.SupportsDirectPlay = false;
|
// OpenedMediaSource.SupportsDirectPlay = false;
|
||||||
// OpenedMediaSource.SupportsDirectStream = true;
|
// OpenedMediaSource.SupportsDirectStream = true;
|
||||||
// OpenedMediaSource.SupportsTranscoding = true;
|
// OpenedMediaSource.SupportsTranscoding = true;
|
||||||
await taskCompletionSource.Task.ConfigureAwait(false);
|
var res = await taskCompletionSource.Task.ConfigureAwait(false);
|
||||||
if (taskCompletionSource.Task.Exception != null)
|
if (!res)
|
||||||
{
|
|
||||||
// Error happened while opening the stream so raise the exception again to inform the caller
|
|
||||||
throw taskCompletionSource.Task.Exception;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!taskCompletionSource.Task.Result)
|
|
||||||
{
|
{
|
||||||
Logger.LogWarning("Zero bytes copied from stream {StreamType} to {FilePath} but no exception raised", GetType().Name, TempFilePath);
|
Logger.LogWarning("Zero bytes copied from stream {StreamType} to {FilePath} but no exception raised", GetType().Name, TempFilePath);
|
||||||
throw new EndOfStreamException(string.Format(CultureInfo.InvariantCulture, "Zero bytes copied from stream {0}", GetType().Name));
|
throw new EndOfStreamException(string.Format(CultureInfo.InvariantCulture, "Zero bytes copied from stream {0}", GetType().Name));
|
||||||
|
|
|
@ -104,7 +104,7 @@ namespace Jellyfin.Api.Helpers
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static QueryResult<BaseItemDto> CreateQueryResult(
|
internal static QueryResult<BaseItemDto> CreateQueryResult(
|
||||||
QueryResult<(BaseItem, ItemCounts)> result,
|
QueryResult<(BaseItem Item, ItemCounts ItemCounts)> result,
|
||||||
DtoOptions dtoOptions,
|
DtoOptions dtoOptions,
|
||||||
IDtoService dtoService,
|
IDtoService dtoService,
|
||||||
bool includeItemTypes,
|
bool includeItemTypes,
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
<Rule Id="SA1210" Action="Error" />
|
<Rule Id="SA1210" Action="Error" />
|
||||||
<!-- error on SA1316: Tuple element names should use correct casing -->
|
<!-- error on SA1316: Tuple element names should use correct casing -->
|
||||||
<Rule Id="SA1316" Action="Error" />
|
<Rule Id="SA1316" Action="Error" />
|
||||||
|
<!-- error on SA1414: Tuple types in signatures should have element names -->
|
||||||
|
<Rule Id="SA1414" Action="Error" />
|
||||||
<!-- error on SA1518: File is required to end with a single newline character -->
|
<!-- error on SA1518: File is required to end with a single newline character -->
|
||||||
<Rule Id="SA1518" Action="Error" />
|
<Rule Id="SA1518" Action="Error" />
|
||||||
<!-- error on SA1629: Documentation text should end with a period -->
|
<!-- error on SA1629: Documentation text should end with a period -->
|
||||||
|
@ -73,6 +75,8 @@
|
||||||
<Rule Id="CA1843" Action="Error" />
|
<Rule Id="CA1843" Action="Error" />
|
||||||
<!-- error on CA1845: Use span-based 'string.Concat' -->
|
<!-- error on CA1845: Use span-based 'string.Concat' -->
|
||||||
<Rule Id="CA1845" Action="Error" />
|
<Rule Id="CA1845" Action="Error" />
|
||||||
|
<!-- error on CA1849: Call async methods when in an async method -->
|
||||||
|
<Rule Id="CA1849" Action="Error" />
|
||||||
<!-- error on CA2016: Forward the CancellationToken parameter to methods that take one
|
<!-- error on CA2016: Forward the CancellationToken parameter to methods that take one
|
||||||
or pass in 'CancellationToken.None' explicitly to indicate intentionally not propagating the token -->
|
or pass in 'CancellationToken.None' explicitly to indicate intentionally not propagating the token -->
|
||||||
<Rule Id="CA2016" Action="Error" />
|
<Rule Id="CA2016" Action="Error" />
|
||||||
|
|
Loading…
Reference in New Issue
Block a user