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

Enable TreatWarningsAsErrors for Jellyfin.Server.Implementations in Release mode #3203

Merged
merged 1 commit into from Jun 3, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions Emby.Server.Implementations/Channels/ChannelManager.cs
Expand Up @@ -46,14 +46,14 @@ public class ChannelManager : IChannelManager
new ConcurrentDictionary<string, Tuple<DateTime, List<MediaSourceInfo>>>();

private readonly SemaphoreSlim _resourcePool = new SemaphoreSlim(1, 1);

/// <summary>
/// Initializes a new instance of the <see cref="ChannelManager"/> class.
/// </summary>
/// <param name="userManager">The user manager.</param>
/// <param name="dtoService">The dto service.</param>
/// <param name="libraryManager">The library manager.</param>
/// <param name="loggerFactory">The logger factory.</param>
/// <param name="logger">The logger.</param>
/// <param name="config">The server configuration manager.</param>
/// <param name="fileSystem">The filesystem.</param>
/// <param name="userDataManager">The user data manager.</param>
Expand Down
5 changes: 4 additions & 1 deletion Emby.Server.Implementations/Data/SqliteItemRepository.cs
@@ -1,3 +1,5 @@
#pragma warning disable CS1591

using System;
using System.Collections.Generic;
using System.Globalization;
Expand Down Expand Up @@ -33,7 +35,7 @@
namespace Emby.Server.Implementations.Data
{
/// <summary>
/// Class SQLiteItemRepository
/// Class SQLiteItemRepository.
/// </summary>
public class SqliteItemRepository : BaseSqliteRepository, IItemRepository
{
Expand Down Expand Up @@ -1971,6 +1973,7 @@ public ChapterInfo GetChapter(BaseItem item, int index)
/// Gets the chapter.
/// </summary>
/// <param name="reader">The reader.</param>
/// <param name="item">The item.</param>
/// <returns>ChapterInfo.</returns>
private ChapterInfo GetChapter(IReadOnlyList<IResultSetValue> reader, BaseItem item)
{
Expand Down
Expand Up @@ -54,6 +54,7 @@
<TargetFramework>netstandard2.1</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<TreatWarningsAsErrors Condition=" '$(Configuration)' == 'Release'" >true</TreatWarningsAsErrors>
</PropertyGroup>

<!-- Code Analyzers-->
Expand Down
Expand Up @@ -47,10 +47,11 @@ public sealed class UdpServerEntryPoint : IServerEntryPoint
}

/// <inheritdoc />
public async Task RunAsync()
public Task RunAsync()
{
_udpServer = new UdpServer(_logger, _appHost, _config);
_udpServer.Start(PortNumber, _cancellationTokenSource.Token);
return Task.CompletedTask;
}

/// <inheritdoc />
Expand Down
Expand Up @@ -56,6 +56,7 @@ public HttpResultFactory(ILoggerFactory loggerfactory, IFileSystem fileSystem, I
/// <summary>
/// Gets the result.
/// </summary>
/// <param name="requestContext">The request context.</param>
/// <param name="content">The content.</param>
/// <param name="contentType">Type of the content.</param>
/// <param name="responseHeaders">The response headers.</param>
Expand Down
2 changes: 2 additions & 0 deletions Emby.Server.Implementations/IStartupOptions.cs
@@ -1,3 +1,5 @@
#pragma warning disable CS1591

using System;

namespace Emby.Server.Implementations
Expand Down
Expand Up @@ -135,43 +135,5 @@ public string GetEasyPasswordHash(User user)
? null
: Hex.Encode(PasswordHash.Parse(user.EasyPassword).Hash);
}

/// <summary>
/// Gets the hashed string.
/// </summary>
public string GetHashedString(User user, string str)
{
if (string.IsNullOrEmpty(user.Password))
{
return _cryptographyProvider.CreatePasswordHash(str).ToString();
}

// TODO: make use of iterations parameter?
PasswordHash passwordHash = PasswordHash.Parse(user.Password);
var salt = passwordHash.Salt.ToArray();
return new PasswordHash(
passwordHash.Id,
_cryptographyProvider.ComputeHash(
passwordHash.Id,
Encoding.UTF8.GetBytes(str),
salt),
salt,
passwordHash.Parameters.ToDictionary(x => x.Key, y => y.Value)).ToString();
}

public ReadOnlySpan<byte> GetHashed(User user, string str)
{
if (string.IsNullOrEmpty(user.Password))
{
return _cryptographyProvider.CreatePasswordHash(str).Hash;
}

// TODO: make use of iterations parameter?
PasswordHash passwordHash = PasswordHash.Parse(user.Password);
return _cryptographyProvider.ComputeHash(
passwordHash.Id,
Encoding.UTF8.GetBytes(str),
passwordHash.Salt.ToArray());
}
}
}
8 changes: 7 additions & 1 deletion Emby.Server.Implementations/Library/LibraryManager.cs
Expand Up @@ -50,7 +50,7 @@
namespace Emby.Server.Implementations.Library
{
/// <summary>
/// Class LibraryManager
/// Class LibraryManager.
/// </summary>
public class LibraryManager : ILibraryManager
{
Expand Down Expand Up @@ -135,6 +135,12 @@ public class LibraryManager : ILibraryManager
/// <param name="userManager">The user manager.</param>
/// <param name="configurationManager">The configuration manager.</param>
/// <param name="userDataRepository">The user data repository.</param>
/// <param name="libraryMonitorFactory">The library monitor.</param>
/// <param name="fileSystem">The file system.</param>
/// <param name="providerManagerFactory">The provider manager.</param>
/// <param name="userviewManagerFactory">The userview manager.</param>
/// <param name="mediaEncoder">The media encoder.</param>
/// <param name="itemRepository">The item repository.</param>
public LibraryManager(
IServerApplicationHost appHost,
ILogger<LibraryManager> logger,
Expand Down
2 changes: 0 additions & 2 deletions Emby.Server.Implementations/LiveTv/LiveTvManager.cs
Expand Up @@ -10,10 +10,8 @@
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Progress;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Channels;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Movies;
Expand Down
@@ -1,3 +1,5 @@
#pragma warning disable CS1591

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
Expand Down
2 changes: 2 additions & 0 deletions Emby.Server.Implementations/MediaEncoder/EncodingManager.cs
@@ -1,3 +1,5 @@
#pragma warning disable CS1591

using System;
using System.Collections.Generic;
using System.Globalization;
Expand Down
2 changes: 2 additions & 0 deletions Emby.Server.Implementations/Net/SocketFactory.cs
@@ -1,3 +1,5 @@
#pragma warning disable CS1591

using System;
using System.Net;
using System.Net.Sockets;
Expand Down
2 changes: 2 additions & 0 deletions Emby.Server.Implementations/Net/UdpSocket.cs
@@ -1,3 +1,5 @@
#pragma warning disable CS1591

using System;
using System.Net;
using System.Net.Sockets;
Expand Down
2 changes: 2 additions & 0 deletions Emby.Server.Implementations/Networking/NetworkManager.cs
@@ -1,3 +1,5 @@
#pragma warning disable CS1591

using System;
using System.Collections.Generic;
using System.Globalization;
Expand Down
@@ -1,3 +1,5 @@
#pragma warning disable CS1591

using System.Collections.Generic;
using System.Linq;
using System.Text.Json.Serialization;
Expand Down
@@ -1,3 +1,5 @@
#pragma warning disable CS1591

using System.Collections.Generic;
using System.Linq;
using Emby.Server.Implementations.Images;
Expand Down Expand Up @@ -32,9 +34,7 @@ protected override IReadOnlyList<BaseItem> GetItemsWithImages(BaseItem item)
{
var subItem = i.Item2;

var episode = subItem as Episode;

if (episode != null)
if (subItem is Episode episode)
{
var series = episode.Series;
if (series != null && series.HasImage(ImageType.Primary))
Expand Down
2 changes: 2 additions & 0 deletions Emby.Server.Implementations/Playlists/PlaylistManager.cs
@@ -1,3 +1,5 @@
#pragma warning disable CS1591

using System;
using System.Collections.Generic;
using System.Globalization;
Expand Down
2 changes: 2 additions & 0 deletions Emby.Server.Implementations/ResourceFileManager.cs
@@ -1,3 +1,5 @@
#pragma warning disable CS1591

using System;
using System.IO;
using MediaBrowser.Controller;
Expand Down
@@ -1,3 +1,5 @@
#pragma warning disable CS1591

using System;
using System.Globalization;
using System.IO;
Expand Down Expand Up @@ -51,7 +53,6 @@ public class ScheduledTaskWorker : IScheduledTaskWorker
/// </summary>
/// <value>The task manager.</value>
private ITaskManager TaskManager { get; set; }
private readonly IFileSystem _fileSystem;

/// <summary>
/// Initializes a new instance of the <see cref="ScheduledTaskWorker" /> class.
Expand All @@ -72,24 +73,28 @@ public class ScheduledTaskWorker : IScheduledTaskWorker
/// or
/// logger
/// </exception>
public ScheduledTaskWorker(IScheduledTask scheduledTask, IApplicationPaths applicationPaths, ITaskManager taskManager, IJsonSerializer jsonSerializer, ILogger logger, IFileSystem fileSystem)
public ScheduledTaskWorker(IScheduledTask scheduledTask, IApplicationPaths applicationPaths, ITaskManager taskManager, IJsonSerializer jsonSerializer, ILogger logger)
{
if (scheduledTask == null)
{
throw new ArgumentNullException(nameof(scheduledTask));
}

if (applicationPaths == null)
{
throw new ArgumentNullException(nameof(applicationPaths));
}

if (taskManager == null)
{
throw new ArgumentNullException(nameof(taskManager));
}

if (jsonSerializer == null)
{
throw new ArgumentNullException(nameof(jsonSerializer));
}

if (logger == null)
{
throw new ArgumentNullException(nameof(logger));
Expand All @@ -100,7 +105,6 @@ public ScheduledTaskWorker(IScheduledTask scheduledTask, IApplicationPaths appli
TaskManager = taskManager;
JsonSerializer = jsonSerializer;
Logger = logger;
_fileSystem = fileSystem;

InitTriggerEvents();
}
Expand Down Expand Up @@ -576,6 +580,7 @@ private void SaveTriggers(TaskTriggerInfo[] triggers)
/// <param name="startTime">The start time.</param>
/// <param name="endTime">The end time.</param>
/// <param name="status">The status.</param>
/// <param name="ex">The exception.</param>
private void OnTaskCompleted(DateTime startTime, DateTime endTime, TaskCompletionStatus status, Exception ex)
{
var elapsedTime = endTime - startTime;
Expand Down
4 changes: 3 additions & 1 deletion Emby.Server.Implementations/ScheduledTasks/TaskManager.cs
@@ -1,3 +1,5 @@
#pragma warning disable CS1591

using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
Expand Down Expand Up @@ -199,7 +201,7 @@ private void QueueScheduledTask(IScheduledTaskWorker task, TaskOptions options)
/// <param name="tasks">The tasks.</param>
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));

ScheduledTasks = ScheduledTasks.Concat(list).ToArray();
}
Expand Down
Expand Up @@ -169,18 +169,25 @@ public async Task Execute(CancellationToken cancellationToken, IProgress<double>
}
}

/// <inheritdoc />
public string Name => _localization.GetLocalizedString("TaskRefreshChapterImages");

/// <inheritdoc />
public string Description => _localization.GetLocalizedString("TaskRefreshChapterImagesDescription");

/// <inheritdoc />
public string Category => _localization.GetLocalizedString("TasksLibraryCategory");

/// <inheritdoc />
public string Key => "RefreshChapterImages";

/// <inheritdoc />
public bool IsHidden => false;

/// <inheritdoc />
public bool IsEnabled => true;

/// <inheritdoc />
public bool IsLogged => true;
}
}
Expand Up @@ -165,18 +165,25 @@ private void DeleteFile(string path)
}
}

