From a944352aa8b961ab723fed2d66947c19129a11cc Mon Sep 17 00:00:00 2001
From: AmbulantRex <21176662+AmbulantRex@users.noreply.github.com>
Date: Sat, 1 Apr 2023 04:59:07 -0600
Subject: [PATCH] Correct style inconsistencies
---
Emby.Server.Implementations/Library/PathExtensions.cs | 9 ++++++---
Emby.Server.Implementations/Plugins/PluginManager.cs | 2 +-
MediaBrowser.Common/Plugins/PluginManifest.cs | 4 ++--
MediaBrowser.Model/Updates/VersionInfo.cs | 2 +-
.../Test Data/Updates/manifest-stable.json | 2 +-
5 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/Emby.Server.Implementations/Library/PathExtensions.cs b/Emby.Server.Implementations/Library/PathExtensions.cs
index a3d748a138..62a9e6419e 100644
--- a/Emby.Server.Implementations/Library/PathExtensions.cs
+++ b/Emby.Server.Implementations/Library/PathExtensions.cs
@@ -87,8 +87,8 @@ namespace Emby.Server.Implementations.Library
return false;
}
- subPath = subPath.NormalizePath(out var newDirectorySeparatorChar)!;
- path = path.NormalizePath(newDirectorySeparatorChar)!;
+ subPath = subPath.NormalizePath(out var newDirectorySeparatorChar);
+ path = path.NormalizePath(newDirectorySeparatorChar);
// We have to ensure that the sub path ends with a directory separator otherwise we'll get weird results
// when the sub path matches a similar but in-complete subpath
@@ -128,6 +128,7 @@ namespace Emby.Server.Implementations.Library
///
/// The path to normalize.
/// The normalized path string or if the input path is null or empty.
+ [return: NotNullIfNotNull(nameof(path))]
public static string? NormalizePath(this string? path)
{
return path.NormalizePath(Path.DirectorySeparatorChar);
@@ -139,6 +140,7 @@ namespace Emby.Server.Implementations.Library
/// The path to normalize.
/// The separator character the path now uses or .
/// The normalized path string or if the input path is null or empty.
+ [return: NotNullIfNotNull(nameof(path))]
public static string? NormalizePath(this string? path, out char separator)
{
if (string.IsNullOrEmpty(path))
@@ -169,6 +171,7 @@ namespace Emby.Server.Implementations.Library
/// The replacement directory separator character. Must be a valid directory separator.
/// The normalized path.
/// Thrown if the new separator character is not a directory separator.
+ [return: NotNullIfNotNull(nameof(path))]
public static string? NormalizePath(this string? path, char newSeparator)
{
const char Bs = '\\';
@@ -184,7 +187,7 @@ namespace Emby.Server.Implementations.Library
return path;
}
- return newSeparator == Bs ? path?.Replace(Fs, newSeparator) : path?.Replace(Bs, newSeparator);
+ return newSeparator == Bs ? path.Replace(Fs, newSeparator) : path.Replace(Bs, newSeparator);
}
}
}
diff --git a/Emby.Server.Implementations/Plugins/PluginManager.cs b/Emby.Server.Implementations/Plugins/PluginManager.cs
index d253a0ab99..0a7c144ed7 100644
--- a/Emby.Server.Implementations/Plugins/PluginManager.cs
+++ b/Emby.Server.Implementations/Plugins/PluginManager.cs
@@ -765,7 +765,7 @@ namespace Emby.Server.Implementations.Plugins
/// If the is null.
private bool TryGetPluginDlls(LocalPlugin plugin, out IReadOnlyList whitelistedDlls)
{
- _ = plugin ?? throw new ArgumentNullException(nameof(plugin));
+ ArgumentNullException.ThrowIfNull(nameof(plugin));
IReadOnlyList pluginDlls = Directory.GetFiles(plugin.Path, "*.dll", SearchOption.AllDirectories);
diff --git a/MediaBrowser.Common/Plugins/PluginManifest.cs b/MediaBrowser.Common/Plugins/PluginManifest.cs
index 2bad3454d1..e0847ccea4 100644
--- a/MediaBrowser.Common/Plugins/PluginManifest.cs
+++ b/MediaBrowser.Common/Plugins/PluginManifest.cs
@@ -24,7 +24,7 @@ namespace MediaBrowser.Common.Plugins
Overview = string.Empty;
TargetAbi = string.Empty;
Version = string.Empty;
- Assemblies = new List();
+ Assemblies = Array.Empty();
}
///
@@ -112,6 +112,6 @@ namespace MediaBrowser.Common.Plugins
/// Paths are considered relative to the plugin folder.
///
[JsonPropertyName("assemblies")]
- public IList Assemblies { get; set; }
+ public IReadOnlyList Assemblies { get; set; }
}
}
diff --git a/MediaBrowser.Model/Updates/VersionInfo.cs b/MediaBrowser.Model/Updates/VersionInfo.cs
index 1e24bde84e..8f76806450 100644
--- a/MediaBrowser.Model/Updates/VersionInfo.cs
+++ b/MediaBrowser.Model/Updates/VersionInfo.cs
@@ -80,6 +80,6 @@ namespace MediaBrowser.Model.Updates
/// Gets or sets the assemblies whitelist for this version.
///
[JsonPropertyName("assemblies")]
- public IList Assemblies { get; set; } = Array.Empty();
+ public IReadOnlyList Assemblies { get; set; } = Array.Empty();
}
}
diff --git a/tests/Jellyfin.Server.Implementations.Tests/Test Data/Updates/manifest-stable.json b/tests/Jellyfin.Server.Implementations.Tests/Test Data/Updates/manifest-stable.json
index d69a52d6d0..3aec299587 100644
--- a/tests/Jellyfin.Server.Implementations.Tests/Test Data/Updates/manifest-stable.json
+++ b/tests/Jellyfin.Server.Implementations.Tests/Test Data/Updates/manifest-stable.json
@@ -25,7 +25,7 @@
"timestamp": "2020-07-20T01:30:16Z",
"assemblies": [ "Jellyfin.Plugin.Anime.dll" ]
}
- ]
+ ]
},
{
"guid": "70b7b43b-471b-4159-b4be-56750c795499",