< Summary

Information
Class: NexusLabs.Needlr.Injection.Reflection.Loaders.ReflectionAssemblyLoader
Assembly: NexusLabs.Needlr.Injection.Reflection
File(s): /home/runner/work/needlr/needlr/src/NexusLabs.Needlr.Injection.Reflection/Loaders/ReflectionAssemblyLoader.cs
Line coverage
100%
Covered lines: 13
Uncovered lines: 0
Coverable lines: 13
Total lines: 37
Line coverage: 100%
Branch coverage
50%
Covered branches: 2
Total branches: 4
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor()50%44100%
LoadAssemblies(...)100%11100%

File(s)

/home/runner/work/needlr/needlr/src/NexusLabs.Needlr.Injection.Reflection/Loaders/ReflectionAssemblyLoader.cs

#LineLine coverage
 1using System.Diagnostics.CodeAnalysis;
 2using System.Reflection;
 3
 4namespace NexusLabs.Needlr.Injection.Reflection.Loaders;
 5
 6/// <summary>
 7/// Assembly loader that uses reflection to discover the entry assembly.
 8/// </summary>
 9/// <remarks>
 10/// This loader is not compatible with NativeAOT or trimming. For AOT scenarios,
 11/// use GeneratedAssemblyProvider from NexusLabs.Needlr.Injection.SourceGen with the Needlr source generator instead.
 12/// </remarks>
 13[RequiresUnreferencedCode("ReflectionAssemblyLoader uses reflection to load assemblies. Use GeneratedAssemblyProvider fo
 14public sealed class ReflectionAssemblyLoader : IAssemblyLoader
 15{
 16    private readonly FileMatchAssemblyLoader _fileMatchAssemblyLoader;
 17
 18    [UnconditionalSuppressMessage("SingleFile", "IL3000:Avoid accessing Assembly file path when publishing as a single f
 19        Justification = "This class is only used for non-AOT scenarios where Assembly.Location is available.")]
 36220    public ReflectionAssemblyLoader()
 21    {
 36222        var filePath = Assembly.GetEntryAssembly()?.Location ??
 36223            throw new InvalidOperationException("Entry assembly location is null.");
 36224        var entrypointPath = Path.GetFileName(filePath);
 36225        _fileMatchAssemblyLoader = new FileMatchAssemblyLoader(
 36226            [AppDomain.CurrentDomain.BaseDirectory],
 36227            fileName =>
 36228            {
 1727229                return
 1727230                    fileName.Equals(entrypointPath, StringComparison.OrdinalIgnoreCase);
 36231            });
 36232    }
 33
 34    /// <inheritdoc />
 35    public IReadOnlyList<Assembly> LoadAssemblies(bool continueOnAssemblyError) =>
 28236        _fileMatchAssemblyLoader.LoadAssemblies(continueOnAssemblyError);
 37}