Correct style inconsistencies

This commit is contained in:
AmbulantRex 2023-04-01 04:59:07 -06:00
parent 677b1f8e34
commit a944352aa8
5 changed files with 11 additions and 8 deletions

View file

@ -87,8 +87,8 @@ namespace Emby.Server.Implementations.Library
return false; return false;
} }
subPath = subPath.NormalizePath(out var newDirectorySeparatorChar)!; subPath = subPath.NormalizePath(out var newDirectorySeparatorChar);
path = path.NormalizePath(newDirectorySeparatorChar)!; path = path.NormalizePath(newDirectorySeparatorChar);
// We have to ensure that the sub path ends with a directory separator otherwise we'll get weird results // 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 // when the sub path matches a similar but in-complete subpath
@ -128,6 +128,7 @@ namespace Emby.Server.Implementations.Library
/// </summary> /// </summary>
/// <param name="path">The path to normalize.</param> /// <param name="path">The path to normalize.</param>
/// <returns>The normalized path string or <see langword="null"/> if the input path is null or empty.</returns> /// <returns>The normalized path string or <see langword="null"/> if the input path is null or empty.</returns>
[return: NotNullIfNotNull(nameof(path))]
public static string? NormalizePath(this string? path) public static string? NormalizePath(this string? path)
{ {
return path.NormalizePath(Path.DirectorySeparatorChar); return path.NormalizePath(Path.DirectorySeparatorChar);
@ -139,6 +140,7 @@ namespace Emby.Server.Implementations.Library
/// <param name="path">The path to normalize.</param> /// <param name="path">The path to normalize.</param>
/// <param name="separator">The separator character the path now uses or <see langword="null"/>.</param> /// <param name="separator">The separator character the path now uses or <see langword="null"/>.</param>
/// <returns>The normalized path string or <see langword="null"/> if the input path is null or empty.</returns> /// <returns>The normalized path string or <see langword="null"/> if the input path is null or empty.</returns>
[return: NotNullIfNotNull(nameof(path))]
public static string? NormalizePath(this string? path, out char separator) public static string? NormalizePath(this string? path, out char separator)
{ {
if (string.IsNullOrEmpty(path)) if (string.IsNullOrEmpty(path))
@ -169,6 +171,7 @@ namespace Emby.Server.Implementations.Library
/// <param name="newSeparator">The replacement directory separator character. Must be a valid directory separator.</param> /// <param name="newSeparator">The replacement directory separator character. Must be a valid directory separator.</param>
/// <returns>The normalized path.</returns> /// <returns>The normalized path.</returns>
/// <exception cref="ArgumentException">Thrown if the new separator character is not a directory separator.</exception> /// <exception cref="ArgumentException">Thrown if the new separator character is not a directory separator.</exception>
[return: NotNullIfNotNull(nameof(path))]
public static string? NormalizePath(this string? path, char newSeparator) public static string? NormalizePath(this string? path, char newSeparator)
{ {
const char Bs = '\\'; const char Bs = '\\';
@ -184,7 +187,7 @@ namespace Emby.Server.Implementations.Library
return path; return path;
} }
return newSeparator == Bs ? path?.Replace(Fs, newSeparator) : path?.Replace(Bs, newSeparator); return newSeparator == Bs ? path.Replace(Fs, newSeparator) : path.Replace(Bs, newSeparator);
} }
} }
} }

View file

@ -765,7 +765,7 @@ namespace Emby.Server.Implementations.Plugins
/// <exception cref="ArgumentNullException">If the <see cref="LocalPlugin"/> is null.</exception> /// <exception cref="ArgumentNullException">If the <see cref="LocalPlugin"/> is null.</exception>
private bool TryGetPluginDlls(LocalPlugin plugin, out IReadOnlyList<string> whitelistedDlls) private bool TryGetPluginDlls(LocalPlugin plugin, out IReadOnlyList<string> whitelistedDlls)
{ {
_ = plugin ?? throw new ArgumentNullException(nameof(plugin)); ArgumentNullException.ThrowIfNull(nameof(plugin));
IReadOnlyList<string> pluginDlls = Directory.GetFiles(plugin.Path, "*.dll", SearchOption.AllDirectories); IReadOnlyList<string> pluginDlls = Directory.GetFiles(plugin.Path, "*.dll", SearchOption.AllDirectories);

View file

@ -24,7 +24,7 @@ namespace MediaBrowser.Common.Plugins
Overview = string.Empty; Overview = string.Empty;
TargetAbi = string.Empty; TargetAbi = string.Empty;
Version = string.Empty; Version = string.Empty;
Assemblies = new List<string>(); Assemblies = Array.Empty<string>();
} }
/// <summary> /// <summary>
@ -112,6 +112,6 @@ namespace MediaBrowser.Common.Plugins
/// Paths are considered relative to the plugin folder. /// Paths are considered relative to the plugin folder.
/// </summary> /// </summary>
[JsonPropertyName("assemblies")] [JsonPropertyName("assemblies")]
public IList<string> Assemblies { get; set; } public IReadOnlyList<string> Assemblies { get; set; }
} }
} }

View file

@ -80,6 +80,6 @@ namespace MediaBrowser.Model.Updates
/// Gets or sets the assemblies whitelist for this version. /// Gets or sets the assemblies whitelist for this version.
/// </summary> /// </summary>
[JsonPropertyName("assemblies")] [JsonPropertyName("assemblies")]
public IList<string> Assemblies { get; set; } = Array.Empty<string>(); public IReadOnlyList<string> Assemblies { get; set; } = Array.Empty<string>();
} }
} }