Merge pull request #1967 from Bond-009/warn10

Fix some warnings
This commit is contained in:
Vasily 2019-11-22 18:29:17 +03:00 committed by GitHub
commit 7b3c394a3e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
48 changed files with 116 additions and 202 deletions

View file

@ -3,7 +3,7 @@ using System;
namespace Emby.Naming.AudioBook namespace Emby.Naming.AudioBook
{ {
/// <summary> /// <summary>
/// Represents a single video file /// Represents a single video file.
/// </summary> /// </summary>
public class AudioBookFileInfo : IComparable<AudioBookFileInfo> public class AudioBookFileInfo : IComparable<AudioBookFileInfo>
{ {

View file

@ -3,7 +3,7 @@ using System.Collections.Generic;
namespace Emby.Naming.AudioBook namespace Emby.Naming.AudioBook
{ {
/// <summary> /// <summary>
/// Represents a complete video, including all parts and subtitles /// Represents a complete video, including all parts and subtitles.
/// </summary> /// </summary>
public class AudioBookInfo public class AudioBookInfo
{ {

View file

@ -25,7 +25,7 @@ namespace Emby.Naming.TV
} }
/// <summary> /// <summary>
/// A season folder must contain one of these somewhere in the name /// A season folder must contain one of these somewhere in the name.
/// </summary> /// </summary>
private static readonly string[] _seasonFolderNames = private static readonly string[] _seasonFolderNames =
{ {
@ -124,7 +124,7 @@ namespace Emby.Naming.TV
} }
/// <summary> /// <summary>
/// Extracts the season number from the second half of the Season folder name (everything after "Season", or "Staffel") /// Extracts the season number from the second half of the Season folder name (everything after "Season", or "Staffel").
/// </summary> /// </summary>
/// <param name="path">The path.</param> /// <param name="path">The path.</param>
/// <returns>System.Nullable{System.Int32}.</returns> /// <returns>System.Nullable{System.Int32}.</returns>

View file

@ -8,7 +8,7 @@ using Emby.Naming.Common;
namespace Emby.Naming.Video namespace Emby.Naming.Video
{ {
/// <summary> /// <summary>
/// http://kodi.wiki/view/Advancedsettings.xml#video /// <see href="http://kodi.wiki/view/Advancedsettings.xml#video" />.
/// </summary> /// </summary>
public class CleanDateTimeParser public class CleanDateTimeParser
{ {

View file

@ -1,7 +1,7 @@
namespace Emby.Naming.Video namespace Emby.Naming.Video
{ {
/// <summary> /// <summary>
/// Represents a single video file /// Represents a single video file.
/// </summary> /// </summary>
public class VideoFileInfo public class VideoFileInfo
{ {

View file

@ -3,7 +3,7 @@ using System.Collections.Generic;
namespace Emby.Naming.Video namespace Emby.Naming.Video
{ {
/// <summary> /// <summary>
/// Represents a complete video, including all parts and subtitles /// Represents a complete video, including all parts and subtitles.
/// </summary> /// </summary>
public class VideoInfo public class VideoInfo
{ {

View file

@ -41,7 +41,7 @@ namespace Emby.Naming.Video
/// <param name="isDirectory">if set to <c>true</c> [is folder].</param> /// <param name="isDirectory">if set to <c>true</c> [is folder].</param>
/// <param name="parseName">Whether or not the name should be parsed for info</param> /// <param name="parseName">Whether or not the name should be parsed for info</param>
/// <returns>VideoFileInfo.</returns> /// <returns>VideoFileInfo.</returns>
/// <exception cref="ArgumentNullException">path</exception> /// <exception cref="ArgumentNullException"><c>path</c> is <c>null</c>.</exception>
public VideoFileInfo Resolve(string path, bool isDirectory, bool parseName = true) public VideoFileInfo Resolve(string path, bool isDirectory, bool parseName = true)
{ {
if (string.IsNullOrEmpty(path)) if (string.IsNullOrEmpty(path))

View file

@ -616,8 +616,8 @@ namespace Emby.Server.Implementations.Activity
/// <summary> /// <summary>
/// Constructs a string description of a time-span value. /// Constructs a string description of a time-span value.
/// </summary> /// </summary>
/// <param name="value">The value of this item</param> /// <param name="value">The value of this item.</param>
/// <param name="description">The name of this item (singular form)</param> /// <param name="description">The name of this item (singular form).</param>
private static string CreateValueString(int value, string description) private static string CreateValueString(int value, string description)
{ {
return string.Format( return string.Format(

View file

@ -16,7 +16,7 @@ using Microsoft.Extensions.Logging;
namespace Emby.Server.Implementations.AppBase namespace Emby.Server.Implementations.AppBase
{ {
/// <summary> /// <summary>
/// Class BaseConfigurationManager /// Class BaseConfigurationManager.
/// </summary> /// </summary>
public abstract class BaseConfigurationManager : IConfigurationManager public abstract class BaseConfigurationManager : IConfigurationManager
{ {
@ -48,7 +48,7 @@ namespace Emby.Server.Implementations.AppBase
/// <param name="applicationPaths">The application paths.</param> /// <param name="applicationPaths">The application paths.</param>
/// <param name="loggerFactory">The logger factory.</param> /// <param name="loggerFactory">The logger factory.</param>
/// <param name="xmlSerializer">The XML serializer.</param> /// <param name="xmlSerializer">The XML serializer.</param>
/// <param name="fileSystem">The file system</param> /// <param name="fileSystem">The file system.</param>
protected BaseConfigurationManager(IApplicationPaths applicationPaths, ILoggerFactory loggerFactory, IXmlSerializer xmlSerializer, IFileSystem fileSystem) protected BaseConfigurationManager(IApplicationPaths applicationPaths, ILoggerFactory loggerFactory, IXmlSerializer xmlSerializer, IFileSystem fileSystem)
{ {
CommonApplicationPaths = applicationPaths; CommonApplicationPaths = applicationPaths;
@ -92,7 +92,7 @@ namespace Emby.Server.Implementations.AppBase
protected IXmlSerializer XmlSerializer { get; private set; } protected IXmlSerializer XmlSerializer { get; private set; }
/// <summary> /// <summary>
/// Gets or sets the application paths. /// Gets the application paths.
/// </summary> /// </summary>
/// <value>The application paths.</value> /// <value>The application paths.</value>
public IApplicationPaths CommonApplicationPaths { get; private set; } public IApplicationPaths CommonApplicationPaths { get; private set; }
@ -173,7 +173,7 @@ namespace Emby.Server.Implementations.AppBase
/// Replaces the configuration. /// Replaces the configuration.
/// </summary> /// </summary>
/// <param name="newConfiguration">The new configuration.</param> /// <param name="newConfiguration">The new configuration.</param>
/// <exception cref="ArgumentNullException">newConfiguration</exception> /// <exception cref="ArgumentNullException"><c>newConfiguration</c> is <c>null</c>.</exception>
public virtual void ReplaceConfiguration(BaseApplicationConfiguration newConfiguration) public virtual void ReplaceConfiguration(BaseApplicationConfiguration newConfiguration)
{ {
if (newConfiguration == null) if (newConfiguration == null)

View file

@ -6,13 +6,13 @@ using MediaBrowser.Model.Serialization;
namespace Emby.Server.Implementations.AppBase namespace Emby.Server.Implementations.AppBase
{ {
/// <summary> /// <summary>
/// Class ConfigurationHelper /// Class ConfigurationHelper.
/// </summary> /// </summary>
public static class ConfigurationHelper public static class ConfigurationHelper
{ {
/// <summary> /// <summary>
/// Reads an xml configuration file from the file system /// Reads an xml configuration file from the file system
/// It will immediately re-serialize and save if new serialization data is available due to property changes /// It will immediately re-serialize and save if new serialization data is available due to property changes.
/// </summary> /// </summary>
/// <param name="type">The type.</param> /// <param name="type">The type.</param>
/// <param name="path">The path.</param> /// <param name="path">The path.</param>

View file

@ -321,7 +321,7 @@ namespace Emby.Server.Implementations
private readonly IConfiguration _configuration; private readonly IConfiguration _configuration;
/// <summary> /// <summary>
/// Gets or sets the installation manager. /// Gets the installation manager.
/// </summary> /// </summary>
/// <value>The installation manager.</value> /// <value>The installation manager.</value>
protected IInstallationManager InstallationManager { get; private set; } protected IInstallationManager InstallationManager { get; private set; }
@ -500,7 +500,7 @@ namespace Emby.Server.Implementations
/// <summary> /// <summary>
/// Gets the export types. /// Gets the export types.
/// </summary> /// </summary>
/// <typeparam name="T">The type</typeparam> /// <typeparam name="T">The type.</typeparam>
/// <returns>IEnumerable{Type}.</returns> /// <returns>IEnumerable{Type}.</returns>
public IEnumerable<Type> GetExportTypes<T>() public IEnumerable<Type> GetExportTypes<T>()
{ {
@ -1022,7 +1022,7 @@ namespace Emby.Server.Implementations
} }
/// <summary> /// <summary>
/// Dirty hacks /// Dirty hacks.
/// </summary> /// </summary>
private void SetStaticProperties() private void SetStaticProperties()
{ {

View file

@ -473,7 +473,7 @@ namespace Emby.Server.Implementations.Channels
await item.RefreshMetadata(new MetadataRefreshOptions(new DirectoryService(_fileSystem)) await item.RefreshMetadata(new MetadataRefreshOptions(new DirectoryService(_fileSystem))
{ {
ForceSave = !isNew && forceUpdate ForceSave = !isNew && forceUpdate
}, cancellationToken); }, cancellationToken).ConfigureAwait(false);
return item; return item;
} }
@ -636,7 +636,7 @@ namespace Emby.Server.Implementations.Channels
private async Task RefreshLatestChannelItems(IChannel channel, CancellationToken cancellationToken) private async Task RefreshLatestChannelItems(IChannel channel, CancellationToken cancellationToken)
{ {
var internalChannel = await GetChannel(channel, cancellationToken); var internalChannel = await GetChannel(channel, cancellationToken).ConfigureAwait(false);
var query = new InternalItemsQuery(); var query = new InternalItemsQuery();
query.Parent = internalChannel; query.Parent = internalChannel;

View file

@ -121,7 +121,7 @@ namespace Emby.Server.Implementations.Collections
// This could cause it to get re-resolved as a plain folder // This could cause it to get re-resolved as a plain folder
var folderName = _fileSystem.GetValidFilename(name) + " [boxset]"; var folderName = _fileSystem.GetValidFilename(name) + " [boxset]";
var parentFolder = GetCollectionsFolder(true).Result; var parentFolder = GetCollectionsFolder(true).GetAwaiter().GetResult();
if (parentFolder == null) if (parentFolder == null)
{ {

View file

@ -1177,7 +1177,7 @@ namespace Emby.Server.Implementations.Data
{ {
if (id == Guid.Empty) if (id == Guid.Empty)
{ {
throw new ArgumentException(nameof(id), "Guid can't be empty"); throw new ArgumentException("Guid can't be empty", nameof(id));
} }
CheckDisposed(); CheckDisposed();

View file

@ -130,7 +130,6 @@ namespace Emby.Server.Implementations.Devices
var session = _authRepo.Get(new AuthenticationInfoQuery var session = _authRepo.Get(new AuthenticationInfoQuery
{ {
DeviceId = id DeviceId = id
}).Items.FirstOrDefault(); }).Items.FirstOrDefault();
var device = session == null ? null : ToDeviceInfo(session); var device = session == null ? null : ToDeviceInfo(session);

View file

@ -70,7 +70,6 @@ namespace Emby.Server.Implementations.EntryPoints
if (!string.Equals(_lastConfigIdentifier, GetConfigIdentifier(), StringComparison.OrdinalIgnoreCase)) if (!string.Equals(_lastConfigIdentifier, GetConfigIdentifier(), StringComparison.OrdinalIgnoreCase))
{ {
Stop(); Stop();
Start(); Start();
} }
} }

View file

@ -455,7 +455,7 @@ namespace Emby.Server.Implementations.EntryPoints
return new[] { item }; return new[] { item };
} }
return new T[] { }; return Array.Empty<T>();
} }
/// <summary> /// <summary>

View file

@ -156,7 +156,7 @@ namespace Emby.Server.Implementations.EntryPoints
{ {
try try
{ {
await _sessionManager.SendMessageToAdminSessions(name, data, CancellationToken.None); await _sessionManager.SendMessageToAdminSessions(name, data, CancellationToken.None).ConfigureAwait(false);
} }
catch (Exception) catch (Exception)
{ {

View file

@ -325,7 +325,7 @@ namespace Emby.Server.Implementations.HttpClientManager
if (options.LogErrorResponseBody) if (options.LogErrorResponseBody)
{ {
var msg = await response.Content.ReadAsStringAsync().ConfigureAwait(false); string msg = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
_logger.LogError("HTTP request failed with message: {Message}", msg); _logger.LogError("HTTP request failed with message: {Message}", msg);
} }

View file

@ -460,7 +460,7 @@ namespace Emby.Server.Implementations.HttpServer
if (string.IsNullOrEmpty(path)) if (string.IsNullOrEmpty(path))
{ {
throw new ArgumentNullException(nameof(path)); throw new ArgumentException("Path can't be empty.", nameof(options));
} }
if (fileShare != FileShareMode.Read && fileShare != FileShareMode.ReadWrite) if (fileShare != FileShareMode.Read && fileShare != FileShareMode.ReadWrite)

View file

@ -48,12 +48,14 @@ namespace Emby.Server.Implementations.HttpServer
public IDictionary<string, string> Headers => _options; public IDictionary<string, string> Headers => _options;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="StreamWriter" /> class. /// Initializes a new instance of the <see cref="RangeRequestWriter" /> class.
/// </summary> /// </summary>
/// <param name="rangeHeader">The range header.</param> /// <param name="rangeHeader">The range header.</param>
/// <param name="contentLength">The content length.</param>
/// <param name="source">The source.</param> /// <param name="source">The source.</param>
/// <param name="contentType">Type of the content.</param> /// <param name="contentType">Type of the content.</param>
/// <param name="isHeadRequest">if set to <c>true</c> [is head request].</param> /// <param name="isHeadRequest">if set to <c>true</c> [is head request].</param>
/// <param name="logger">The logger instance.</param>
public RangeRequestWriter(string rangeHeader, long contentLength, Stream source, string contentType, bool isHeadRequest, ILogger logger) public RangeRequestWriter(string rangeHeader, long contentLength, Stream source, string contentType, bool isHeadRequest, ILogger logger)
{ {
if (string.IsNullOrEmpty(contentType)) if (string.IsNullOrEmpty(contentType))

View file

@ -83,7 +83,7 @@ namespace Emby.Server.Implementations.Library
if (string.IsNullOrEmpty(searchTerm)) if (string.IsNullOrEmpty(searchTerm))
{ {
throw new ArgumentNullException(nameof(searchTerm)); throw new ArgumentNullException("SearchTerm can't be empty.", nameof(searchTerm));
} }
searchTerm = searchTerm.Trim().RemoveDiacritics(); searchTerm = searchTerm.Trim().RemoveDiacritics();

View file

@ -28,10 +28,11 @@ namespace Emby.Server.Implementations.Library.Validators
private readonly IItemRepository _itemRepo; private readonly IItemRepository _itemRepo;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ArtistsPostScanTask" /> class. /// Initializes a new instance of the <see cref="ArtistsValidator" /> class.
/// </summary> /// </summary>
/// <param name="libraryManager">The library manager.</param> /// <param name="libraryManager">The library manager.</param>
/// <param name="logger">The logger.</param> /// <param name="logger">The logger.</param>
/// <param name="itemRepo">The item repository.</param>
public ArtistsValidator(ILibraryManager libraryManager, ILogger logger, IItemRepository itemRepo) public ArtistsValidator(ILibraryManager libraryManager, ILogger logger, IItemRepository itemRepo)
{ {
_libraryManager = libraryManager; _libraryManager = libraryManager;

View file

@ -10,17 +10,18 @@ namespace Emby.Server.Implementations.Library.Validators
public class GenresPostScanTask : ILibraryPostScanTask public class GenresPostScanTask : ILibraryPostScanTask
{ {
/// <summary> /// <summary>
/// The _library manager /// The _library manager.
/// </summary> /// </summary>
private readonly ILibraryManager _libraryManager; private readonly ILibraryManager _libraryManager;
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IItemRepository _itemRepo; private readonly IItemRepository _itemRepo;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ArtistsPostScanTask" /> class. /// Initializes a new instance of the <see cref="GenresPostScanTask" /> class.
/// </summary> /// </summary>
/// <param name="libraryManager">The library manager.</param> /// <param name="libraryManager">The library manager.</param>
/// <param name="logger">The logger.</param> /// <param name="logger">The logger.</param>
/// <param name="itemRepo">The item repository.</param>
public GenresPostScanTask(ILibraryManager libraryManager, ILogger logger, IItemRepository itemRepo) public GenresPostScanTask(ILibraryManager libraryManager, ILogger logger, IItemRepository itemRepo)
{ {
_libraryManager = libraryManager; _libraryManager = libraryManager;

View file

@ -20,10 +20,11 @@ namespace Emby.Server.Implementations.Library.Validators
private readonly IItemRepository _itemRepo; private readonly IItemRepository _itemRepo;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ArtistsPostScanTask" /> class. /// Initializes a new instance of the <see cref="MusicGenresPostScanTask" /> class.
/// </summary> /// </summary>
/// <param name="libraryManager">The library manager.</param> /// <param name="libraryManager">The library manager.</param>
/// <param name="logger">The logger.</param> /// <param name="logger">The logger.</param>
/// <param name="itemRepo">The item repository.</param>
public MusicGenresPostScanTask(ILibraryManager libraryManager, ILogger logger, IItemRepository itemRepo) public MusicGenresPostScanTask(ILibraryManager libraryManager, ILogger logger, IItemRepository itemRepo)
{ {
_libraryManager = libraryManager; _libraryManager = libraryManager;

View file

@ -21,9 +21,11 @@ namespace Emby.Server.Implementations.Library.Validators
private readonly IItemRepository _itemRepo; private readonly IItemRepository _itemRepo;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ArtistsPostScanTask" /> class. /// Initializes a new instance of the <see cref="StudiosPostScanTask" /> class.
/// </summary> /// </summary>
/// <param name="libraryManager">The library manager.</param> /// <param name="libraryManager">The library manager.</param>
/// <param name="logger">The logger.</param>
/// <param name="itemRepo">Th item repository.</param>
public StudiosPostScanTask(ILibraryManager libraryManager, ILogger logger, IItemRepository itemRepo) public StudiosPostScanTask(ILibraryManager libraryManager, ILogger logger, IItemRepository itemRepo)
{ {
_libraryManager = libraryManager; _libraryManager = libraryManager;

View file

@ -237,7 +237,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
if (requiresRefresh) if (requiresRefresh)
{ {
await _libraryManager.ValidateMediaLibrary(new SimpleProgress<double>(), CancellationToken.None); await _libraryManager.ValidateMediaLibrary(new SimpleProgress<double>(), CancellationToken.None).ConfigureAwait(false);
} }
} }

View file

@ -501,7 +501,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
public async Task<List<NameIdPair>> GetHeadends(ListingsProviderInfo info, string country, string location, CancellationToken cancellationToken) public async Task<List<NameIdPair>> GetHeadends(ListingsProviderInfo info, string country, string location, CancellationToken cancellationToken)
{ {
var token = await GetToken(info, cancellationToken); var token = await GetToken(info, cancellationToken).ConfigureAwait(false);
var lineups = new List<NameIdPair>(); var lineups = new List<NameIdPair>();
@ -713,7 +713,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
private async Task AddLineupToAccount(ListingsProviderInfo info, CancellationToken cancellationToken) private async Task AddLineupToAccount(ListingsProviderInfo info, CancellationToken cancellationToken)
{ {
var token = await GetToken(info, cancellationToken); var token = await GetToken(info, cancellationToken).ConfigureAwait(false);
if (string.IsNullOrEmpty(token)) if (string.IsNullOrEmpty(token))
{ {
@ -738,7 +738,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
httpOptions.RequestHeaders["token"] = token; httpOptions.RequestHeaders["token"] = token;
using (await _httpClient.SendAsync(httpOptions, "PUT")) using (await _httpClient.SendAsync(httpOptions, "PUT").ConfigureAwait(false))
{ {
} }
} }
@ -750,7 +750,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
throw new ArgumentException("Listings Id required"); throw new ArgumentException("Listings Id required");
} }
var token = await GetToken(info, cancellationToken); var token = await GetToken(info, cancellationToken).ConfigureAwait(false);
if (string.IsNullOrEmpty(token)) if (string.IsNullOrEmpty(token))
{ {
@ -833,7 +833,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
throw new Exception("ListingsId required"); throw new Exception("ListingsId required");
} }
var token = await GetToken(info, cancellationToken); var token = await GetToken(info, cancellationToken).ConfigureAwait(false);
if (string.IsNullOrEmpty(token)) if (string.IsNullOrEmpty(token))
{ {

View file

@ -38,8 +38,8 @@ namespace Emby.Server.Implementations.LiveTv
/// <returns>IEnumerable{BaseTaskTrigger}.</returns> /// <returns>IEnumerable{BaseTaskTrigger}.</returns>
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers() public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
{ {
return new[] { return new[]
{
// Every so often // Every so often
new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(24).Ticks} new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(24).Ticks}
}; };

View file

@ -185,7 +185,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
Url = string.Format("{0}/tuners.html", GetApiUrl(info)), Url = string.Format("{0}/tuners.html", GetApiUrl(info)),
CancellationToken = cancellationToken, CancellationToken = cancellationToken,
BufferContent = false BufferContent = false
}, HttpMethod.Get)) }, HttpMethod.Get).ConfigureAwait(false))
using (var stream = response.Content) using (var stream = response.Content)
using (var sr = new StreamReader(stream, System.Text.Encoding.UTF8)) using (var sr = new StreamReader(stream, System.Text.Encoding.UTF8))
{ {
@ -259,7 +259,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
for (int i = 0; i < model.TunerCount; ++i) for (int i = 0; i < model.TunerCount; ++i)
{ {
var name = string.Format("Tuner {0}", i + 1); var name = string.Format("Tuner {0}", i + 1);
var currentChannel = "none"; /// @todo Get current channel and map back to Station Id var currentChannel = "none"; // @todo Get current channel and map back to Station Id
var isAvailable = await manager.CheckTunerAvailability(ipInfo, i, cancellationToken).ConfigureAwait(false); var isAvailable = await manager.CheckTunerAvailability(ipInfo, i, cancellationToken).ConfigureAwait(false);
var status = isAvailable ? LiveTvTunerStatus.Available : LiveTvTunerStatus.LiveTv; var status = isAvailable ? LiveTvTunerStatus.Available : LiveTvTunerStatus.LiveTv;
tuners.Add(new LiveTvTunerInfo tuners.Add(new LiveTvTunerInfo
@ -298,7 +298,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
public async Task<List<LiveTvTunerInfo>> GetTunerInfos(TunerHostInfo info, CancellationToken cancellationToken) public async Task<List<LiveTvTunerInfo>> GetTunerInfos(TunerHostInfo info, CancellationToken cancellationToken)
{ {
// TODO Need faster way to determine UDP vs HTTP // TODO Need faster way to determine UDP vs HTTP
var channels = await GetChannels(info, true, cancellationToken); var channels = await GetChannels(info, true, cancellationToken).ConfigureAwait(false);
var hdHomerunChannelInfo = channels.FirstOrDefault() as HdHomerunChannelInfo; var hdHomerunChannelInfo = channels.FirstOrDefault() as HdHomerunChannelInfo;

View file

@ -5,11 +5,9 @@ using System.Globalization;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Configuration;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Extensions;
using MediaBrowser.Model.Globalization; using MediaBrowser.Model.Globalization;
using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Serialization;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;

View file

@ -27,12 +27,12 @@ namespace Emby.Server.Implementations.Middleware
var webSocketContext = await httpContext.WebSockets.AcceptWebSocketAsync(null).ConfigureAwait(false); var webSocketContext = await httpContext.WebSockets.AcceptWebSocketAsync(null).ConfigureAwait(false);
if (webSocketContext != null) if (webSocketContext != null)
{ {
await _webSocketManager.OnWebSocketConnected(webSocketContext); await _webSocketManager.OnWebSocketConnected(webSocketContext).ConfigureAwait(false);
} }
} }
else else
{ {
await _next.Invoke(httpContext); await _next.Invoke(httpContext).ConfigureAwait(false);
} }
} }
} }

View file

@ -453,114 +453,6 @@ namespace Emby.Server.Implementations.Networking
.Select(x => x.GetPhysicalAddress()) .Select(x => x.GetPhysicalAddress())
.Where(x => x != null && x != PhysicalAddress.None); .Where(x => x != null && x != PhysicalAddress.None);
/// <summary>
/// Parses the specified endpointstring.
/// </summary>
/// <param name="endpointstring">The endpointstring.</param>
/// <returns>IPEndPoint.</returns>
public IPEndPoint Parse(string endpointstring)
{
return Parse(endpointstring, -1).Result;
}
/// <summary>
/// Parses the specified endpointstring.
/// </summary>
/// <param name="endpointstring">The endpointstring.</param>
/// <param name="defaultport">The defaultport.</param>
/// <returns>IPEndPoint.</returns>
/// <exception cref="ArgumentException">Endpoint descriptor may not be empty.</exception>
/// <exception cref="FormatException"></exception>
private static async Task<IPEndPoint> Parse(string endpointstring, int defaultport)
{
if (string.IsNullOrEmpty(endpointstring)
|| endpointstring.Trim().Length == 0)
{
throw new ArgumentException("Endpoint descriptor may not be empty.");
}
if (defaultport != -1 &&
(defaultport < IPEndPoint.MinPort
|| defaultport > IPEndPoint.MaxPort))
{
throw new ArgumentException(string.Format("Invalid default port '{0}'", defaultport));
}
string[] values = endpointstring.Split(new char[] { ':' });
IPAddress ipaddy;
int port = -1;
//check if we have an IPv6 or ports
if (values.Length <= 2) // ipv4 or hostname
{
port = values.Length == 1 ? defaultport : GetPort(values[1]);
//try to use the address as IPv4, otherwise get hostname
if (!IPAddress.TryParse(values[0], out ipaddy))
ipaddy = await GetIPfromHost(values[0]).ConfigureAwait(false);
}
else if (values.Length > 2) //ipv6
{
//could [a:b:c]:d
if (values[0].StartsWith("[") && values[values.Length - 2].EndsWith("]"))
{
string ipaddressstring = string.Join(":", values.Take(values.Length - 1).ToArray());
ipaddy = IPAddress.Parse(ipaddressstring);
port = GetPort(values[values.Length - 1]);
}
else //[a:b:c] or a:b:c
{
ipaddy = IPAddress.Parse(endpointstring);
port = defaultport;
}
}
else
{
throw new FormatException(string.Format("Invalid endpoint ipaddress '{0}'", endpointstring));
}
if (port == -1)
throw new ArgumentException(string.Format("No port specified: '{0}'", endpointstring));
return new IPEndPoint(ipaddy, port);
}
protected static readonly CultureInfo UsCulture = new CultureInfo("en-US");
/// <summary>
/// Gets the port.
/// </summary>
/// <param name="p">The p.</param>
/// <returns>System.Int32.</returns>
/// <exception cref="FormatException"></exception>
private static int GetPort(string p)
{
if (!int.TryParse(p, out var port)
|| port < IPEndPoint.MinPort
|| port > IPEndPoint.MaxPort)
{
throw new FormatException(string.Format("Invalid end point port '{0}'", p));
}
return port;
}
/// <summary>
/// Gets the I pfrom host.
/// </summary>
/// <param name="p">The p.</param>
/// <returns>IPAddress.</returns>
/// <exception cref="ArgumentException"></exception>
private static async Task<IPAddress> GetIPfromHost(string p)
{
var hosts = await Dns.GetHostAddressesAsync(p).ConfigureAwait(false);
if (hosts == null || hosts.Length == 0)
throw new ArgumentException(string.Format("Host not found: {0}", p));
return hosts[0];
}
public bool IsInSameSubnet(IPAddress address1, IPAddress address2, IPAddress subnetMask) public bool IsInSameSubnet(IPAddress address1, IPAddress address2, IPAddress subnetMask)
{ {
IPAddress network1 = GetNetworkAddress(address1, subnetMask); IPAddress network1 = GetNetworkAddress(address1, subnetMask);

View file

@ -48,4 +48,3 @@ namespace Emby.Server.Implementations.Playlists
} }
} }
} }

View file

@ -23,7 +23,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
public event EventHandler<GenericEventArgs<double>> TaskProgress; public event EventHandler<GenericEventArgs<double>> TaskProgress;
/// <summary> /// <summary>
/// Gets or sets the scheduled task. /// Gets the scheduled task.
/// </summary> /// </summary>
/// <value>The scheduled task.</value> /// <value>The scheduled task.</value>
public IScheduledTask ScheduledTask { get; private set; } public IScheduledTask ScheduledTask { get; private set; }
@ -215,11 +215,12 @@ namespace Emby.Server.Implementations.ScheduledTasks
public double? CurrentProgress { get; private set; } public double? CurrentProgress { get; private set; }
/// <summary> /// <summary>
/// The _triggers /// The _triggers.
/// </summary> /// </summary>
private Tuple<TaskTriggerInfo, ITaskTrigger>[] _triggers; private Tuple<TaskTriggerInfo, ITaskTrigger>[] _triggers;
/// <summary> /// <summary>
/// Gets the triggers that define when the task will run /// Gets the triggers that define when the task will run.
/// </summary> /// </summary>
/// <value>The triggers.</value> /// <value>The triggers.</value>
private Tuple<TaskTriggerInfo, ITaskTrigger>[] InternalTriggers private Tuple<TaskTriggerInfo, ITaskTrigger>[] InternalTriggers
@ -245,7 +246,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
} }
/// <summary> /// <summary>
/// Gets the triggers that define when the task will run /// Gets the triggers that define when the task will run.
/// </summary> /// </summary>
/// <value>The triggers.</value> /// <value>The triggers.</value>
/// <exception cref="ArgumentNullException">value</exception> /// <exception cref="ArgumentNullException">value</exception>

View file

@ -36,19 +36,19 @@ namespace Emby.Server.Implementations.ScheduledTasks
/// Gets or sets the json serializer. /// Gets or sets the json serializer.
/// </summary> /// </summary>
/// <value>The json serializer.</value> /// <value>The json serializer.</value>
private IJsonSerializer JsonSerializer { get; set; } private readonly IJsonSerializer _jsonSerializer;
/// <summary> /// <summary>
/// Gets or sets the application paths. /// Gets or sets the application paths.
/// </summary> /// </summary>
/// <value>The application paths.</value> /// <value>The application paths.</value>
private IApplicationPaths ApplicationPaths { get; set; } private readonly IApplicationPaths _applicationPaths;
/// <summary> /// <summary>
/// Gets the logger. /// Gets the logger.
/// </summary> /// </summary>
/// <value>The logger.</value> /// <value>The logger.</value>
private ILogger Logger { get; set; } private readonly ILogger _logger;
private readonly IFileSystem _fileSystem; private readonly IFileSystem _fileSystem;
/// <summary> /// <summary>
@ -57,19 +57,19 @@ namespace Emby.Server.Implementations.ScheduledTasks
/// <param name="applicationPaths">The application paths.</param> /// <param name="applicationPaths">The application paths.</param>
/// <param name="jsonSerializer">The json serializer.</param> /// <param name="jsonSerializer">The json serializer.</param>
/// <param name="loggerFactory">The logger factory.</param> /// <param name="loggerFactory">The logger factory.</param>
/// <exception cref="System.ArgumentException">kernel</exception> /// <param name="fileSystem">The filesystem manager.</param>
public TaskManager( public TaskManager(
IApplicationPaths applicationPaths, IApplicationPaths applicationPaths,
IJsonSerializer jsonSerializer, IJsonSerializer jsonSerializer,
ILoggerFactory loggerFactory, ILoggerFactory loggerFactory,
IFileSystem fileSystem) IFileSystem fileSystem)
{ {
ApplicationPaths = applicationPaths; _applicationPaths = applicationPaths;
JsonSerializer = jsonSerializer; _jsonSerializer = jsonSerializer;
Logger = loggerFactory.CreateLogger(nameof(TaskManager)); _logger = loggerFactory.CreateLogger(nameof(TaskManager));
_fileSystem = fileSystem; _fileSystem = fileSystem;
ScheduledTasks = new IScheduledTaskWorker[] { }; ScheduledTasks = Array.Empty<IScheduledTaskWorker>();
} }
/// <summary> /// <summary>
@ -78,7 +78,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
/// <typeparam name="T"></typeparam> /// <typeparam name="T"></typeparam>
/// <param name="options">Task options.</param> /// <param name="options">Task options.</param>
public void CancelIfRunningAndQueue<T>(TaskOptions options) public void CancelIfRunningAndQueue<T>(TaskOptions options)
where T : IScheduledTask where T : IScheduledTask
{ {
var task = ScheduledTasks.First(t => t.ScheduledTask.GetType() == typeof(T)); var task = ScheduledTasks.First(t => t.ScheduledTask.GetType() == typeof(T));
((ScheduledTaskWorker)task).CancelIfRunning(); ((ScheduledTaskWorker)task).CancelIfRunning();
@ -115,7 +115,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
if (scheduledTask == null) if (scheduledTask == null)
{ {
Logger.LogError("Unable to find scheduled task of type {0} in QueueScheduledTask.", typeof(T).Name); _logger.LogError("Unable to find scheduled task of type {0} in QueueScheduledTask.", typeof(T).Name);
} }
else else
{ {
@ -147,13 +147,13 @@ namespace Emby.Server.Implementations.ScheduledTasks
if (scheduledTask == null) if (scheduledTask == null)
{ {
Logger.LogError("Unable to find scheduled task of type {0} in Execute.", typeof(T).Name); _logger.LogError("Unable to find scheduled task of type {0} in Execute.", typeof(T).Name);
} }
else else
{ {
var type = scheduledTask.ScheduledTask.GetType(); var type = scheduledTask.ScheduledTask.GetType();
Logger.LogInformation("Queueing task {0}", type.Name); _logger.LogInformation("Queueing task {0}", type.Name);
lock (_taskQueue) lock (_taskQueue)
{ {
@ -176,7 +176,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
if (scheduledTask == null) if (scheduledTask == null)
{ {
Logger.LogError("Unable to find scheduled task of type {0} in QueueScheduledTask.", task.GetType().Name); _logger.LogError("Unable to find scheduled task of type {0} in QueueScheduledTask.", task.GetType().Name);
} }
else else
{ {
@ -193,7 +193,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
{ {
var type = task.ScheduledTask.GetType(); var type = task.ScheduledTask.GetType();
Logger.LogInformation("Queueing task {0}", type.Name); _logger.LogInformation("Queueing task {0}", type.Name);
lock (_taskQueue) lock (_taskQueue)
{ {
@ -213,7 +213,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
/// <param name="tasks">The tasks.</param> /// <param name="tasks">The tasks.</param>
public void AddTasks(IEnumerable<IScheduledTask> tasks) public void AddTasks(IEnumerable<IScheduledTask> tasks)
{ {
var list = tasks.Select(t => new ScheduledTaskWorker(t, ApplicationPaths, this, JsonSerializer, Logger, _fileSystem)); var list = tasks.Select(t => new ScheduledTaskWorker(t, _applicationPaths, this, _jsonSerializer, _logger, _fileSystem));
ScheduledTasks = ScheduledTasks.Concat(list).ToArray(); ScheduledTasks = ScheduledTasks.Concat(list).ToArray();
} }
@ -281,7 +281,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
/// </summary> /// </summary>
private void ExecuteQueuedTasks() private void ExecuteQueuedTasks()
{ {
Logger.LogInformation("ExecuteQueuedTasks"); _logger.LogInformation("ExecuteQueuedTasks");
// Execute queued tasks // Execute queued tasks
lock (_taskQueue) lock (_taskQueue)

View file

@ -1,5 +1,4 @@
using System; using System;
using System.Globalization;
using System.Threading; using System.Threading;
using MediaBrowser.Model.Tasks; using MediaBrowser.Model.Tasks;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
@ -7,12 +6,12 @@ using Microsoft.Extensions.Logging;
namespace Emby.Server.Implementations.ScheduledTasks namespace Emby.Server.Implementations.ScheduledTasks
{ {
/// <summary> /// <summary>
/// Represents a task trigger that fires everyday /// Represents a task trigger that fires everyday.
/// </summary> /// </summary>
public class DailyTrigger : ITaskTrigger public class DailyTrigger : ITaskTrigger
{ {
/// <summary> /// <summary>
/// Get the time of day to trigger the task to run /// Get the time of day to trigger the task to run.
/// </summary> /// </summary>
/// <value>The time of day.</value> /// <value>The time of day.</value>
public TimeSpan TimeOfDay { get; set; } public TimeSpan TimeOfDay { get; set; }

View file

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
@ -45,8 +46,8 @@ namespace Emby.Server.Implementations.Services
public int PathComponentsCount { get; set; } public int PathComponentsCount { get; set; }
/// <summary> /// <summary>
/// The total number of segments after subparts have been exploded ('.') /// Gets or sets the total number of segments after subparts have been exploded ('.')
/// e.g. /path/to/here.ext == 4 /// e.g. /path/to/here.ext == 4.
/// </summary> /// </summary>
public int TotalComponentsCount { get; set; } public int TotalComponentsCount { get; set; }
@ -279,7 +280,7 @@ namespace Emby.Server.Implementations.Services
} }
/// <summary> /// <summary>
/// Provide for quick lookups based on hashes that can be determined from a request url /// Provide for quick lookups based on hashes that can be determined from a request url.
/// </summary> /// </summary>
public string FirstMatchHashKey { get; private set; } public string FirstMatchHashKey { get; private set; }
@ -436,9 +437,12 @@ namespace Emby.Server.Implementations.Services
&& requestComponents.Length >= this.TotalComponentsCount - this.wildcardCount; && requestComponents.Length >= this.TotalComponentsCount - this.wildcardCount;
if (!isValidWildCardPath) if (!isValidWildCardPath)
throw new ArgumentException(string.Format( throw new ArgumentException(
"Path Mismatch: Request Path '{0}' has invalid number of components compared to: '{1}'", string.Format(
pathInfo, this.restPath)); CultureInfo.InvariantCulture,
"Path Mismatch: Request Path '{0}' has invalid number of components compared to: '{1}'",
pathInfo,
this.restPath));
} }
var requestKeyValuesMap = new Dictionary<string, string>(); var requestKeyValuesMap = new Dictionary<string, string>();

View file

@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Net;
@ -175,7 +175,7 @@ namespace Emby.Server.Implementations.Services
private SwaggerTag[] GetTags() private SwaggerTag[] GetTags()
{ {
return new SwaggerTag[] { }; return Array.Empty<SwaggerTag>();
} }
private Dictionary<string, SwaggerDefinition> GetDefinitions() private Dictionary<string, SwaggerDefinition> GetDefinitions()

View file

@ -105,7 +105,7 @@ namespace Emby.Server.Implementations.Session
return SendMessage(command.Command.ToString(), messageId, args, cancellationToken); return SendMessage(command.Command.ToString(), messageId, args, cancellationToken);
} }
private string[] _supportedMessages = new string[] { }; private string[] _supportedMessages = Array.Empty<string>();
public Task SendMessage<T>(string name, string messageId, T data, ISessionController[] allControllers, CancellationToken cancellationToken) public Task SendMessage<T>(string name, string messageId, T data, ISessionController[] allControllers, CancellationToken cancellationToken)
{ {
if (!IsSessionActive) if (!IsSessionActive)

View file

@ -33,7 +33,7 @@ namespace Emby.Server.Implementations.SocketSharp
} }
/// <summary> /// <summary>
/// Gets or sets the state. /// Gets the state.
/// </summary> /// </summary>
/// <value>The state.</value> /// <value>The state.</value>
public WebSocketState State => _webSocket.State; public WebSocketState State => _webSocket.State;

View file

@ -81,8 +81,10 @@ namespace Emby.Server.Implementations.SocketSharp
if (webSocketContext.State == WebSocketState.Open) if (webSocketContext.State == WebSocketState.Open)
{ {
await webSocketContext.CloseAsync(result.CloseStatus ?? WebSocketCloseStatus.NormalClosure, await webSocketContext.CloseAsync(
result.CloseStatusDescription, _disposeCancellationToken); result.CloseStatus ?? WebSocketCloseStatus.NormalClosure,
result.CloseStatusDescription,
_disposeCancellationToken).ConfigureAwait(false);
} }
socket.Dispose(); socket.Dispose();

View file

@ -2,7 +2,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Net; using System.Net;
using System.Linq;
using MediaBrowser.Common.Net; using MediaBrowser.Common.Net;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Extensions; using Microsoft.AspNetCore.Http.Extensions;
@ -13,7 +12,7 @@ using IHttpRequest = MediaBrowser.Model.Services.IHttpRequest;
namespace Emby.Server.Implementations.SocketSharp namespace Emby.Server.Implementations.SocketSharp
{ {
public partial class WebSocketSharpRequest : IHttpRequest public class WebSocketSharpRequest : IHttpRequest
{ {
public const string FormUrlEncoded = "application/x-www-form-urlencoded"; public const string FormUrlEncoded = "application/x-www-form-urlencoded";
public const string MultiPartFormData = "multipart/form-data"; public const string MultiPartFormData = "multipart/form-data";

View file

@ -19,10 +19,14 @@ namespace Emby.Server.Implementations.Sorting
public int Compare(BaseItem x, BaseItem y) public int Compare(BaseItem x, BaseItem y)
{ {
if (x == null) if (x == null)
{
throw new ArgumentNullException(nameof(x)); throw new ArgumentNullException(nameof(x));
}
if (y == null) if (y == null)
{
throw new ArgumentNullException(nameof(y)); throw new ArgumentNullException(nameof(y));
}
return string.Compare(x.Name, y.Name, StringComparison.CurrentCultureIgnoreCase); return string.Compare(x.Name, y.Name, StringComparison.CurrentCultureIgnoreCase);
} }

View file

@ -24,10 +24,14 @@ namespace Emby.Server.Implementations.Sorting
public int Compare(BaseItem x, BaseItem y) public int Compare(BaseItem x, BaseItem y)
{ {
if (x == null) if (x == null)
{
throw new ArgumentNullException(nameof(x)); throw new ArgumentNullException(nameof(x));
}
if (y == null) if (y == null)
{
throw new ArgumentNullException(nameof(y)); throw new ArgumentNullException(nameof(y));
}
var levelX = string.IsNullOrEmpty(x.OfficialRating) ? 0 : _localization.GetRatingLevel(x.OfficialRating) ?? 0; var levelX = string.IsNullOrEmpty(x.OfficialRating) ? 0 : _localization.GetRatingLevel(x.OfficialRating) ?? 0;
var levelY = string.IsNullOrEmpty(y.OfficialRating) ? 0 : _localization.GetRatingLevel(y.OfficialRating) ?? 0; var levelY = string.IsNullOrEmpty(y.OfficialRating) ? 0 : _localization.GetRatingLevel(y.OfficialRating) ?? 0;

View file

@ -17,10 +17,15 @@ namespace Emby.Server.Implementations.Sorting
public int Compare(BaseItem x, BaseItem y) public int Compare(BaseItem x, BaseItem y)
{ {
if (x == null) if (x == null)
{
throw new ArgumentNullException(nameof(x)); throw new ArgumentNullException(nameof(x));
}
if (y == null) if (y == null)
{
throw new ArgumentNullException(nameof(y)); throw new ArgumentNullException(nameof(y));
}
return AlphanumComparator.CompareValues(x.Studios.FirstOrDefault() ?? string.Empty, y.Studios.FirstOrDefault() ?? string.Empty); return AlphanumComparator.CompareValues(x.Studios.FirstOrDefault() ?? string.Empty, y.Studios.FirstOrDefault() ?? string.Empty);
} }

View file

@ -39,12 +39,12 @@ namespace Emby.Server.Implementations.WebSockets
do do
{ {
var buffer = WebSocket.CreateServerBuffer(BufferSize); var buffer = WebSocket.CreateServerBuffer(BufferSize);
result = await webSocket.ReceiveAsync(buffer, cancellationToken); result = await webSocket.ReceiveAsync(buffer, cancellationToken).ConfigureAwait(false);
message.AddRange(buffer.Array.Take(result.Count)); message.AddRange(buffer.Array.Take(result.Count));
if (result.EndOfMessage) if (result.EndOfMessage)
{ {
await ProcessMessage(message.ToArray(), taskCompletionSource); await ProcessMessage(message.ToArray(), taskCompletionSource).ConfigureAwait(false);
message.Clear(); message.Clear();
} }
} while (!taskCompletionSource.Task.IsCompleted && } while (!taskCompletionSource.Task.IsCompleted &&
@ -53,8 +53,10 @@ namespace Emby.Server.Implementations.WebSockets
if (webSocket.State == WebSocketState.Open) if (webSocket.State == WebSocketState.Open)
{ {
await webSocket.CloseAsync(result.CloseStatus ?? WebSocketCloseStatus.NormalClosure, await webSocket.CloseAsync(
result.CloseStatusDescription, cancellationToken); result.CloseStatus ?? WebSocketCloseStatus.NormalClosure,
result.CloseStatusDescription,
cancellationToken).ConfigureAwait(false);
} }
} }

View file

@ -588,7 +588,7 @@ namespace MediaBrowser.Api.Playback
/// <summary> /// <summary>
/// Parses query parameters as StreamOptions /// Parses query parameters as StreamOptions
/// <summary> /// </summary>
/// <param name="request">The stream request.</param> /// <param name="request">The stream request.</param>
private void ParseStreamOptions(StreamRequest request) private void ParseStreamOptions(StreamRequest request)
{ {