/// <inheritdoc />
public string Name => _localization.GetLocalizedString("TaskCleanCache");

/// <inheritdoc />
public string Description => _localization.GetLocalizedString("TaskCleanCacheDescription");

/// <inheritdoc />
public string Category => _localization.GetLocalizedString("TasksMaintenanceCategory");

/// <inheritdoc />
public string Key => "DeleteCacheFiles";

/// <inheritdoc />
public bool IsHidden => false;

/// <inheritdoc />
public bool IsEnabled => true;

/// <inheritdoc />
public bool IsLogged => true;
}
}
Expand Up @@ -28,6 +28,8 @@ public class DeleteLogFileTask : IScheduledTask, IConfigurableScheduledTask
/// Initializes a new instance of the <see cref="DeleteLogFileTask" /> class.
/// </summary>
/// <param name="configurationManager">The configuration manager.</param>
/// <param name="fileSystem">The file system.</param>
/// <param name="localization">The localization manager.</param>
public DeleteLogFileTask(IConfigurationManager configurationManager, IFileSystem fileSystem, ILocalizationManager localization)
{
ConfigurationManager = configurationManager;
Expand Down Expand Up @@ -82,18 +84,25 @@ public Task Execute(CancellationToken cancellationToken, IProgress<double> progr
return Task.CompletedTask;
}

/// <inheritdoc />
public string Name => _localization.GetLocalizedString("TaskCleanLogs");

/// <inheritdoc />
public string Description => string.Format(_localization.GetLocalizedString("TaskCleanLogsDescription"), ConfigurationManager.CommonConfiguration.LogFileRetentionDays);

/// <inheritdoc />
public string Category => _localization.GetLocalizedString("TasksMaintenanceCategory");

/// <inheritdoc />
public string Key => "CleanLogFiles";

/// <inheritdoc />
public bool IsHidden => false;

/// <inheritdoc />
public bool IsEnabled => true;

/// <inheritdoc />
public bool IsLogged => true;
}
}