From a30bba2c0bbc91dd572b58fac9a23dfdcab3428a Mon Sep 17 00:00:00 2001 From: Justin Swanson Date: Thu, 9 Apr 2020 16:12:32 -0500 Subject: [PATCH] Inferencer nullability enabled --- .../UrlDownloaders/BethesdaNetInferencer.cs | 3 ++- .../Downloaders/UrlDownloaders/IUrlInferencer.cs | 3 ++- .../Downloaders/UrlDownloaders/YoutubeInferencer.cs | 10 +++++----- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Wabbajack.Lib/Downloaders/UrlDownloaders/BethesdaNetInferencer.cs b/Wabbajack.Lib/Downloaders/UrlDownloaders/BethesdaNetInferencer.cs index 1265b46e..2dfd3cf2 100644 --- a/Wabbajack.Lib/Downloaders/UrlDownloaders/BethesdaNetInferencer.cs +++ b/Wabbajack.Lib/Downloaders/UrlDownloaders/BethesdaNetInferencer.cs @@ -1,11 +1,12 @@ using System; using System.Threading.Tasks; +#nullable enable namespace Wabbajack.Lib.Downloaders.UrlDownloaders { public class BethesdaNetInferencer : IUrlInferencer { - public async Task Infer(Uri uri) + public async Task Infer(Uri uri) { return BethesdaNetDownloader.StateFromUrl(uri); } diff --git a/Wabbajack.Lib/Downloaders/UrlDownloaders/IUrlInferencer.cs b/Wabbajack.Lib/Downloaders/UrlDownloaders/IUrlInferencer.cs index a0febfa3..84be4335 100644 --- a/Wabbajack.Lib/Downloaders/UrlDownloaders/IUrlInferencer.cs +++ b/Wabbajack.Lib/Downloaders/UrlDownloaders/IUrlInferencer.cs @@ -1,10 +1,11 @@ using System; using System.Threading.Tasks; +#nullable enable namespace Wabbajack.Lib.Downloaders.UrlDownloaders { public interface IUrlInferencer { - Task Infer(Uri uri); + Task Infer(Uri uri); } } diff --git a/Wabbajack.Lib/Downloaders/UrlDownloaders/YoutubeInferencer.cs b/Wabbajack.Lib/Downloaders/UrlDownloaders/YoutubeInferencer.cs index 66cff7eb..8c8d1974 100644 --- a/Wabbajack.Lib/Downloaders/UrlDownloaders/YoutubeInferencer.cs +++ b/Wabbajack.Lib/Downloaders/UrlDownloaders/YoutubeInferencer.cs @@ -3,15 +3,15 @@ using System.Linq; using System.Threading.Tasks; using Wabbajack.Common; using YoutubeExplode; +#nullable enable namespace Wabbajack.Lib.Downloaders.UrlDownloaders { public class YoutubeInferencer : IUrlInferencer { - - public async Task Infer(Uri uri) + public async Task Infer(Uri uri) { - var state = (YouTubeDownloader.State)YouTubeDownloader.UriToState(uri); + var state = YouTubeDownloader.UriToState(uri) as YouTubeDownloader.State; if (state == null) return null; var client = new YoutubeClient(Common.Http.ClientFactory.Client); @@ -24,13 +24,13 @@ namespace Wabbajack.Lib.Downloaders.UrlDownloaders .Select(line => { var segments = line.Split(' ', StringSplitOptions.RemoveEmptyEntries); - if (segments.Length == 0) return (TimeSpan.Zero, null); + if (segments.Length == 0) return (TimeSpan.Zero, string.Empty); if (TryParseEx(segments.First(), out var s1)) return (s1, string.Join(" ", segments.Skip(1))); if (TryParseEx(Enumerable.Last(segments), out var s2)) return (s2, string.Join(" ", Utils.ButLast(segments))); - return (TimeSpan.Zero, null); + return (TimeSpan.Zero, string.Empty); }) .Where(t => t.Item2 != null) .ToList();