< Summary - Jellyfin

Information
Class: Emby.Server.Implementations.Plugins.PluginLoadContext
Assembly: Emby.Server.Implementations
File(s): /srv/git/jellyfin/Emby.Server.Implementations/Plugins/PluginLoadContext.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 7
Coverable lines: 7
Total lines: 33
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%210%
Load(...)0%620%

File(s)

/srv/git/jellyfin/Emby.Server.Implementations/Plugins/PluginLoadContext.cs

#LineLine coverage
 1using System.Reflection;
 2using System.Runtime.Loader;
 3
 4namespace Emby.Server.Implementations.Plugins;
 5
 6/// <summary>
 7/// A custom <see cref="AssemblyLoadContext"/> for loading Jellyfin plugins.
 8/// </summary>
 9public class PluginLoadContext : AssemblyLoadContext
 10{
 11    private readonly AssemblyDependencyResolver _resolver;
 12
 13    /// <summary>
 14    /// Initializes a new instance of the <see cref="PluginLoadContext"/> class.
 15    /// </summary>
 16    /// <param name="path">The path of the plugin assembly.</param>
 017    public PluginLoadContext(string path) : base(true)
 18    {
 019        _resolver = new AssemblyDependencyResolver(path);
 020    }
 21
 22    /// <inheritdoc />
 23    protected override Assembly? Load(AssemblyName assemblyName)
 24    {
 025        var assemblyPath = _resolver.ResolveAssemblyToPath(assemblyName);
 026        if (assemblyPath is not null)
 27        {
 028            return LoadFromAssemblyPath(assemblyPath);
 29        }
 30
 031        return null;
 32    }
 33}