< Summary

Information
Class: Elsa.Extensions.ModuleExtensions
Assembly: Elsa.Api.Common
File(s): /home/runner/work/elsa-core/elsa-core/src/common/Elsa.Api.Common/Extensions/ModuleExtensions.cs
Line coverage
100%
Covered lines: 14
Uncovered lines: 0
Coverable lines: 14
Total lines: 55
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.cctor()100%11100%
AddFastEndpointsAssembly(...)100%11100%
AddFastEndpointsAssembly(...)100%11100%
AddFastEndpointsAssembly(...)100%11100%
GetFastEndpointsAssembliesFromModule(...)100%11100%
AddFastEndpointsFromModule(...)100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/common/Elsa.Api.Common/Extensions/ModuleExtensions.cs

#LineLine coverage
 1using System.Reflection;
 2using Elsa.Features.Services;
 3using FastEndpoints;
 4
 5// ReSharper disable once CheckNamespace
 6namespace Elsa.Extensions;
 7
 8/// <summary>
 9/// Provides extensions to <see cref="IModule"/>.
 10/// </summary>
 11public static class ModuleExtensions
 12{
 113    private static readonly object FastEndpointsAssembliesKey = new();
 14
 15    /// <summary>
 16    /// Registers the specified assembly for FastEndpoint assembly discovery.
 17    /// </summary>
 18    public static IModule AddFastEndpointsAssembly(this IModule module, Assembly assembly)
 19    {
 620        var assemblies = module.Properties.GetOrAdd(FastEndpointsAssembliesKey, () => new HashSet<Assembly>());
 521        assemblies.Add(assembly);
 522        return module;
 23    }
 24
 25    /// <summary>
 26    /// Registers the assembly for FastEndpoint assembly discovery using the specified marker type.
 27    /// </summary>
 328    public static IModule AddFastEndpointsAssembly<T>(this IModule module) => module.AddFastEndpointsAssembly(typeof(T))
 29
 30    /// <summary>
 31    /// Registers the assembly for FastEndpoint assembly discovery using the specified marker type.
 32    /// </summary>
 533    public static IModule AddFastEndpointsAssembly(this IModule module, Type markerType) => module.AddFastEndpointsAssem
 34
 35    /// <summary>
 36    /// Returns all collected assemblies for discovery of endpoints.
 37    /// </summary>
 138    public static IEnumerable<Assembly> GetFastEndpointsAssembliesFromModule(this IModule module) => module.Properties.G
 39
 40    /// <summary>
 41    /// Adds FastEndpoints to the service container and registers all collected assemblies for discovery of endpoints.
 42    /// </summary>
 43    public static IModule AddFastEndpointsFromModule(this IModule module)
 44    {
 145        var assemblies = module.GetFastEndpointsAssembliesFromModule().ToList();
 46
 147        module.Services.AddFastEndpoints(options =>
 148        {
 149            options.DisableAutoDiscovery = true;
 150            options.Assemblies = assemblies;
 251        });
 52
 153        return module;
 54    }
 55}