< Summary - Jellyfin

Information
Class: MediaBrowser.Common.Plugins.LocalPlugin
Assembly: MediaBrowser.Common
File(s): /srv/git/jellyfin/MediaBrowser.Common/Plugins/LocalPlugin.cs
Line coverage
70%
Covered lines: 17
Uncovered lines: 7
Coverable lines: 24
Total lines: 147
Line coverage: 70.8%
Branch coverage
43%
Covered branches: 14
Total branches: 32
Branch coverage: 43.7%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 5/6/2026 - 12:15:23 AM Line coverage: 54.1% (13/24) Branch coverage: 17.8% (5/28) Total lines: 1395/22/2026 - 12:15:17 AM Line coverage: 54.1% (13/24) Branch coverage: 20% (6/30) Total lines: 1398/9/2026 - 12:16:58 AM Line coverage: 70.8% (17/24) Branch coverage: 43.7% (14/32) Total lines: 147 5/6/2026 - 12:15:23 AM Line coverage: 54.1% (13/24) Branch coverage: 17.8% (5/28) Total lines: 1395/22/2026 - 12:15:17 AM Line coverage: 54.1% (13/24) Branch coverage: 20% (6/30) Total lines: 1398/9/2026 - 12:16:58 AM Line coverage: 70.8% (17/24) Branch coverage: 43.7% (14/32) Total lines: 147

Coverage delta

Coverage delta 24 -24

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
get_Id()100%11100%
get_Name()100%11100%
get_Version()100%22100%
get_IsEnabledAndSupported()50%22100%
Compare(...)58.33%171266.66%
GetPluginInfo()50%88100%
Equals(...)0%620%
GetHashCode()100%210%
Equals(...)0%4260%

File(s)

/srv/git/jellyfin/MediaBrowser.Common/Plugins/LocalPlugin.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using MediaBrowser.Model.Plugins;
 4
 5namespace MediaBrowser.Common.Plugins
 6{
 7    /// <summary>
 8    /// Local plugin class.
 9    /// </summary>
 10    public class LocalPlugin : IEquatable<LocalPlugin>
 11    {
 12        private readonly bool _supported;
 13        private Version? _version;
 14
 15        /// <summary>
 16        /// Initializes a new instance of the <see cref="LocalPlugin"/> class.
 17        /// </summary>
 18        /// <param name="path">The plugin path.</param>
 19        /// <param name="isSupported"><b>True</b> if Jellyfin supports this version of the plugin.</param>
 20        /// <param name="manifest">The manifest record for this plugin, or null if one does not exist.</param>
 21        public LocalPlugin(string path, bool isSupported, PluginManifest manifest)
 22        {
 23            Path = path;
 24924            DllFiles = Array.Empty<string>();
 24925            _supported = isSupported;
 26            Manifest = manifest;
 24927        }
 28
 29        /// <summary>
 30        /// Gets the plugin id.
 31        /// </summary>
 672232        public Guid Id => Manifest.Id;
 33
 34        /// <summary>
 35        /// Gets the plugin name.
 36        /// </summary>
 30637        public string Name => Manifest.Name;
 38
 39        /// <summary>
 40        /// Gets the plugin version.
 41        /// </summary>
 42        public Version Version
 43        {
 44            get
 45            {
 21046                if (_version is null)
 47                {
 17948                    _version = Version.Parse(Manifest.Version);
 49                }
 50
 21051                return _version;
 52            }
 53        }
 54
 55        /// <summary>
 56        /// Gets the plugin path.
 57        /// </summary>
 58        public string Path { get; }
 59
 60        /// <summary>
 61        /// Gets or sets the list of dll files for this plugin.
 62        /// </summary>
 63        public IReadOnlyList<string> DllFiles { get; set; }
 64
 65        /// <summary>
 66        /// Gets or sets the instance of this plugin.
 67        /// </summary>
 68        public IPlugin? Instance { get; set; }
 69
 70        /// <summary>
 71        /// Gets a value indicating whether Jellyfin supports this version of the plugin, and it's enabled.
 72        /// </summary>
 1273        public bool IsEnabledAndSupported => _supported && Manifest.Status >= PluginStatus.Active;
 74
 75        /// <summary>
 76        /// Gets or sets a value indicating whether a restart is required for the plugin's state to take effect.
 77        /// </summary>
 78        /// <remarks>
 79        /// Memory only. <see cref="Manifest"/> holds the state that is persisted to disk.
 80        /// </remarks>
 81        public bool RestartRequired { get; set; }
 82
 83        /// <summary>
 84        /// Gets a value indicating whether the plugin has a manifest.
 85        /// </summary>
 86        public PluginManifest Manifest { get; }
 87
 88        /// <summary>
 89        /// Compare two <see cref="LocalPlugin"/>.
 90        /// </summary>
 91        /// <param name="a">The first item.</param>
 92        /// <param name="b">The second item.</param>
 93        /// <returns>Comparison result.</returns>
 94        public static int Compare(LocalPlugin a, LocalPlugin b)
 95        {
 296            if (a is null || b is null)
 97            {
 098                throw new ArgumentNullException(a is null ? nameof(a) : nameof(b));
 99            }
 100
 2101            var compare = string.Compare(a.Name, b.Name, StringComparison.OrdinalIgnoreCase);
 102
 103            // Id is not equal but name is.
 2104            if (!a.Id.Equals(b.Id) && compare == 0)
 105            {
 0106                compare = a.Id.CompareTo(b.Id);
 107            }
 108
 2109            return compare == 0 ? a.Version.CompareTo(b.Version) : compare;
 110        }
 111
 112        /// <summary>
 113        /// Returns the plugin information.
 114        /// </summary>
 115        /// <returns>A <see cref="PluginInfo"/> instance containing the information.</returns>
 116        public PluginInfo GetPluginInfo()
 117        {
 9118            var inst = Instance?.GetPluginInfo() ?? new PluginInfo(Manifest.Name, Version, Manifest.Description, Manifes
 9119            inst.Status = RestartRequired ? PluginStatus.Restart : Manifest.Status;
 9120            inst.HasImage = !string.IsNullOrEmpty(Manifest.ImagePath) || !string.IsNullOrEmpty(Manifest.ImageResourceNam
 9121            return inst;
 122        }
 123
 124        /// <inheritdoc />
 125        public override bool Equals(object? obj)
 126        {
 0127            return obj is LocalPlugin other && this.Equals(other);
 128        }
 129
 130        /// <inheritdoc />
 131        public override int GetHashCode()
 132        {
 0133            return Name.GetHashCode(StringComparison.OrdinalIgnoreCase);
 134        }
 135
 136        /// <inheritdoc />
 137        public bool Equals(LocalPlugin? other)
 138        {
 0139            if (other is null)
 140            {
 0141                return false;
 142            }
 143
 0144            return Name.Equals(other.Name, StringComparison.OrdinalIgnoreCase) && Id.Equals(other.Id) && Version.Equals(
 145        }
 146    }
 147}