Merge pull request #9322 from Bond-009/nullable

This commit is contained in:
Bond-009 2023-02-19 15:08:35 +01:00 committed by GitHub
commit bb6f867067
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 24 additions and 41 deletions

View File

@ -1,5 +1,3 @@
#nullable disable
#pragma warning disable CS1591 #pragma warning disable CS1591
using System; using System;
@ -43,9 +41,9 @@ namespace Emby.Server.Implementations.ScheduledTasks
ScheduledTasks = Array.Empty<IScheduledTaskWorker>(); ScheduledTasks = Array.Empty<IScheduledTaskWorker>();
} }
public event EventHandler<GenericEventArgs<IScheduledTaskWorker>> TaskExecuting; public event EventHandler<GenericEventArgs<IScheduledTaskWorker>>? TaskExecuting;
public event EventHandler<TaskCompletionEventArgs> TaskCompleted; public event EventHandler<TaskCompletionEventArgs>? TaskCompleted;
/// <summary> /// <summary>
/// Gets the list of Scheduled Tasks. /// Gets the list of Scheduled Tasks.

View File

@ -1,5 +1,3 @@
#nullable disable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -58,7 +56,7 @@ namespace Emby.Server.Implementations.Session
/// <summary> /// <summary>
/// The KeepAlive cancellation token. /// The KeepAlive cancellation token.
/// </summary> /// </summary>
private CancellationTokenSource _keepAliveCancellationToken; private CancellationTokenSource? _keepAliveCancellationToken;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="SessionWebSocketListener" /> class. /// Initializes a new instance of the <see cref="SessionWebSocketListener" /> class.
@ -105,7 +103,7 @@ namespace Emby.Server.Implementations.Session
} }
} }
private async Task<SessionInfo> GetSession(HttpContext httpContext, string remoteEndpoint) private async Task<SessionInfo?> GetSession(HttpContext httpContext, string? remoteEndpoint)
{ {
if (!httpContext.User.Identity?.IsAuthenticated ?? false) if (!httpContext.User.Identity?.IsAuthenticated ?? false)
{ {
@ -138,8 +136,13 @@ namespace Emby.Server.Implementations.Session
/// </summary> /// </summary>
/// <param name="sender">The WebSocket.</param> /// <param name="sender">The WebSocket.</param>
/// <param name="e">The event arguments.</param> /// <param name="e">The event arguments.</param>
private void OnWebSocketClosed(object sender, EventArgs e) private void OnWebSocketClosed(object? sender, EventArgs e)
{ {
if (sender is null)
{
return;
}
var webSocket = (IWebSocketConnection)sender; var webSocket = (IWebSocketConnection)sender;
_logger.LogDebug("WebSocket {0} is closed.", webSocket); _logger.LogDebug("WebSocket {0} is closed.", webSocket);
RemoveWebSocket(webSocket); RemoveWebSocket(webSocket);

View File

@ -1,5 +1,3 @@
#nullable disable
using System; using System;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Sorting; using MediaBrowser.Controller.Sorting;
@ -24,10 +22,9 @@ namespace Emby.Server.Implementations.Sorting
/// <param name="x">The x.</param> /// <param name="x">The x.</param>
/// <param name="y">The y.</param> /// <param name="y">The y.</param>
/// <returns>System.Int32.</returns> /// <returns>System.Int32.</returns>
public int Compare(BaseItem x, BaseItem y) public int Compare(BaseItem? x, BaseItem? y)
{ {
ArgumentNullException.ThrowIfNull(x); ArgumentNullException.ThrowIfNull(x);
ArgumentNullException.ThrowIfNull(y); ArgumentNullException.ThrowIfNull(y);
return (x.RunTimeTicks ?? 0).CompareTo(y.RunTimeTicks ?? 0); return (x.RunTimeTicks ?? 0).CompareTo(y.RunTimeTicks ?? 0);

View File

@ -1,5 +1,3 @@
#nullable disable
#pragma warning disable CS1591 #pragma warning disable CS1591
using System; using System;
@ -23,15 +21,14 @@ namespace Emby.Server.Implementations.Sorting
/// <param name="x">The x.</param> /// <param name="x">The x.</param>
/// <param name="y">The y.</param> /// <param name="y">The y.</param>
/// <returns>System.Int32.</returns> /// <returns>System.Int32.</returns>
public int Compare(BaseItem x, BaseItem y) public int Compare(BaseItem? x, BaseItem? y)
{ {
return string.Compare(GetValue(x), GetValue(y), StringComparison.OrdinalIgnoreCase); return string.Compare(GetValue(x), GetValue(y), StringComparison.OrdinalIgnoreCase);
} }
private static string GetValue(BaseItem item) private static string? GetValue(BaseItem? item)
{ {
var hasSeries = item as IHasSeries; var hasSeries = item as IHasSeries;
return hasSeries?.FindSeriesSortName(); return hasSeries?.FindSeriesSortName();
} }
} }

View File

@ -1,5 +1,3 @@
#nullable disable
using System; using System;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Sorting; using MediaBrowser.Controller.Sorting;
@ -24,10 +22,9 @@ namespace Emby.Server.Implementations.Sorting
/// <param name="x">The x.</param> /// <param name="x">The x.</param>
/// <param name="y">The y.</param> /// <param name="y">The y.</param>
/// <returns>System.Int32.</returns> /// <returns>System.Int32.</returns>
public int Compare(BaseItem x, BaseItem y) public int Compare(BaseItem? x, BaseItem? y)
{ {
ArgumentNullException.ThrowIfNull(x); ArgumentNullException.ThrowIfNull(x);
ArgumentNullException.ThrowIfNull(y); ArgumentNullException.ThrowIfNull(y);
return string.Compare(x.SortName, y.SortName, StringComparison.OrdinalIgnoreCase); return string.Compare(x.SortName, y.SortName, StringComparison.OrdinalIgnoreCase);

View File

@ -1,5 +1,3 @@
#nullable disable
#pragma warning disable CS1591 #pragma warning disable CS1591
using System; using System;
@ -24,7 +22,7 @@ namespace Emby.Server.Implementations.Sorting
/// <param name="x">The x.</param> /// <param name="x">The x.</param>
/// <param name="y">The y.</param> /// <param name="y">The y.</param>
/// <returns>System.Int32.</returns> /// <returns>System.Int32.</returns>
public int Compare(BaseItem x, BaseItem y) public int Compare(BaseItem? x, BaseItem? y)
{ {
return GetDate(x).CompareTo(GetDate(y)); return GetDate(x).CompareTo(GetDate(y));
} }
@ -34,7 +32,7 @@ namespace Emby.Server.Implementations.Sorting
/// </summary> /// </summary>
/// <param name="x">The x.</param> /// <param name="x">The x.</param>
/// <returns>DateTime.</returns> /// <returns>DateTime.</returns>
private static DateTime GetDate(BaseItem x) private static DateTime GetDate(BaseItem? x)
{ {
if (x is LiveTvProgram hasStartDate) if (x is LiveTvProgram hasStartDate)
{ {

View File

@ -1,5 +1,3 @@
#nullable disable
#pragma warning disable CS1591 #pragma warning disable CS1591
using System; using System;
@ -24,10 +22,9 @@ namespace Emby.Server.Implementations.Sorting
/// <param name="x">The x.</param> /// <param name="x">The x.</param>
/// <param name="y">The y.</param> /// <param name="y">The y.</param>
/// <returns>System.Int32.</returns> /// <returns>System.Int32.</returns>
public int Compare(BaseItem x, BaseItem y) public int Compare(BaseItem? x, BaseItem? y)
{ {
ArgumentNullException.ThrowIfNull(x); ArgumentNullException.ThrowIfNull(x);
ArgumentNullException.ThrowIfNull(y); ArgumentNullException.ThrowIfNull(y);
return AlphanumericComparator.CompareValues(x.Studios.FirstOrDefault(), y.Studios.FirstOrDefault()); return AlphanumericComparator.CompareValues(x.Studios.FirstOrDefault(), y.Studios.FirstOrDefault());

View File

@ -1,5 +1,3 @@
#nullable disable
#pragma warning disable CS1591 #pragma warning disable CS1591
using System; using System;
@ -42,7 +40,7 @@ namespace Emby.Server.Implementations.TV
throw new ArgumentException("User not found"); throw new ArgumentException("User not found");
} }
string presentationUniqueKey = null; string? presentationUniqueKey = null;
if (query.SeriesId.HasValue && !query.SeriesId.Value.Equals(default)) if (query.SeriesId.HasValue && !query.SeriesId.Value.Equals(default))
{ {
if (_libraryManager.GetItemById(query.SeriesId.Value) is Series series) if (_libraryManager.GetItemById(query.SeriesId.Value) is Series series)
@ -91,7 +89,7 @@ namespace Emby.Server.Implementations.TV
throw new ArgumentException("User not found"); throw new ArgumentException("User not found");
} }
string presentationUniqueKey = null; string? presentationUniqueKey = null;
int? limit = null; int? limit = null;
if (request.SeriesId.HasValue && !request.SeriesId.Value.Equals(default)) if (request.SeriesId.HasValue && !request.SeriesId.Value.Equals(default))
{ {
@ -168,7 +166,7 @@ namespace Emby.Server.Implementations.TV
return !anyFound && i.LastWatchedDate == DateTime.MinValue; return !anyFound && i.LastWatchedDate == DateTime.MinValue;
}) })
.Select(i => i.GetEpisodeFunction()) .Select(i => i.GetEpisodeFunction())
.Where(i => i is not null); .Where(i => i is not null)!;
} }
private static string GetUniqueSeriesKey(Episode episode) private static string GetUniqueSeriesKey(Episode episode)
@ -185,7 +183,7 @@ namespace Emby.Server.Implementations.TV
/// Gets the next up. /// Gets the next up.
/// </summary> /// </summary>
/// <returns>Task{Episode}.</returns> /// <returns>Task{Episode}.</returns>
private (DateTime LastWatchedDate, Func<Episode> GetEpisodeFunction) GetNextUp(string seriesKey, User user, DtoOptions dtoOptions, bool rewatching) private (DateTime LastWatchedDate, Func<Episode?> GetEpisodeFunction) GetNextUp(string seriesKey, User user, DtoOptions dtoOptions, bool rewatching)
{ {
var lastQuery = new InternalItemsQuery(user) var lastQuery = new InternalItemsQuery(user)
{ {
@ -209,7 +207,7 @@ namespace Emby.Server.Implementations.TV
var lastWatchedEpisode = _libraryManager.GetItemList(lastQuery).Cast<Episode>().FirstOrDefault(); var lastWatchedEpisode = _libraryManager.GetItemList(lastQuery).Cast<Episode>().FirstOrDefault();
Episode GetEpisode() Episode? GetEpisode()
{ {
var nextQuery = new InternalItemsQuery(user) var nextQuery = new InternalItemsQuery(user)
{ {

View File

@ -1,5 +1,3 @@
#nullable disable
#pragma warning disable CS1591 #pragma warning disable CS1591
using System; using System;

View File

@ -9,9 +9,9 @@ namespace MediaBrowser.Model.Tasks
{ {
public interface ITaskManager : IDisposable public interface ITaskManager : IDisposable
{ {
event EventHandler<GenericEventArgs<IScheduledTaskWorker>> TaskExecuting; event EventHandler<GenericEventArgs<IScheduledTaskWorker>>? TaskExecuting;
event EventHandler<TaskCompletionEventArgs> TaskCompleted; event EventHandler<TaskCompletionEventArgs>? TaskCompleted;
/// <summary> /// <summary>
/// Gets the list of Scheduled Tasks. /// Gets the list of Scheduled Tasks.