From eabdf49dd370d6d55e89e94380b63c95d31568c2 Mon Sep 17 00:00:00 2001 From: Mikal Stordal Date: Fri, 6 Dec 2024 03:44:32 +0100 Subject: [PATCH] chore: move all extensions to their own namespace --- Shokofin/API/Info/EpisodeInfo.cs | 1 + Shokofin/API/Models/ApiException.cs | 8 +------ Shokofin/API/Models/ComponentVersion.cs | 1 + Shokofin/API/Models/Relation.cs | 21 ------------------- Shokofin/API/ShokoAPIManager.cs | 1 + Shokofin/Collections/CollectionManager.cs | 1 + .../MediaFolderConfigurationService.cs | 1 + .../PluginServiceRegistrator.cs | 0 Shokofin/Events/EventDispatchService.cs | 1 + .../CollectionTypeExtensions.cs | 2 +- Shokofin/{ => Extensions}/FolderExtensions.cs | 2 +- Shokofin/{ => Extensions}/ListExtensions.cs | 2 +- .../MediaFolderConfigurationExtensions.cs | 3 ++- Shokofin/{ => Extensions}/StringExtensions.cs | 2 +- .../{Sync => Extensions}/SyncExtensions.cs | 2 +- Shokofin/IdLookup.cs | 1 + Shokofin/MergeVersions/MergeVersionManager.cs | 1 + Shokofin/Providers/BoxSetProvider.cs | 1 + Shokofin/Providers/CustomBoxSetProvider.cs | 1 + Shokofin/Providers/CustomSeasonProvider.cs | 1 + Shokofin/Providers/CustomSeriesProvider.cs | 1 + Shokofin/Providers/SeasonProvider.cs | 1 + Shokofin/Resolvers/ShokoResolver.cs | 1 + .../Resolvers/VirtualFileSystemService.cs | 1 + Shokofin/SignalR/SignalRConnectionManager.cs | 1 + Shokofin/Sync/UserDataSyncManager.cs | 2 +- Shokofin/Tasks/CleanupVirtualRootTask.cs | 1 + Shokofin/Utils/ContentRating.cs | 2 +- Shokofin/Utils/Ordering.cs | 2 +- Shokofin/Utils/Text.cs | 7 ++++--- Shokofin/Web/Models/VfsLibraryPreview.cs | 1 + 31 files changed, 33 insertions(+), 40 deletions(-) rename Shokofin/{ => Configuration}/PluginServiceRegistrator.cs (100%) rename Shokofin/{ => Extensions}/CollectionTypeExtensions.cs (96%) rename Shokofin/{ => Extensions}/FolderExtensions.cs (88%) rename Shokofin/{ => Extensions}/ListExtensions.cs (95%) rename Shokofin/{Configuration => Extensions}/MediaFolderConfigurationExtensions.cs (96%) rename Shokofin/{ => Extensions}/StringExtensions.cs (99%) rename Shokofin/{Sync => Extensions}/SyncExtensions.cs (99%) diff --git a/Shokofin/API/Info/EpisodeInfo.cs b/Shokofin/API/Info/EpisodeInfo.cs index 6597406..7c170b5 100644 --- a/Shokofin/API/Info/EpisodeInfo.cs +++ b/Shokofin/API/Info/EpisodeInfo.cs @@ -12,6 +12,7 @@ using Shokofin.API.Models.TMDB; using Shokofin.Configuration; using Shokofin.Events.Interfaces; +using Shokofin.Extensions; using Shokofin.Utils; namespace Shokofin.API.Info; diff --git a/Shokofin/API/Models/ApiException.cs b/Shokofin/API/Models/ApiException.cs index 7bbb7e5..217af8c 100644 --- a/Shokofin/API/Models/ApiException.cs +++ b/Shokofin/API/Models/ApiException.cs @@ -5,6 +5,7 @@ using System.Net; using System.Net.Http; using System.Text.Json; +using Shokofin.Extensions; namespace Shokofin.API.Models; @@ -81,10 +82,3 @@ public enum ApiExceptionType { RemoteException = 2, } } - -public static class IListExtension { - public static void Deconstruct(this IList list, out T? first, out IList rest) { - first = list.Count > 0 ? list[0] : default; // or throw - rest = list.Skip(1).ToList(); - } -} diff --git a/Shokofin/API/Models/ComponentVersion.cs b/Shokofin/API/Models/ComponentVersion.cs index 2ef7065..7f3db89 100644 --- a/Shokofin/API/Models/ComponentVersion.cs +++ b/Shokofin/API/Models/ComponentVersion.cs @@ -2,6 +2,7 @@ using System.ComponentModel; using System.Linq; using System.Text.Json.Serialization; +using Shokofin.Extensions; namespace Shokofin.API.Models; diff --git a/Shokofin/API/Models/Relation.cs b/Shokofin/API/Models/Relation.cs index a46b9cb..4115d16 100644 --- a/Shokofin/API/Models/Relation.cs +++ b/Shokofin/API/Models/Relation.cs @@ -102,24 +102,3 @@ public enum RelationType { /// Summary = 42, } - -/// -/// Extensions related to relations -/// -public static class RelationExtensions { - /// - /// Reverse the relation. - /// - /// The relation to reverse. - /// The reversed relation. - public static RelationType Reverse(this RelationType type) - => type switch { - RelationType.Prequel => RelationType.Sequel, - RelationType.Sequel => RelationType.Prequel, - RelationType.MainStory => RelationType.SideStory, - RelationType.SideStory => RelationType.MainStory, - RelationType.FullStory => RelationType.Summary, - RelationType.Summary => RelationType.FullStory, - _ => type - }; -} diff --git a/Shokofin/API/ShokoAPIManager.cs b/Shokofin/API/ShokoAPIManager.cs index 9f943b0..62f4a1a 100644 --- a/Shokofin/API/ShokoAPIManager.cs +++ b/Shokofin/API/ShokoAPIManager.cs @@ -19,6 +19,7 @@ using Path = System.IO.Path; using Regex = System.Text.RegularExpressions.Regex; using RegexOptions = System.Text.RegularExpressions.RegexOptions; +using Shokofin.Extensions; namespace Shokofin.API; diff --git a/Shokofin/Collections/CollectionManager.cs b/Shokofin/Collections/CollectionManager.cs index 49b81dc..dae98c9 100644 --- a/Shokofin/Collections/CollectionManager.cs +++ b/Shokofin/Collections/CollectionManager.cs @@ -13,6 +13,7 @@ using Microsoft.Extensions.Logging; using Shokofin.API; using Shokofin.API.Info; +using Shokofin.Extensions; using Shokofin.ExternalIds; using Shokofin.Utils; diff --git a/Shokofin/Configuration/MediaFolderConfigurationService.cs b/Shokofin/Configuration/MediaFolderConfigurationService.cs index ccd5965..e2cb9c4 100644 --- a/Shokofin/Configuration/MediaFolderConfigurationService.cs +++ b/Shokofin/Configuration/MediaFolderConfigurationService.cs @@ -14,6 +14,7 @@ using Microsoft.Extensions.Logging; using Shokofin.API; using Shokofin.Configuration.Models; +using Shokofin.Extensions; using Shokofin.Utils; namespace Shokofin.Configuration; diff --git a/Shokofin/PluginServiceRegistrator.cs b/Shokofin/Configuration/PluginServiceRegistrator.cs similarity index 100% rename from Shokofin/PluginServiceRegistrator.cs rename to Shokofin/Configuration/PluginServiceRegistrator.cs diff --git a/Shokofin/Events/EventDispatchService.cs b/Shokofin/Events/EventDispatchService.cs index ddb9d14..938ac3c 100644 --- a/Shokofin/Events/EventDispatchService.cs +++ b/Shokofin/Events/EventDispatchService.cs @@ -16,6 +16,7 @@ using Shokofin.API.Models; using Shokofin.Configuration; using Shokofin.Events.Interfaces; +using Shokofin.Extensions; using Shokofin.ExternalIds; using Shokofin.Resolvers; using Shokofin.Resolvers.Models; diff --git a/Shokofin/CollectionTypeExtensions.cs b/Shokofin/Extensions/CollectionTypeExtensions.cs similarity index 96% rename from Shokofin/CollectionTypeExtensions.cs rename to Shokofin/Extensions/CollectionTypeExtensions.cs index 71a53d1..6a21212 100644 --- a/Shokofin/CollectionTypeExtensions.cs +++ b/Shokofin/Extensions/CollectionTypeExtensions.cs @@ -2,7 +2,7 @@ using Jellyfin.Data.Enums; using MediaBrowser.Model.Entities; -namespace Shokofin; +namespace Shokofin.Extensions; public static class CollectionTypeExtensions { public static CollectionType? ConvertToCollectionType(this CollectionTypeOptions? collectionType) diff --git a/Shokofin/FolderExtensions.cs b/Shokofin/Extensions/FolderExtensions.cs similarity index 88% rename from Shokofin/FolderExtensions.cs rename to Shokofin/Extensions/FolderExtensions.cs index 404a597..a5e71cd 100644 --- a/Shokofin/FolderExtensions.cs +++ b/Shokofin/Extensions/FolderExtensions.cs @@ -1,7 +1,7 @@ using System.IO; using MediaBrowser.Controller.Entities; -namespace Shokofin; +namespace Shokofin.Extensions; public static class FolderExtensions { public static string GetVirtualRoot(this Folder libraryFolder) diff --git a/Shokofin/ListExtensions.cs b/Shokofin/Extensions/ListExtensions.cs similarity index 95% rename from Shokofin/ListExtensions.cs rename to Shokofin/Extensions/ListExtensions.cs index 0128765..eff832b 100644 --- a/Shokofin/ListExtensions.cs +++ b/Shokofin/Extensions/ListExtensions.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; -namespace Shokofin; +namespace Shokofin.Extensions; public static class ListExtensions { public static bool TryRemoveAt(this List list, int index, [NotNullWhen(true)] out T? item) { diff --git a/Shokofin/Configuration/MediaFolderConfigurationExtensions.cs b/Shokofin/Extensions/MediaFolderConfigurationExtensions.cs similarity index 96% rename from Shokofin/Configuration/MediaFolderConfigurationExtensions.cs rename to Shokofin/Extensions/MediaFolderConfigurationExtensions.cs index e1513df..f6a3200 100644 --- a/Shokofin/Configuration/MediaFolderConfigurationExtensions.cs +++ b/Shokofin/Extensions/MediaFolderConfigurationExtensions.cs @@ -2,8 +2,9 @@ using System.Collections.Generic; using System.Linq; using MediaBrowser.Controller.Entities; +using Shokofin.Configuration; -namespace Shokofin.Configuration; +namespace Shokofin.Extensions; public static class MediaFolderConfigurationExtensions { public static Folder GetFolderForPath(this string mediaFolderPath) diff --git a/Shokofin/StringExtensions.cs b/Shokofin/Extensions/StringExtensions.cs similarity index 99% rename from Shokofin/StringExtensions.cs rename to Shokofin/Extensions/StringExtensions.cs index 04e598b..ba5ac21 100644 --- a/Shokofin/StringExtensions.cs +++ b/Shokofin/Extensions/StringExtensions.cs @@ -7,7 +7,7 @@ using MediaBrowser.Model.Entities; using Shokofin.ExternalIds; -namespace Shokofin; +namespace Shokofin.Extensions; public static partial class StringExtensions { public static string Replace(this string input, Regex regex, string replacement, int count, int startAt) diff --git a/Shokofin/Sync/SyncExtensions.cs b/Shokofin/Extensions/SyncExtensions.cs similarity index 99% rename from Shokofin/Sync/SyncExtensions.cs rename to Shokofin/Extensions/SyncExtensions.cs index d648b1c..e125aa0 100644 --- a/Shokofin/Sync/SyncExtensions.cs +++ b/Shokofin/Extensions/SyncExtensions.cs @@ -3,7 +3,7 @@ using MediaBrowser.Controller.Entities; using Shokofin.API.Models; -namespace Shokofin.Sync; +namespace Shokofin.Extensions; public static class SyncExtensions { public static File.UserStats ToFileUserStats(this UserItemData userData) { diff --git a/Shokofin/IdLookup.cs b/Shokofin/IdLookup.cs index 525adf2..d0674f6 100644 --- a/Shokofin/IdLookup.cs +++ b/Shokofin/IdLookup.cs @@ -8,6 +8,7 @@ using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Entities; using Shokofin.API; +using Shokofin.Extensions; using Shokofin.ExternalIds; using Shokofin.Providers; diff --git a/Shokofin/MergeVersions/MergeVersionManager.cs b/Shokofin/MergeVersions/MergeVersionManager.cs index fb5338f..ecc9027 100644 --- a/Shokofin/MergeVersions/MergeVersionManager.cs +++ b/Shokofin/MergeVersions/MergeVersionManager.cs @@ -13,6 +13,7 @@ using MediaBrowser.Model.Entities; using Microsoft.Extensions.Logging; using Shokofin.API; +using Shokofin.Extensions; using Shokofin.ExternalIds; using Shokofin.Utils; diff --git a/Shokofin/Providers/BoxSetProvider.cs b/Shokofin/Providers/BoxSetProvider.cs index ee08065..5666d4e 100644 --- a/Shokofin/Providers/BoxSetProvider.cs +++ b/Shokofin/Providers/BoxSetProvider.cs @@ -10,6 +10,7 @@ using MediaBrowser.Model.Providers; using Microsoft.Extensions.Logging; using Shokofin.API; +using Shokofin.Extensions; using Shokofin.ExternalIds; using Shokofin.Utils; diff --git a/Shokofin/Providers/CustomBoxSetProvider.cs b/Shokofin/Providers/CustomBoxSetProvider.cs index 654acb4..239f3c8 100644 --- a/Shokofin/Providers/CustomBoxSetProvider.cs +++ b/Shokofin/Providers/CustomBoxSetProvider.cs @@ -13,6 +13,7 @@ using Shokofin.API; using Shokofin.API.Info; using Shokofin.Collections; +using Shokofin.Extensions; using Shokofin.ExternalIds; using Shokofin.Utils; diff --git a/Shokofin/Providers/CustomSeasonProvider.cs b/Shokofin/Providers/CustomSeasonProvider.cs index ddbee0e..ac166f1 100644 --- a/Shokofin/Providers/CustomSeasonProvider.cs +++ b/Shokofin/Providers/CustomSeasonProvider.cs @@ -10,6 +10,7 @@ using MediaBrowser.Model.Entities; using Microsoft.Extensions.Logging; using Shokofin.API; +using Shokofin.Extensions; using Shokofin.ExternalIds; using Shokofin.MergeVersions; diff --git a/Shokofin/Providers/CustomSeriesProvider.cs b/Shokofin/Providers/CustomSeriesProvider.cs index c994773..f353c36 100644 --- a/Shokofin/Providers/CustomSeriesProvider.cs +++ b/Shokofin/Providers/CustomSeriesProvider.cs @@ -10,6 +10,7 @@ using MediaBrowser.Model.Entities; using Microsoft.Extensions.Logging; using Shokofin.API; +using Shokofin.Extensions; using Shokofin.ExternalIds; using Shokofin.MergeVersions; using Shokofin.Utils; diff --git a/Shokofin/Providers/SeasonProvider.cs b/Shokofin/Providers/SeasonProvider.cs index 91a980f..7af0548 100644 --- a/Shokofin/Providers/SeasonProvider.cs +++ b/Shokofin/Providers/SeasonProvider.cs @@ -10,6 +10,7 @@ using MediaBrowser.Model.Providers; using Microsoft.Extensions.Logging; using Shokofin.API; +using Shokofin.Extensions; using Shokofin.ExternalIds; using Shokofin.Utils; diff --git a/Shokofin/Resolvers/ShokoResolver.cs b/Shokofin/Resolvers/ShokoResolver.cs index d95f004..e455247 100644 --- a/Shokofin/Resolvers/ShokoResolver.cs +++ b/Shokofin/Resolvers/ShokoResolver.cs @@ -14,6 +14,7 @@ using Microsoft.Extensions.Logging; using Shokofin.API; using Shokofin.API.Models; +using Shokofin.Extensions; using Shokofin.ExternalIds; using File = System.IO.File; diff --git a/Shokofin/Resolvers/VirtualFileSystemService.cs b/Shokofin/Resolvers/VirtualFileSystemService.cs index 91a9872..2156d9d 100644 --- a/Shokofin/Resolvers/VirtualFileSystemService.cs +++ b/Shokofin/Resolvers/VirtualFileSystemService.cs @@ -17,6 +17,7 @@ using Shokofin.API; using Shokofin.API.Models; using Shokofin.Configuration; +using Shokofin.Extensions; using Shokofin.ExternalIds; using Shokofin.Resolvers.Models; using Shokofin.Utils; diff --git a/Shokofin/SignalR/SignalRConnectionManager.cs b/Shokofin/SignalR/SignalRConnectionManager.cs index 66aa38b..72e5299 100644 --- a/Shokofin/SignalR/SignalRConnectionManager.cs +++ b/Shokofin/SignalR/SignalRConnectionManager.cs @@ -9,6 +9,7 @@ using Shokofin.Configuration; using Shokofin.Events; using Shokofin.Events.Interfaces; +using Shokofin.Extensions; using Shokofin.SignalR.Models; using Shokofin.Utils; diff --git a/Shokofin/Sync/UserDataSyncManager.cs b/Shokofin/Sync/UserDataSyncManager.cs index 689e12a..0c21b30 100644 --- a/Shokofin/Sync/UserDataSyncManager.cs +++ b/Shokofin/Sync/UserDataSyncManager.cs @@ -16,7 +16,7 @@ using Microsoft.Extensions.Logging; using Shokofin.API; using Shokofin.Configuration; - +using Shokofin.Extensions; using UserStats = Shokofin.API.Models.File.UserStats; namespace Shokofin.Sync; diff --git a/Shokofin/Tasks/CleanupVirtualRootTask.cs b/Shokofin/Tasks/CleanupVirtualRootTask.cs index 923b740..74d3ca6 100644 --- a/Shokofin/Tasks/CleanupVirtualRootTask.cs +++ b/Shokofin/Tasks/CleanupVirtualRootTask.cs @@ -10,6 +10,7 @@ using MediaBrowser.Model.Tasks; using Microsoft.Extensions.Logging; using Shokofin.Configuration; +using Shokofin.Extensions; using Shokofin.Utils; namespace Shokofin.Tasks; diff --git a/Shokofin/Utils/ContentRating.cs b/Shokofin/Utils/ContentRating.cs index 4b56931..51758bf 100644 --- a/Shokofin/Utils/ContentRating.cs +++ b/Shokofin/Utils/ContentRating.cs @@ -7,7 +7,7 @@ using Shokofin.API.Info; using Shokofin.API.Models; using Shokofin.Events.Interfaces; - +using Shokofin.Extensions; using TagWeight = Shokofin.Utils.TagFilter.TagWeight; namespace Shokofin.Utils; diff --git a/Shokofin/Utils/Ordering.cs b/Shokofin/Utils/Ordering.cs index 000ad5b..6a1eb31 100644 --- a/Shokofin/Utils/Ordering.cs +++ b/Shokofin/Utils/Ordering.cs @@ -4,7 +4,7 @@ using Shokofin.API.Info; using Shokofin.API.Models; using Shokofin.API.Models.AniDB; - +using Shokofin.Extensions; using ExtraType = MediaBrowser.Model.Entities.ExtraType; namespace Shokofin.Utils; diff --git a/Shokofin/Utils/Text.cs b/Shokofin/Utils/Text.cs index a3db07f..d879a1f 100644 --- a/Shokofin/Utils/Text.cs +++ b/Shokofin/Utils/Text.cs @@ -1,10 +1,11 @@ -using Shokofin.API; -using Shokofin.API.Info; -using Shokofin.API.Models; using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; +using Shokofin.API; +using Shokofin.API.Info; +using Shokofin.API.Models; +using Shokofin.Extensions; namespace Shokofin.Utils; diff --git a/Shokofin/Web/Models/VfsLibraryPreview.cs b/Shokofin/Web/Models/VfsLibraryPreview.cs index 0ab31e3..b9e38be 100644 --- a/Shokofin/Web/Models/VfsLibraryPreview.cs +++ b/Shokofin/Web/Models/VfsLibraryPreview.cs @@ -2,6 +2,7 @@ using System.IO; using System.Linq; using MediaBrowser.Model.Entities; +using Shokofin.Extensions; using Shokofin.Resolvers.Models; namespace Shokofin.Web.Models;